Skip to content

Inkling-2-Small: Serve on two GB10s from an EXL3 pack - #4841

Open
ajensenwaud wants to merge 27 commits into
ashhart:mainfrom
ajensenwaud:ink-small-tp2
Open

ajensenwaud wants to merge 27 commits into
ashhart:mainfrom
ajensenwaud:ink-small-tp2

Conversation

@ajensenwaud

@ajensenwaud ajensenwaud commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Inkling 2 Small has its kernels in TensorFold through #4125, #4126 and #4127, but nothing serves it yet. A pair of DGX Sparks can hold Small at 2.2 bits a weight, which is how people run it today, but that needs a loader for the pack and a runtime that splits the model across the two machines. This PR adds both.

What this changes

  • Pack. A standard exllamav3 1.x EXL3 pack on the mul1 codebook loads as it comes from exllamav3. Any other codebook, version or format is refused by name before a tensor is read. The reader is our own and sits beside inkling: load EXL3 packs through the shared family plan #3612, which reads kortexa's pack format.
  • Ranks. Rank 0 serves and drives rank 1 over NCCL, and each layer's partial sums cross by RoCE writes. Each projection and expert is cut to its rank when it loads.
  • Serving. One stream gets the model's full 1,048,576-token window, or several streams share each decode step. Prompts run in 2,048-row chunks, kept prompt states resume a conversation, and images go through the vision tower.
  • Scope. The KV cache is bf16 and a stream decodes one token a step. The DSpark drafter, fp8 KV and the faster-decode switches come in follow-up PRs.
  • Switches. TF_INKLING2_RANK and TF_INKLING2_WORLD name a rank, with rows in docs/environment.md. docs/recipes/inkling-2-small-cuda.md has the run commands.

Stacked on #4127 at 467dbe87b; only the last six commits are new.

Checks on this head

  • Equality. With main's db36991e0 reverted, token ids equal the release build's on all 28 cases at bf16 KV. That commit changes the arithmetic of tf_ink2_mix, so with it every case differs from the release.
  • Concurrency. Four and eight requests at once give the same tokens as each request alone, in both the served cases and bench_concurrent.py.
  • Resume. A conversation resumed from a kept prompt state gives the same tokens as a fresh one at 21,857 prompt tokens.
  • Cache. That resumed turn reads 20,480 tokens from the prompt cache and starts answering in 3.9 seconds, against 61.4 seconds the first time.
  • Graphs. Graphed decode matches eager decode on all 46 steps.
  • Speed. One stream decodes at 31 tokens a second, and four streams reach 69 to 71 in total.
  • Host. All 860 build steps of zig build test test-gradient-serving compile-cuda-tests -Dfixed-cpu pass, with 13,404 of 13,500 tests (96 skipped). lean_check finds no new problems, and every Zig file is at most 600 lines.

The device runs happened on 24 November on two GB10s against ajensenwaud/inkspark-2dgx at aa29f3a0. Equality, concurrency and resume ran again on 85dc7a169, which carries this head's patch on an older main, and the host run on d67d65682, the same patch on main ef4dd750b. The cache, graph and speed figures come from 6b579b2a0 on main 0300dfbfe, whose Inkling 2 files differ from this head only in two hook signatures. The review fixes ran on 25 November on this head: equality, serial equality across the prompt GEMM threshold and the checkpoint check.

Receipt

Commits.

  • 4d06cf054: load standard exllamav3 packs with two-rank cuts.
  • 3da1f58fa: serve Small on two GB10s from an EXL3 pack.
  • ff6abfb87: add the Inkling 2 Small CUDA recipe page.
  • 31069d466: choose a stream's slot before publishing its lane.
  • 338b9ca5f: compare every shard byte across the ranks at ready.
  • 5fee538c3: make a call's scratch safe to free at every failed allocation.

Size. 31 files, +3,629 / -10 over #4127. Shared files take +41 / -8; the rest is new under zig/src/families/inkling2/ and docs/recipes/.

Hardware. Two DGX Spark (GB10, sm_121), RoCE between them, bf16 KV, 12 GiB reserve a rank, images on.

Token equality (tools/g3-equal/ab_tokens.py, 28 cases: chat, code, agent and report prompts, 3,421 and 21,857 prompt tokens, four- and eight-request runs, a resumed run and an image, 256 tokens each, greedy): with db36991e0 reverted, 28 of 28 equal the release build's. Without the revert, 28 of 28 equal the same patch's earlier run on main 68ff0ad8e. Within the head, the four- and eight-request runs equal the single ones, and the resumed run equals the fresh one.

Prompt cache. A follow-up chat turn on a 21,857-token conversation:

Turn Cached tokens TTFT s
First 2,048 61.4
Resumed 20,480 3.9

bench_cache.py (token-id prompts from the pack's tokenizer, 64 tokens): raw completions keep no prompt state, so every repeat runs cold with 0 cached tokens. Repeated and concurrent replies equal the first.

Prompt tokens TTFT s, first TTFT s, repeat Two at once, makespan s
2,000 6.0 6.0 14.5
7,999 24.0 23.9 50.5
32,017 95.8 96.0 194.9

spark-bench (bf16 KV, 512 tokens, chat/code/agent/report):

Streams Per stream tok/s Total tok/s TTFT p50 s
1 31.2 to 31.6 30.7 to 31.2 0.23 to 0.31
2 24.1 to 24.5 47.5 to 48.3 0.34 to 0.47
4 17.6 to 18.2 69.2 to 71.5 0.55 to 0.72

bench_openai.py (256 tokens, 3 reps): 31.9 tok/s on fibonacci-raw at temperature 0, 31.9 on gpu-chat-no-think.

bench_concurrent.py (--alone --serial): equal to alone at 1, 2 and 4 streams on code and chat, 0 unequal.

Graphs. tf-inkling2-engine graphs: 46/46 steps bit-identical, 5 captured, 41 replayed, on 7c7998de4, an earlier head of this branch on main 0300dfbfe.

Kernel contract. No new kernels; the PR runs on #4125, #4126 and #4127.

Notices. THIRD_PARTY_NOTICES.md credits exllamav3 (MIT) for the EXL3 format and HF transformers (Apache-2.0) for the layer order.

@ajensenwaud
ajensenwaud force-pushed the ink-small-tp2 branch 2 times, most recently from e97933a to f6f897a Compare November 24, 2026 06:16
@ashhart

ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thank you, @ajensenwaud. The aligned rank cuts, slot-aware cache states and explicit image-cache handling are good foundations. The pinned pack and concurrency receipts help.

Three source issues need fixing. In lanes.zig, the new map entry is inserted before pick scans its values, so it reads that entry's uninitialized slot; choose the slot before publishing the entry and cover failed initialization. In engine.zig, checkpoint_digest stays all zero, so the rank-ready check cannot reject different checkpoint bytes. Please populate the real content identity and add a mismatch control. In forward.zig, partial allocation cleanup reads the still-uninitialized ids or logits buffer; please make cleanup safe at each failure point.

Please retain serial equality across the prompt GEMM threshold and shared-kernel changes when checking the corrected tree. The changelog conflict can be handled at integration.

  • Synthena

ajensenwaud and others added 19 commits November 24, 2026 16:54
The family's attention was a copy of prefill_attention.cu's
vision_kernel, so the tower now calls vit.Attention.full at head dim 64,
the instance and record Qwen3-ASR already brought to main.
grouped_body takes the member tiles a program as a template parameter.
tf_exl3_grouped_wide_2 runs 32 members by 64 columns for prompt chunks;
the existing instantiations compile to the same SASS on every SM.
nvcc 13.3 changed tf_exl3_grouped_2's sm_120 and sm_121 SASS when the
wide instance followed it; defined first, every existing kernel compiles
as before under 13.0 and 13.3.
The item plan was limited to mcg and slot rows written to ey. It now
takes every codebook, writes scratch y when ey is 0, picks the wide
kernel for 32-member items and the capped epilogue for act_mode 3.
The family's grouper and grouped projections were copies of core's.
Inkling now runs exl3_experts.runWith on grouped.Router's item plan,
16-member items below 512 rows and the wide kernel from there; outputs
are bit-equal to the kernels this replaces. Expert widths up to 8 bits
are admitted, as core decodes them.
tf_ink2_gateup duplicated core's gate/up epilogue apart from the
softcaps, which core now runs as act_mode 3. Its registration moves to
tf_exl3_gateup_capped, with the swapped-caps control kept.
RADIO, MiniMax M3, Qwen 27 and Inkling 2 each kept their own copy of
the placeholder span and the cut that maps a prompt pass onto it. They
now share core.image_rows, started from RADIO's copy, and each family
keeps only its own splice.

The cut now works in usize and takes the offset before adding the
buffer row, as RADIO's did. MiniMax M3 and Inkling 2 already cut in
usize, so their results are unchanged. RADIO and Qwen 27 no longer
overflow u32 on a span that ends past 2^32; nothing else changes.
Inkling 2's tf_ink2v_scale_add was a layer-scaled residual add, which
is tf_vit_pointwise with a per-column scale between the activation and
the add. vit.cu now has tf_vit_pointwise_gamma for that, and the tower
calls it through vit.Kernels.pointwiseGamma. Its fp32 multiply, bf16
rounding and add are the same round-to-nearest steps the family kernel
took, so the tower's results are unchanged.

Every existing function in vit.cu and inkling2/vision.cu compiles to
the same SASS on sm_80, 86, 89, 120 and 121 under nvcc 13.0 and 13.3.
The contract now registers the core kernel, with the late-gamma control
retargeted to it; its records come from cuobjdump -res-usage, and 13.2
stays pending.
The Metal and residency builds give qwen27 its own core roots, which
lacked image_rows after the shared module moved into core.
Core builds exl3_experts.cu with contraction on, so the soft-capped
SwiGLU's products and sum fused into FMAs, and Inkling 2 Small's tokens
no longer matched the build it was validated on. Explicitly rounded
operations give the SASS the old text has at the glue kernels' flags.
…ls, bit for bit

With ashhart#4127, Inkling 2's softcapped gate/up epilogue and vision layer scale
come from core (tf_exl3_gateup_capped, tf_vit_pointwise_gamma) in place of
main's family kernels (tf_ink2_gateup, built at --fmad=false, and
tf_ink2v_scale_add). A host test writes both kernels' arithmetic at their
rounding points: every product and sum on its own, the same order, the shared
rotation and the fp16 or bf16 store. Over 512 random 128-column blocks with
saturating and non-finite inputs, and 65,536 layer-scale values, the old and
new forms give the same bits. A control contracts one product into the
rotation's first sum, as core's fmad=true flags would without the explicit
_rn operations, and it differs, so the comparison can see one fused rounding.
Reads an EXL3 pack from exllamav3 1.x on the mul1 codebook: every
attention projection and the head as EXL3 linears, each layer's experts
as one grouped layer, cut to a rank by key heads, columns or rows.
Rank 0 serves and sends every step to rank 1 over NCCL; the per-layer
partial sums cross by RoCE writes. Decode rows from several streams
share one graphed forward, prompts run in 2,048-row chunks with kept
states at chunk starts, and images go through the vision tower. No
drafter yet: a stream decodes one row a step.
The new map entry went in before pick scanned the lanes, so the scan
read the entry's unset slot, and a failed pick left the entry behind.
The slot is now chosen first and the entry added only once it has one.
checkpoint_digest stayed zero, so the ready check passed two ranks
holding different packs. Each rank now hashes every shard byte beside
the load and hands that digest to the check.
Buffers.deinit read ids and logits before init had made them. Both
now start empty, and a fake-driver test fails each allocation in turn.
@AIFlowML

Copy link
Copy Markdown
Contributor

On 5fee538c366f5842b950a774a77dd8f68179b45a, zig build test-inkling2-host test-inkling2-cuda-host check-native-cuda-host -Dfixed-cpu -j2 --summary all passed 122 tests with four skips on Apple silicon. The revised CUDA host suite passed 77/77, including the lane insertion, pack identity, and partial-allocation cleanup cases. The build also compiled the native adapter for aarch64 Linux.

The pack fixture changes a payload byte and checks the resulting digest. To cover readiness end to end, the remaining receipt would be a two-rank run that confirms identical packs reach ready and mismatched packs stop with CheckpointBytesDiffer before either rank serves. I did not run NCCL or checkpoint serving in this pass.

I tested the PR head directly. A trial against d1ff890729 has seven conflicts, including the native CUDA family registration and the Inkling expert contract, so it still needs an integration run on current main.

Igor Lessio - AIFLOW LABS

@ajensenwaud

Copy link
Copy Markdown
Contributor Author

Thanks, Ash, and thanks @AIFlowML. All three are fixed in 5fee538c3, which now sits on your #4127 head 467dbe87b.

  1. Lanes. A new stream's slot is chosen before its lane goes into the map, so pick never reads an entry without a slot. A failed choice leaves no entry behind, and a host test covers both cases.
  2. Checkpoint identity. Each rank now hashes every shard byte while the weights load, and the ready check compares the two digests. A host test shows that one changed byte changes the digest. On two GB10s, identical packs reach ready, with each rank hashing 154.9 GiB beside the load. When rank 1's copy of the pack has its last byte flipped, both ranks stop with CheckpointBytesDiffer and the server never answers.
  3. Scratch cleanup. The token-id and logits buffers start empty, so cleanup is safe at every failure point. A fake-driver test fails each allocation in turn and checks that everything made is freed.
  4. Equality. On this head, prompts of 200, 299, 2,246 and 2,347 tokens, either side of the prompt GEMM threshold, give the same tokens alone and at two and four streams, greedy and sampled. All 28 served cases equal the same patch's earlier run on main 68ff0ad8e. Every case differs from the release build because of main's db36991e0, which normalises before the query reductions in tf_ink2_mix. With that one change reverted, all 28 match the release again.

zig build test passes 13,404 of 13,500 tests on this head, with 96 skipped. Main has since moved shared files that this PR and #4127 both edit, so I'll resolve ours once #4127 lands.

@ashhart

ashhart commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Thanks @ajensenwaud. Slot selection now happens before publishing the lane, and the call buffers start empty before cleanup. The new shard-byte test and reported two-rank mismatch run also close the changed-weight case.

Two fixes remain. The ready digest includes shard bytes but not the effective config, so identical shards with different valid RMS epsilon values can still pass. Please bind that config into readiness and cover a config-only mismatch. Prompt resources also need cleanup if plan insertion, symbol lookup or later engine setup fails. In Engine.init, cleanup still uses the older module copy rather than the copy holding the new prompt resources.

The new threshold and concurrency comparisons are useful. Keep the release-reference difference explicit when checking the corrected tree. Integration conflicts are on our side.

  • Synthena

Two ranks with identical shards but different configs, such as another
rms_norm_eps, passed the ready check. The digest now also covers the
parsed config and the stream shape each rank was started with.
Engine.init cleaned up a stale copy of its modules, which never held the
prompt projections. A failed kernel lookup leaked the GEMM workspace and
a failed plan insertion leaked its descriptor and layouts.
@ajensenwaud

Copy link
Copy Markdown
Contributor Author

Thanks, Ash. Both are fixed in f481bf083, on top of 5fee538c3 with no rebase.

  1. Config. The ready digest now covers the parsed config each rank runs, plus its context and image limits, beside the shard bytes. A host test changes only rms_norm_eps in config.json and shows that the digest changes, as it does for a different context, image limit or shard byte. A mismatch stops both ranks through the same check as a changed shard byte, and the refusal now names settings as well as packs.
  2. Prompt cleanup. Engine.init now cleans up its own copy of the modules, which holds the prompt projections and the grown scratch. The kernel lookups run before any allocation, and a failed plan insertion destroys its plan. Two fake-driver tests fail the module load, each allocation and the plan insertion in turn, and check that everything made is freed. A later setup failure now also frees the vocabulary spans, the graph cache and the partials list.

No kernel or arithmetic changed, so the earlier device results stand, including the release-reference difference that main's db36991e0 causes. test-inkling2-cuda-host passes 80 of 80.

@ashhart

ashhart commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Thank you @ajensenwaud. The ready digest now includes the effective config and stream limits, with a config-only control. The prompt plan has an insertion guard, symbol lookup precedes allocation, and engine cleanup uses the module copy that owns the prompt resources. Those source asks are closed.

This is ready for an exact comparison after integration. Please keep the agreed serial-reference gate and the release-reference difference explicit; the earlier token receipts remain credited.

  • Synthena

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants