Views
No views yet
.litertlm bundle, binary-patched to support
a 64k context window on both CPU and GPU. Correct text output verified
against the community 32k bundle.litert-community/gemma-4-E4B-it-litert-lm (32k bundle, magic
cache dim 32003), tf_lite_prefill_decode and tf_lite_mtp_drafter are
binary-patched 32003 → 65003 (prime, avoids an XNNPack slow path that
triggers on composite dims like 65536 or 64006). The patch walks four layers
of the TFLite flatbuffer:shape[i] == 32003 rewritten to 65003
(1 900 entries across decode / prefill / verify, 52 more in the drafter).arange(N) / arange(N)+512 int32 index
tables are regenerated for the new length, appended past the end of the
file, and Buffer.offset / Buffer.size fields rewritten.StableHLOCompositeOptions.CompositeAttributes FlexBuffer blobs of
every odml.cache_update composite are walked and their
kv_cache_batch_size / key_size / value_size / scale_* attributes
rewritten from 32003 → 65003. Missing step 4 gave graphs whose tensor
shapes were right but whose per-layer composite attributes still
referenced 32003 — the runtime then corrupts decode output to
" agregado<pad><pad>...". All earlier -patched revisions had this bug;
this release (v2) is the first with correct text output.main)--async=false), --conv_type=float, --max_num_tokens=2048 (typical
short-chat cache — see note below).| Backend | Prefill tok/s | Decode tok/s | TTFT | vs CPU |
|---|---|---|---|---|
| CPU | ~30 | ~8.9 | ~40 s | 1× |
| GPU | ~512 | ~33 | ~2.0 s | 3.7× |
--max_num_tokens. For the long-
context floor: at --max_num_tokens=65000 (full bundle capacity), decode
lands near 21 tok/s with TTFT ≈ 4.8 s for a 1024-token prompt.libLiteRtTopKWebGpuSampler.dylib on
macOS exports only 3 of the 7 C symbols the runtime dynamically loads:
_UpdateConfig, _CanHandleInput, _HandlesInput, and
_SetInputTensorsAndInferenceFunc are compiled in but marked
non-external (was a private external) because of the
macos_exported_symbols.lds export list. The runtime then prints
GPU sampler unavailable. Falling back to CPU sampling. and every decode
step transfers the full logits tensor GPU → CPU for argmax.LC_DYLD_EXPORTS_TRIE:1# ctox repo helper (scripts/models/patch_webgpu_sampler_exports.py) —
2# appends a new 7-symbol exports trie at EOF, extends __LINKEDIT by 200 B,
3# and ad-hoc re-signs the dylib. No source rebuild required.
4python scripts/models/patch_webgpu_sampler_exports.py \
5 <LITERT_LM_PREBUILT_DIR>/libLiteRtTopKWebGpuSampler.dylib--enable_speculative_decoding=true) crashes the
WebGPU path with ALREADY_EXISTS: wgpu::Instance already set when drafter
and main model both try to create a WebGPU instance. On CPU it runs but
produces 0 % acceptance rate — the drafter's first token never matches
the verifier, so MTP is a strict slowdown on this runtime version. Keep
it off until upstream ships a fix.--gpu_external_tensor_mode=true fails on Gemma 4 bundles with
INVALID_ARGUMENT: bytes-per-token exceeds output tensor size — the
external-tensor path has a hard-coded token count that doesn't match
Gemma 4's PLE layout. Can't enable.runtime/components/embedding_lookup/embedding_lookup_text.cc on
non-Android builds. Forcing them to GPU regresses throughput by ≈ 9 ×
(E2B drops 68 → 9 tok/s) because the WebGPU delegate has no
embedding-lookup kernel and silently falls back with bad scheduling.
Leaving them CPU-pinned is correct.gpu_artisan backend referenced in
--helpfull is internal-only. WebGPU → Dawn → Metal is the only GPU path
on macOS today.1litert-lm run --from-huggingface-repo metricspace/gemma4-E4B-it-litert-64k-mtp \
2 model.litertlm -b gpu --prompt "Explain transformers."litert_lm_advanced_main:1litert_lm_advanced_main \
2 --model_path=model.litertlm \
3 --backend=gpu --async=false \
4 --max_num_tokens=2048 \
5 --conv_type=float \
6 --benchmark --benchmark_prefill_tokens=1024 --benchmark_decode_tokens=256--max_num_tokens--max_num_tokens=2048 → ~33 tok/s decode.--max_num_tokens=8192 → ~32 tok/s decode.--max_num_tokens=65000 → ~21 tok/s decode,
4.8 s TTFT for a 1024-token prompt.scripts/models/patch_tflite_cache_length.py (composite-
attribute walker included, v2) and repacked with
scripts/models/repack_litertlm.py from the ctox repository. The optional
sampler-dylib trie patcher lives in
scripts/models/patch_webgpu_sampler_exports.py.