hf-to-litertlm
One command from a Hugging Face model repo to a .litertlm bundle for Google's
LiteRT-LM runtime, on a pinned toolchain. Rebuilding from
the lock file it writes gives the same bytes.
uvx hf-to-litertlm <org>/<model> # -> out/<model>/: <model>_int8.litertlm, <model>.lock.json, convert_report.json
uvx hf-to-litertlm verify out/<model>/<model>.lock.json # rebuild from the lock: MATCH = the same bytes
uvx hf-to-litertlm check out/<model>/<model>_int8.litertlm # litert-lm 0.18.0, CPU: load + an echo prompt -> PASS / FAIL
uvx needs uv; pip install hf-to-litertlm pulls uv in as a dependency
and gives the same hf-to-litertlm command. Tested on macOS arm64 only; Linux is untested. On an M4 Max
(128 GB), a 1.7B model took 3 to 4 minutes, the gate included, and peaked at 25 GB of RAM;
gemma-4-E2B-it took 7 minutes and 64 GB
(locks/refs/CHANGELOG.md).
- Pinned toolchain. litert-torch 0.9.4, litert-lm-builder 0.18.0, litert-lm 0.18.0, torch 2.13.0 and
transformers 5.14.1, and every other package at the version in the repository's
uv.lock. The package carries the converter scripts with thatpyproject.tomlanduv.lockand runs them withuv run --frozen --project ~/.cache/hf-to-litertlm/<version>/, which gives the environmentuv syncmakes in a clone of the repository;out/is written in the current directory. So a lock the package wrote verifies in a clone, and a clone's lock verifies from the package, when both have the sameuv.lockand the same Python patch version (the reference locks record 3.12.11). The first run installs the environment (about 1.5 GB on macOS arm64, 1.6 GB once a model has been converted; uv also fetches a Python 3.12 if none is installed). Model files download into the Hugging Face cache. - The lock (
<model>.lock.json) records the Hub commit, the size and sha256 of every file the export read, the export call, every package version, and the sha256 of the bundle and of each of its sections. litert-lm-builder writes a random uuid and the current time into every bundle header (google-ai-edge/LiteRT-LM#4064); the converter takes the timestamp from the source commit and the uuid from the source, the recipe and the toolchain instead. The export runs underPYTHONHASHSEED=0, because litert-torch writes the stop tokens in set iteration order (google-ai-edge/litert-torch#1346). A lock verifies only on the toolchain that wrote it: when the Python version or a package version differs,verifystops withFAIL toolchainand lists the differences. - Checked before it is called done. The gate: eight short questions with known answers (17 + 25, the capital of Japan, …) on the pinned litert-lm CLI, CPU, greedy, scored for the answer and for degenerate output; pass = 6 of 8. Refused with a JSON reason, among others: repos gated behind an access request, architectures that need the repo's own Python code, pre-quantized weights, repos without full weights. A LoRA / PEFT adapter repo is merged into its base and then exported (that route writes no lock yet).
- A chat template litert-lm 0.18 can render. litert-lm 0.18 renders chat templates on native values:
a map has no Python methods, and a message's content is a list of text parts. When the model's template
does not render the way transformers renders it, the converter edits it (
.get→ indexing, the parts → one string) and keeps the edit only if the prompt renders byte-identical to transformers on three test conversations (four when the template readsenable_thinking). The lock records the edits. - One line when it fails:
FAIL <stage>: <op or first error line> -> next: <hint>. Exit codes ofhf-to-litertlm <org>/<model>: 0 = converted and passed the gate, 1 = the gate or the check failed, 2 = refused or stopped before any weight file is downloaded, 3 = any later failure;verifyexits 0 on MATCH,checkexits 0 on PASS.
Rebuilt byte for byte from their locks in a clone, on macOS arm64: Qwen/Qwen3-1.7B,
HuggingFaceTB/SmolLM2-1.7B-Instruct and google/gemma-4-E2B-it (gate 8/8, 7/8 and 8/8). From this
package, Qwen/Qwen3-1.7B converted to the bytes that its lock in
locks/refs/ records (gate 8/8),
and a clone rebuilt the package's lock to the same bytes.
The hybrid families that need a patched litert-torch checkout (granite-4.0-h, Falcon-H1, Zamba2,
Nemotron-H) and the hand-made recipes of the repository's published conversions (--curated) run from
a clone of the repository; the package refuses both
before any weight file is downloaded and names the clone (a model that has a hand-made recipe still
converts on the generic path).
The design, the lock format and how to raise the toolchain: docs/one-command-lock.md.
Metadata
Release files for hf-to-litertlm 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 |
|---|---|---|---|---|
| hf_to_litertlm-0.1.1.tar.gz | 184.8 kB | Without provenance | Details for hf_to_litertlm-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hf_to_litertlm-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for hf_to_litertlm-0.1.1-py3-none-any.whl |
Total release size: 369.5 kB
Release files / hf_to_litertlm-0.1.1.tar.gz
| Download URL | hf_to_litertlm-0.1.1.tar.gz |
|---|---|
| Size | 184.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6fd17bf3404455ca2e05eb1cd7668a2b8c40993fe190d259576807abf872fc82
|
|
BLAKE2b-256 checksum How to use checksums |
b1508ae2a2448d65fc267460936099a4ce4b39cf85d15c5b88552d3d46f3d1f0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.11
|
Release files / hf_to_litertlm-0.1.1-py3-none-any.whl
| Download URL | hf_to_litertlm-0.1.1-py3-none-any.whl |
|---|---|
| Size | 184.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b0b72f896fb807359be8f8b8e335bf73c10e7eceec29bec642ebd9d4aef16182
|
|
BLAKE2b-256 checksum How to use checksums |
093976e88038f8e6a2ee91e622a5cdfd678147a7b4aecd3fcf63f5e39980a97c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.11
|
Security for hf-to-litertlm 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.