Skip to content

Commit 6b9f5c7

Browse files
committed
refactor: update backend imports and improve model registration in TinkerService
- Changed import of TinkerBackend from art.local to art.tinker. - Refactored model registration logic in TinkerService to use a models dictionary instead of sampling clients. - Enhanced checkpoint handling and model registration for better clarity and maintainability. - Updated response handling in the Proxy class to use integer IDs instead of UUIDs for requests and responses.
1 parent 3fb3563 commit 6b9f5c7

5 files changed

Lines changed: 293 additions & 154 deletions

File tree

dev/yes-no-maybe.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import openai
77

88
import art
9-
from art.local import LocalBackend
9+
from art.tinker import TinkerBackend
1010

1111

1212
async def rollout(client: openai.AsyncOpenAI, prompt: str) -> art.Trajectory:
@@ -40,7 +40,7 @@ def with_quotes(w: str) -> str:
4040
async def main():
4141
load_dotenv()
4242

43-
backend = art.TinkerBackend()
43+
backend = TinkerBackend()
4444
global model
4545
base_model = os.environ.get("BASE_MODEL", "Qwen/Qwen3-30B-A3B-Instruct-2507")
4646
model = art.TrainableModel(

src/art/tinker/prefix_cache.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ def __init__(self, max_entries: int = 1024) -> None:
2828

2929
@staticmethod
3030
def _encode_tokens(tokens: Sequence[int]) -> str:
31-
packed = bytearray()
32-
for token in tokens:
33-
packed.extend(struct.pack(">I", token))
34-
return packed.hex()
31+
if not tokens:
32+
return ""
33+
return struct.pack(f">{len(tokens)}I", *tokens).hex()
3534

3635
def lookup(self, rendered_tokens: Sequence[int]) -> PrefixEntry | None:
3736
key = self._encode_tokens(rendered_tokens)

0 commit comments

Comments
 (0)