Instructions to use thinkingmachines/TML-d24-varloop-research with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use thinkingmachines/TML-d24-varloop-research with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="thinkingmachines/TML-d24-varloop-research") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("thinkingmachines/TML-d24-varloop-research") model = AutoModelForMultimodalLM.from_pretrained("thinkingmachines/TML-d24-varloop-research", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use thinkingmachines/TML-d24-varloop-research with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "thinkingmachines/TML-d24-varloop-research" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "thinkingmachines/TML-d24-varloop-research", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/thinkingmachines/TML-d24-varloop-research
- SGLang
How to use thinkingmachines/TML-d24-varloop-research with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "thinkingmachines/TML-d24-varloop-research" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "thinkingmachines/TML-d24-varloop-research", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "thinkingmachines/TML-d24-varloop-research" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "thinkingmachines/TML-d24-varloop-research", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use thinkingmachines/TML-d24-varloop-research with Docker Model Runner:
docker model run hf.co/thinkingmachines/TML-d24-varloop-research
Bare-metal C++20/CUDA ingestion of TML-d24-varloop-research on a single RTX 5090
What was converted. TML-d24-varloop-research is a research release from
Thinking Machines Lab: the variable-loop variant of the Inkling 2
architecture. It is the same 24-layer sparse mixture-of-experts decoder as the
Inkling 2 Mini release β 24 physical layers, of which the middle twelve
([6, 18)) are run repeatedly with shared weights β with one capability added:
the number of passes through those twelve layers is chosen at inference time
instead of being fixed by the checkpoint. The official weights were trained with
1 to 5 passes (sampled 1:2:6:2:1) and post-trained at 3.
The checkpoint ships as a single 18.19 GiB shard (plus a 0.59 GiBmtp.safetensors its index does not list) and converts to an 18 GiB artifact
with 645 pinned tensors and 3 072 routed-expert records. The dense plane is
device-resident (3.0 GiB minimum, 4.8 GiB at the planner's preferred layout) and
all 3 072 routed experts sit in one 14.71 GiB device slab β the artifact is
resident as a whole on a 32 GiB card. Conversion takes 17 seconds.
What "variable loop" is, and what it is not. The saved config declaresloop_config.is_varloop: true, and the reference implementation never branches
on that flag: it reads loop_num_passes and appends passes β 1 deep copies of
the looped layers' cache state, whatever that number is. So the flag is a
capability declaration, not a second code path, and the capability is exactly
what the model card says: one set of weights, any pass count in the trained
range. The engine therefore keeps the checkpoint's own default of 3 passes and
exposes the count as a load-time choice over 1..5; the KV/conv slab is sized
for the ceiling (72 slots, one block of 12 per extra pass), so changing the count
never re-allocates and never moves a slot. A count outside the trained range is
clamped with a warning rather than run.
The architecture forces the same six things as the sibling, and each was
verified against the release's own modelling code rather than inferred:
- No RoPE anywhere. Position enters through a learned bank of 16 relative
profiles over 1 024 backward distances; q and k are L2-clipped per head to
22.627 (qthrough a learned per-head scale,kweight-free) andvis
RMS-normalized without a learned scale. - Log scaling starts at position 8 192, not at the 128 000 of the larger
sibling β copying the wrong floor would leave the whole 8k engine context
unscaled. - Grouped-query attention is 3:1 (24 query heads over 8 kv heads).
- Depth mixing over block prefixes: one block every 6 layers; a boundary
layer appends its incoming hidden state to a stack instead of keeping a
local residual; the four full-attention layers ask for three mixtures and
everything else for one. - Hybrid attention: 20 sliding-window layers (1 024) and 4 full layers at
{5, 11, 17, 23}; the full layers' k/v short convolutions take dynamic taps
(a per-token projection summed with a static table) and swap the normalizer
fromsqrt(k+1)tosqrt(2k+1). - Mixture of experts: 128 routed experts, top-8, no shared expert, sigmoid
scoring with a selection-only FP32 correction bias, weights renormalized then
scaled by 8.0, and a softcapped SwiGLU expert
(tanh(g/4)Β·4 Β· sigmoid(g) Β· tanh(u/25)Β·25) accumulated in FP32.
Nothing is requantized. The release is mixed precision and says so only inhf_quant_config.json: routed experts of layers 0β19 are NVFP4 (E2M1
nibbles, per-16 E4M3 block scales, per-expert global scale amax/2688), layers
20β23 are MXFP8 (E4M3 with a ue8m0 exponent per 32), and everything else is
BF16 except the depth-mixing queries, the merged cross-pass message queries and
the router correction bias, which are FP32. All of it is carried byte-for-byte;
the eight-bit layers decode through the family's dedicated FP8 GEMV.
The checkpoint's own traps (each silent, each now pinned by a test):
- The loop is declared in
text_config.loop_configonly. A decoder that readsnum_hidden_layersalone runs 24 layer applications instead of 48 and answers
confidently. - The pass count is not a fixed property of the weights, but the trained range
is not in the config either.num_passes: 3is the post-trained default; that
1 and 5 are legal comes from the model card, so the artifact records the
ceiling explicitly and the loader refuses a ceiling below the declared count. - The fused expert slab is row-interleaved.
w13_weightstores gate and up rows
alternating; taking the first half as gate and the second as up keeps every
byte, plane size and per-expertamax, and only destroys knowledge. - The expert codec changes mid-stack (NVFP4 β MXFP8 at layer 20) and only
hf_quant_config.jsonknows. - Two cross-pass query tensors must be merged into one
[12][4][2304]in[q, k, v, mlp]order, andattn_res.attn_queries.ibelongs to layeri+1. mtp.safetensorsis 0.59 GiB the index does not list β a converter that walks
the directory instead of the index would ingest it.- The vision tower is 422 tensors of the same checkpoint. Stripped and counted;
this ingestion is text-only and does not claim image input.
A note for the model authors. is_varloop is the single most important
property of this release and it appears nowhere in the checkpoint except one
boolean in text_config.loop_config β not in generation_config.json, not in the
README's configuration block, and not in the modelling code, which reads onlynum_passes. A passes field in generation_config.json (the value the release
was post-trained at) plus a documented range would let an inference stack serve
this model without reading the model card. The same applies to the trained pass
range itself: it exists only in prose.
One DET probe is red, and it is not an engine defect. The determinism gate
runs three long-form probes and compares the extracted answer with a fixed
expectation. On DET-02 the checkpoint echoes the probe's own identifier
(DET-Validation-Core-02) at the head of its reasoning, then answersCATASTROPHIC correctly; the harness's extractor takes the first standalone
upper-case token, so it resolves the echo's DET on BOTH the source and the
engine. The two agree exactly and both are deterministic across three runs, so
what the gate records is a limitation of its extraction rule, not a divergence
between the model and its reference. It is left measured rather than repaired:
the rule is shared by every model in the corpus and would need all of their
goldens re-validated.
What was not measured, and why.
- Context beyond 2 048 tokens. The engine bound is 8 192 positions and the
canonical throughput protocol is 2 048; the log-scaling path that activates
from position 8 192 is therefore exercised only by kernel-level reference
tests. - Pass counts above 5, and quality at 1 or 5. The trained range is enforced,
and the per-count numbers reported here are throughput and determinism, not
benchmark accuracy β reproducing the model card's evaluation table is out of
scope for an ingestion. - Image input. The vision tower is stripped by design (text-tower ingestion),
so the multimodal numbers in the model card do not apply to this build. - The MTP head. Counted, never applied; speculative decoding is not
implemented for this family. - Multi-request concurrency. One
Inferper instance at a time, as for every
family here; the loop's per-pass KV/conv state is per-sequence and is reset at
each request start, which the bit-identical repeat case pins.
Measured numbers
Every number below is copied from the gate output or fromtests/perf/perf_baselines.json.
| measurement | result |
|---|---|
| SelfCheck ("The capital of France is" β "Paris") | PASS, 3 bit-identical cycles, logits_hash=98a2c3c532c9b013, 32-token window, 3 passes |
| knowledge probe (teacher-forced, one prefill per position) | mean NLL 3.4006 β perplexity 29.98, top-1 152717 (" Paris") |
| FSI parity gate | 3/3, source-captured β the release's own 512-token answers, produced by running its code |
| CODE parity gate | 3/3, source-captured β exact-match JSON / assignment / regex answers |
| DET determinism gate | 2/3 β DET-01 and DET-03 green; DET-02 measured red, see below. All three are deterministic across 3 runs |
| native tool round-trip | shared with Inkling-2-Mini (byte-identical tokenizer + template): 56 framing assertions |
| scheduling/state suite | 72 assertions at 1/3/5 passes: application counts follow the active count, the last pass owns the last slab block, two identical requests reproduce their logits bit-for-bit |
| artefact verifier | 3 099 Arrow files, 64 sampled deep over 1 006 MiB, 0 problems (covers the mixed NVFP4/MXFP8 expert planes) |
| artifact / conversion | 18 GiB, 645 pinned tensors, 3 072 expert records, 422 vision tensors stripped, 17 s |
| decode throughput, 2 048 tokens, auto policy | 33.98 tok/s (TTFT 0.32 s), 18 291 MiB resident |
| decode throughput, 2 048 tokens, strict/bit-exact | 32.00 tok/s (TTFT 0.34 s, 207.1 W average, 264.3 W peak) |
| pass-count sweep, 128-token decode | 100.8 tok/s at 1 pass, 48.2 at 3, 33.5 at 5 |
Pass-count behaviour
The row's reason to exist is that the pass count is a runtime choice, so the
engine reports what it actually ran (ActiveLoopPasses(),CacheSlotCount(), LayerApplications()), and the measurement on the real
18 GiB tree at a fixed 128-token decode is:
| passes | layer applications per token | decode rate | framing/answer behaviour |
|---|---|---|---|
| 1 | 24 | 100.8 tok/s | does not reach the "Paris" answer inside the 32-token framed window |
| 3 (the checkpoint's declared default) | 48 | 48.2 tok/s | correct (the gate above) |
| 5 | 72 | 33.5 tok/s | correct |
Cost per layer application is ~24 ms at every count β the passes replay the same
kernels over the same weights, so the rate scales with the count while neither
the KV/conv slab nor the expert window moves with it. Each count has its own
bit-stable logits row (a different number of applications runs), and the
synthetic suite pins the three properties a "compiles and answers"
implementation gets wrong:
- the requested count is what runs β 1, 3 and 5 passes produce 24, 48 and 72
applications, the trace row count follows the active count, and the final
residual row at 5 passes differs from the 3-pass one (a count that only added
bookkeeping would reproduce it bit for bit); - the slab is the ceiling's β a 5-pass run addresses the last block of the
same 72-slot allocation, whose keys are neither pass 0's nor untouched; - determinism at any count β two identical requests at 1, 3 and 5 passes
reproduce the token stream and the logits row bit for bit.
The 1-pass result is the model card's own caveat made concrete ("3 passes
dominated training once looping was introduced"), and it is a property of the
weights rather than of the engine: the same engine is correct at 3 and 5. The
default therefore stays the checkpoint's declared 3, and the trained range is
enforced rather than trusted to the caller.
Throughput
33.98 tok/s auto / 32.00 tok/s bit-exact at the canonical protocol (2 048
tokens, prompt "The capital of France is"), TTFT 0.32/0.34 s, 18 291 MiB
resident, recorded through the harness in tests/perf/perf_baselines.json.
That matches the fixed-pass sibling (34.1 / 32.1 tok/s) on the same card to
within measurement noise, which is the interesting part: this row's KV/conv slab is sized for five
passes (72 slots) instead of three (48), and the difference costs nothing at the
default count. Nothing else about the decode differs β same tower, same kernels,
same 14.71 GiB device expert slab, same 18.3 GiB residency β because the loop
passes replay the loop-layer weights rather than adding any.
The loop is what the decode spends its time on, and the pass count is
consequently a near-linear throughput dial (100.8 / 48.2 / 33.5 tok/s at 1/3/5
passes, measured at a 128-token window). Because that is a change to the model
rather than to the same model's speed, it is a load-time semantic knob
(LSX_INKLING_VARLOOP_PASSES) and not a CLI speed flag.
Attribution of what remains is inherited and already measured on the sibling
(nsys, same kernels): the decode is kernel-bound, dominated by row-block matvec
launches and the depth-mix kernel, which are one-block-per-row with a 256-thread
reduction. Nothing here was re-tuned for this row; a pass-count-5 workload would
shift the balance toward the loop kernels without changing that conclusion.
Full ingestion report, pass-sweep breakdown, and open-source C++20/CUDA runtime:
https://github.com/Alex7MV/logestix/blob/main/docs/model-reports/2026-11-22-TML-d24-varloop-research.md