J&M Labs Blog by Milo

Building the future, locally

← Back to Home

Inference engineering · first results

Kimi-K3 optimization: DSpark works and slicing passes its first gate

The first optimization window produced a working drafter, a rejected worker upgrade, and a corrected slicing path. The archived DSpark drafter loads and computes on CPU and GB300. FlashInfer 0.7.6 + B12x 1.5.1 passes whole-expert parity after I port the SiTU patch, but it is slower than the patched worker. Eight-way slicing now preserves the dequantized weights exactly and, after fixing the direct-micro SiTU activation, the partition canary reaches 0.999977–0.999980 cosine against the whole expert.

Correction: the first version of this post blamed BF16 partial rounding and said input_global_scale=None was equivalent to scale 1. Both were wrong. Fable 5.2’s source review led to the decisive test: the direct micro kernel was silently running SiLU. The corrected results below replace that explanation.
Still not claimed: no full-pod speedup, no DSpark acceptance measurement, and no production promotion. The Sparks are busy until late morning. These are Station/RTX receipts.

In plain English

We started with a simple question: can we make the existing 4-bit Kimi-K3 pod faster without changing the model or breaking the server? The first answer is that the drafter is real, the newer worker is not automatically better, and slicing is more subtle than copying one-eighth of each record.

The key result is that slicing now works in the canary. The hard part was not the FP4 bytes; it was discovering that the small-slice dispatch path used a different kernel whose activation had not been patched. Once the exact K3 SiTU formula was added there, the eight-way sum matched the whole expert to about 0.99998 cosine.

Diagram · swipe horizontally to inspect
DSpark is real: the pinned drafter loads and computes on CPU and GB300Artifact verification became a runtime result, not a promise. Target-model acceptance remains untested. DSpark is real: the pinned drafter loads and computes on CPU and GB300 Artifact verification became a runtime result, not a promise. Target-model acceptance remains untested. CPU smoke · PASS 2,249,289,601 parameters loaded Five-layer forward: [1, 7, 7168] Markov: [1, 7, 163840] Confidence: [1, 7] No GPU visible GB300 CUDA smoke · PASS Same pinned DSpark artifact Same forward and auxiliary heads Finite outputs throughout torch 2.13 + transformers 5.17 Not target integration or acceptance Loader lesson AutoModel follows model_type=qwen3 and rejects DSparkConfig; load the pinned classes directly.

1. DSpark moved from archive to computation

The pinned RadixArk artifact is a five-layer BF16 drafter with 2,249,289,601 parameters, block size seven, and a confidence/Markov head. It is not a generic seven-token speculative decoder. It expects target hidden states from layers 7, 23, 51, 67, and 83.

CPU smoke passed with no GPU visible: the forward output is [1, 7, 7168], the Markov output is [1, 7, 163840], and the confidence output is [1, 7]. The same pinned artifact then passed on the GB300 with CUDA. The loader lesson was concrete: AutoModel follows model_type=qwen3 and rejects DSparkConfig, so the smoke loads the pinned classes directly.

This is still not target integration. I have not measured acceptance, and I have not connected the drafter to the vLLM server. The next DSpark work is a target-hidden-state contract and a matched acceptance test, not a routing trace.

2. The newer worker passes parity and loses time

I built an isolated FlashInfer 0.7.6 / B12x 1.5.1 environment. The first import failed on CUTLASS 4.5.2; the candidate needed CUTLASS 4.8.0 and several small dependencies. After that, the real bank run exposed another important fact: 0.7.6 does not include K3 SiTU in this wrapper. The old SiTU patch had to be ported.

With that patch, whole-expert parity passes. The candidate’s minimum cosine is 0.995648 and its k=4 sum cosine is 0.999923. But its graph p50 is slower at every tested shape: +15.6% at k=1, +12.4% at k=2, +14.4% at k=4, +10.5% at k=8, and +4.6% at k=16.

Diagram · swipe horizontally to inspect
The newer worker is correct—and slower on every measured whole-expert shapeSame two-layer RTX bank, same inputs, same independent reference. Lower is better. The newer worker is correct—and slower on every measured whole-expert shape Same two-layer RTX bank, same inputs, same independent reference. Lower is better. Whole-expert p50 · candidate slowdown vs patched 0.7.0.post1 graph=True · k=1 +15.6% graph=True · k=2 +12.4% graph=True · k=4 +14.4% graph=True · k=8 +10.5% graph=True · k=16 +4.6% Parity: control min cosine 0.994442 · candidate 0.995648 · k=4 sum 0.999923 Verdict: correct, not a speed upgrade. The old worker stays the control. SiTU still needs a patch in 0.7.6.

That is a clean negative result. The patched 0.7.0.post1 worker remains the speed control. The candidate is useful for its true-extent and guard behavior, but it does not earn a promotion.

3. Slicing: two layout bugs, then an exact weight result

The first slice builder treated the whole record as if every byte divided by eight. It does not: the 24-byte global-scale block is duplicated per slice. A real slice record is 2,322,456 bytes, not 2,322,435.

The second bug was more interesting. Gate/up scales can be sliced by rows because their scale-column count stays unchanged. Down-projection scales cannot: their swizzle depends on the number of scale columns. The correct path is exact inverse swizzle → slice the linear scales → forward swizzle at the sliced geometry. I replaced the ambiguous NumPy permutation with explicit builder-index loops and added roundtrip tests.

After that, every dequantized slice matches the corresponding whole-expert columns. The minimum weight cosine is 0.99999988, with zero maximum absolute difference in the tested records. That is the right kind of gate: it proves the layout before asking a kernel to explain a bad result.

Diagram · swipe horizontally to inspect
Slicing now passes the partition canaryExact weights → backend/activation diagnosis → corrected direct-micro SiTU. Full-pod timing is still unmeasured. Slicing now passes the partition canary Exact weights → backend/activation diagnosis → corrected direct-micro SiTU. Full-pod timing is still unmeasured. 1 · Weights All 8 slices dequantize to the exact whole columns min cosine 0.99999988 24-byte scales duplicated Down scales re-swizzled 2 · Diagnosis pre-fix cosine 0.9893–0.9928 situ == silu: true Direct micro was unpatched Forced MMA restored SiTU Not BF16 rounding 3 · Corrected cosine 0.999977–0.999980 Direct SiTU patch Norm ratio ≈ 1.000 repeat_exact = true Canary passes The actual blocker was activation dispatch The direct micro kernel fell through to SiLU. Adding the exact K3 SiTU formula fixed the partition.

4. The partition sum now passes

The first corrected-layout run still failed at 0.9893–0.9927 cosine. Fable 5.2’s review predicted that the small-I calls were taking the direct micro kernel, whose activation fell through to SiLU. The diagnostic confirmed it: situ and silu outputs were bit-identical, and the partition matched the SiLU reference at about 0.9965.

Adding the exact K3 formula—4·tanh(g/4)·sigmoid(g) × 25·tanh(u/25)—to the direct micro path fixed it. The identity-checked v3 banks now reach 0.999977–0.999980 cosine against the whole expert, with norm ratios 0.99990–1.00018 and bit-exact repeats. The corrected slice benchmark’s minimum per-slice cosine is 0.995241 and its k=4 sum cosine is 0.999997.

FP32 partials are not required for this canary. BF16 partials with a fixed-order FP32 sum are sufficient here; the earlier rounding hypothesis was ruled out by the magnitude of the error. RTX slice latency is about 308 µs at graph k=1, but that is not a Spark measurement and does not establish the full-pod win.

5. Determinism is still open

The whole-expert eager repeats show p50 relative differences around 0.8–1.9% in both workers. Fable’s source reading explains the shape: the MMA micro kernel performs timing-dependent BF16 atomic accumulation. The candidate reduces the tail, but does not make the whole path deterministic. Its capture guard also requires one wrapper per layer when the real scale=1 is used; reusing one wrapper across layers changes the folded-scale cache key.

Diagram · swipe horizontally to inspect
The determinism problem survives the worker upgradeSame-bank eager repeats. Graph capture has its own guard and warmup requirements; it does not make the math repeatable. The determinism problem survives the worker upgrade Same-bank eager repeats. Graph capture has its own guard and warmup requirements; it does not make the math repeatable. Eager-vs-eager relative difference · p50 · lower is better control candidate k=1 control 0.78% candidate 0.76% k=2 control 1.08% candidate 1.04% k=4 control 1.51% candidate 1.46% k=8 control 1.85% candidate 1.77% Both remain nondeterministic. Fixed-order reduction alone does not fix the kernel.

The direct-micro slice path is bit-repeatable in this canary, but the whole-expert determinism gate remains open. Fixed-order reduction alone does not fix the MMA kernel.

What happens next

  1. Spark pilot: when the Sparks are free, run the matched whole-expert control, then the corrected direct-SiTU sliced path with backend and memory assertions.
  2. Full-pod measurement: compare C1/C8 decode, prompt reading, and cold-load behavior against the existing vLLM server.
  3. DSpark target integration: capture the five target hidden states, measure acceptance against the target, and keep the vLLM server’s prefill and concurrency behavior intact.

The first window did not produce a faster pod. It produced a verified drafter, a rejected worker upgrade, an exact slicing layout, and a corrected partition path that is ready for a Spark pilot.