mirror of
https://github.com/hanzoai/python-sdk.git
synced 2026-10-23 20:23:00 +00:00
Hand-written package for the engine /v1/training API: ServiceClient + TrainingClient (create/list/get/delete/forward_backward/optim_step/ sample/save_weights), dataclasses, sync httpx, completed-future .result() wrapper so tinker fut.result() code ports 1:1. 22 pytest tests over httpx.MockTransport, no network. Wired like siblings: publish-pypi hanzo-train-* tag case, rye+uv workspace member, uv source, pyright exclude. uv.lock relock also catches the lockfile up to on-disk truth (hanzoai 3.1.1, hanzo-tools-browser 0.5.10) -- no package versions changed.
53 lines
1.3 KiB
Python
53 lines
1.3 KiB
Python
"""Hanzo Train -- Tinker-shaped client for the Hanzo Engine training API.
|
|
|
|
Mirrors the shapes of Thinking Machines' ``tinker`` SDK so training loops port
|
|
across unchanged. Synchronous httpx under the hood; the four training ops return
|
|
a completed future exposing ``.result(timeout=None)``.
|
|
|
|
Usage::
|
|
|
|
from hanzo_train import ServiceClient, LoraConfig, AdamParams, SamplingParams
|
|
|
|
sc = ServiceClient("http://localhost:1234")
|
|
tc = sc.create_lora_training_client("HuggingFaceTB/SmolLM2-135M", LoraConfig(rank=16))
|
|
out = tc.forward_backward([{"prompt": "2+2=", "completion": "4"}]).result()
|
|
tc.optim_step(AdamParams(lr=1e-4)).result()
|
|
resp = tc.sample(prompt="2+2=", sampling_params=SamplingParams(max_tokens=8)).result()
|
|
"""
|
|
|
|
from hanzo_train.client import (
|
|
AdamParams,
|
|
Datum,
|
|
ForwardBackwardResult,
|
|
HanzoTrainError,
|
|
LoraConfig,
|
|
ModelInput,
|
|
OptimResult,
|
|
SampleResult,
|
|
SamplingParams,
|
|
SaveResult,
|
|
Sequence,
|
|
ServiceClient,
|
|
TrainingClient,
|
|
TrainingClientInfo,
|
|
)
|
|
|
|
__version__ = "0.1.0"
|
|
|
|
__all__ = [
|
|
"ServiceClient",
|
|
"TrainingClient",
|
|
"TrainingClientInfo",
|
|
"LoraConfig",
|
|
"AdamParams",
|
|
"SamplingParams",
|
|
"Datum",
|
|
"ModelInput",
|
|
"ForwardBackwardResult",
|
|
"OptimResult",
|
|
"SampleResult",
|
|
"Sequence",
|
|
"SaveResult",
|
|
"HanzoTrainError",
|
|
]
|