hanzo-train
Tinker-shaped Python client for the Hanzo Engine training API.
It mirrors the shapes of Thinking Machines' tinker
SDK, so training loops written against tinker port across unchanged, while using
Hanzo-canonical field names. The transport is synchronous httpx with no retries;
the four training ops return a completed future exposing .result(timeout=None)
so fut.result() code ports 1:1.
Install
pip install hanzo-train
Quickstart
from hanzo_train import ServiceClient, LoraConfig, AdamParams, SamplingParams, Datum, ModelInput
sc = ServiceClient(base_url="http://localhost:1234", api_key=None) # api_key -> Authorization: Bearer
tc = sc.create_lora_training_client(
"HuggingFaceTB/SmolLM2-135M", lora_config=LoraConfig(rank=16), wait=True, timeout=600.0
)
# wait=True polls the client until status is ready (raises on failed); wait=False returns immediately.
out = tc.forward_backward([
{"prompt": "2+2=", "completion": "4"},
Datum(model_input=ModelInput(tokens=[1, 2, 3]), target_tokens=[2, 3, 4], weights=[0.0, 1.0, 1.0]),
]).result()
# out.loss, out.num_tokens, out.metrics
tc.optim_step(AdamParams(lr=1e-4)).result()
resp = tc.sample(
prompt="2+2=", sampling_params=SamplingParams(max_tokens=8, temperature=0.0), num_samples=1
).result()
# resp.sequences[0].tokens / .text
saved = tc.save_weights_and_get_sampling_client(name="my-adapter").result() # .path, .format == "peft"
# alias: tc.save_weights(name="my-adapter")
info = tc.get_info() # TrainingClientInfo incl. loss_history
sc.list_training_clients() # list[TrainingClientInfo]
tc.delete()
Errors
Every non-2xx response raises HanzoTrainError(status, message):
400— bad input404— unknown training client id409— client still loading, or failed to load
API
ServiceClient(base_url, api_key=None)
create_lora_training_client(base_model, lora_config=None, wait=True, timeout=600.0, poll_interval=1.0) -> TrainingClientlist_training_clients() -> list[TrainingClientInfo]close()
TrainingClient
forward_backward(data) -> Future[ForwardBackwardResult]—dataitems are either{"prompt": str, "completion": str}dicts orDatumvalues.optim_step(adam_params=None) -> Future[OptimResult]sample(prompt=None, tokens=None, sampling_params=None, num_samples=1) -> Future[SampleResult]— pass exactly one ofpromptortokens.save_weights_and_get_sampling_client(name, dir=None) -> Future[SaveResult](alias:save_weights)get_info() -> TrainingClientInfodelete()
Metadata
Release files for hanzo-train 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hanzo_train-0.1.1.tar.gz | 8.3 kB | Without provenance | Details for hanzo_train-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hanzo_train-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for hanzo_train-0.1.1-py3-none-any.whl |
Total release size: 15.0 kB
Release files / hanzo_train-0.1.1.tar.gz
| Download URL | hanzo_train-0.1.1.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2a9f463db50a18477a469213ea5d37ea6f0025e781d5069e3dc18668e9695200
|
|
BLAKE2b-256 checksum How to use checksums |
2f773975f564ed6b1af1c1a2b25e5203dc94443fac8faad73b783be6db97e423
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.9
|
Release files / hanzo_train-0.1.1-py3-none-any.whl
| Download URL | hanzo_train-0.1.1-py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
753d14d357eb23817068a41d80f3a0a03df351aaaaca8d09facf497a0dbe9026
|
|
BLAKE2b-256 checksum How to use checksums |
40863f4523899b7c4737e0a2afe17aa84b20b18b2df788528af13908918c4ac0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.9
|
Security for hanzo-train 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.