Skip to content

Gates for decode-graph changes; opt-in decode width tiers (#14) - #26

Merged
gspark-etri merged 1 commit into
mainfrom
feat/14-tiers
Oct 22, 2026
Merged

gspark-etri merged 1 commit into
mainfrom
feat/14-tiers

Conversation

@gspark-etri

Copy link
Copy Markdown
Contributor

Background

After #23 and #24, the remaining #14 gap is TPOT. The 16-wide decode step costs 35–43 ms against furiosa-llm's 17–22 ms. Every lever on it changes bf16 rounding, so the token gate was relaxed (coordinator decision on #14). A rounding-changing change is accepted only if:

  1. Free-running: every continuation on the fixed prompt set equals one furiosa-llm produces (sequential or batched) or rngd-pd's 16-wide baseline, and agreement with furiosa-llm does not drop below the baseline.
  2. Teacher-forced: on the same token sequences, top-1 agreement is ≥ 99 % against the 16-wide path; mean |Δlogit| and top-k KL are reported; and no step has the new top-1 below half the old top-1's probability under the old model.
  3. Perplexity (optional): within ±0.5 % on a fixed text.

This PR adds the tools for those gates, and decode width tiers as an opt-in lever, with every measurement. It also records the KV-rewrite and tactic-hint levers that reached hard limits.

Changes

  • bench/teacher_forced.py: gate 2 and gate 3. Variants are WIDTH[:HINT] engines that share the reference engine's weights.
  • bench/token_gate.py: gate 1.
  • bench/ppl_text.txt: ~1,800 words of original prose. A first try with famous public-domain texts gave perplexity 1.06, because the model has memorised them.
  • engines/decode_batch.py:
    • BatchDecodeEngine(share=, hint=) reuses another engine's 16 GB of projections and the lm_head, and takes a per-engine tactic hint. step_logits() returns the logits.
    • The graph specs no longer pass allow_external/unlowered_operators on SDK ≥ 2026.3 (removed there), and the engine uses dev_str(). The default path's keys and behaviour are unchanged.
  • engines/tiers.py, TieredDecode: one engine per width on shared weights. Each step runs at the narrowest width covering the live lanes, and live lanes are copied on the card when the width changes.
    • serving/cluster.py builds it from RNGD_DECODE_TIERS (e.g. 4,8) and RNGD_TIER_HINTS (e.g. 4:Default).
    • The scheduler tells it the live lanes. It is off by default.
  • bench/tier_numerics.py (bit-exactness across widths), bench/kv_append_probe.py (eager in-place KV writes).
  • tests/test_decode_tiers.py: tokens are identical to one wide engine across width changes; added to CI.

Verification

All runs: npu-node-1, 2026-10-22, a Job with one card, S=1024, decode group 8, furiosa-torch 2026.2.0. The reference is the 16-wide ForLlmModelDecode graph.

Gates per candidate. Gate 2 runs on the 14 reference continuations (819 steps); perplexity runs on 1,716 tokens of ppl_text.txt. Data: teacher_forced_tiers_S1024.json, teacher_forced_hint_default_S1024.json, greedy_rngd_pd_{tiers,t4def,t8}_S1024.jsonl.

candidate gate 1 (free-running) top-1 agree guard violations mean / max |Δlogit| KL top-20 mean / max top-1 on ppl text ppl Δ engine step
width 4 FAIL (#2, #10, #11 new; agreement 6/12 vs 9/12) 99.27 % 0 0.034 / 0.375 3.1e-4 / 9.7e-3 98.72 % −0.125 % 21.5 ms
width 4, Default hint FAIL (#2, #11; 8/12) 99.39 % 0 0.035 / 0.375 3.0e-4 / 7.8e-3 – – –
width 8 PASS (10/12) 99.63 % 0 0.031 / 0.375 3.0e-4 / 1.1e-2 98.31 % −0.086 % ≈ 16-wide
width 16, Default hint – 99.51 % 0 – – 98.30 % −0.009 % 57.2 ms (slower)
  • Width 4 is the only one that is fast (TPOT 25 ms vs 42 ms for ≤ 4 in flight), and it fails gate 1. Its graph is not bit-exact with the 16-wide one: hidden-state max |Δ| 0.5, argmax flipped on 1 of 24 steps (tier_numerics.py). The flipped continuation diverges for the rest of the 64 tokens.

  • Width 8 passes all gates, but its step costs about the same as 16. With tiers {8, 16} the sweep is flat or worse (harness_rngd_pd_t8_S1024.jsonl):

    TPOT, conc 1 tok/s, conc 16
    Admit a burst back to back and argmax with torch (#14) #24 42.4 ms 306
    tiers {8, 16} 38.5 ms 244

    So tiers stay off by default.

  • On the high-entropy natural text, top-1 agreement is 98.3–98.7 % for every variant, against 99.3–99.6 % on the reference continuations. Guard violations were 0 everywhere and perplexity moved ≤ 0.13 %.

  • Default path unchanged: with RNGD_DECODE_TIERS unset, greedy is 14/14 identical to Admit a burst back to back and argmax with torch (#14) #24's run on this branch's final code.

  • Tests: CI set + tests/test_decode_tiers.py → 54 passed, 1 skipped locally.

Compatibility and limits (the levers that did not pass)

  • Dropping the per-step KV rewrite is not reachable on this SDK. Compiled modules are functional, so the decode graph must return the S-wide cache it injected into. Outside the graph, kv_append_probe.py (B=16, S=1024, one group's K = 268 MB) measured:
    • per-lane slice writes: correct, but 3.97 ms per tensor, i.e. ~32 ms per step for K and V over 4 groups — worse than the ~5 ms the rewrite costs inside the graph at S=1024;
    • index_put_: 1,115 ms (it goes through the host).
  • Tactic hints for the 16-wide graph: Default is 1.5× slower (group call 10.4 vs 8.3 ms). ForMiscModel and NoConstraint did not finish tactic search in 2 h even at width 4.
  • furiosa-torch 2026.4: the 16-wide S=1024 decode graph hits memory explosion at layer group 8 and 4. Group 2 compiles, but cannot be stored: 2026.3+ has no EDF container for artifact_cache. On 2026.2, group 8 also fails at S ≥ 2048.
  • Where the time goes: the 16-wide graph streams the weights at ~485 GB/s, against ~890 GB/s at width 4. The remaining TPOT gap is the compiled matmul tactics at B=16 on this SDK, not host work or KV traffic.

Related Issue

Part of #14 (phase 3: decode tiers, KV rewrite, hints).

🤖 Generated with Claude Code

bench/teacher_forced.py feeds the same token sequences through the
16-wide decode graph and a candidate (another width or tactic hint, on
shared weights) and reports top-1 agreement, |delta logit| at the teacher
token, KL(old||new) on the top-k, the half-probability guard, and
perplexity on bench/ppl_text.txt (original prose, so not memorised).
bench/token_gate.py checks free-running continuations against the
reference engine's own runs.

BatchDecodeEngine can share another engine's weights and lm_head
(share=), take its own tactic hint (hint=), and return logits
(step_logits). TieredDecode (engines/tiers.py, RNGD_DECODE_TIERS,
RNGD_TIER_HINTS) steps at the narrowest width covering the live lanes;
it stays off by default: width 4 passes the teacher-forced gate but not
the free-running one, width 8 passes both but gains nothing.

Decode graph specs no longer pass the options 2026.3+ removed, and the
engine uses the SDK's device string, so the graphs can be built on newer
furiosa-torch. bench/kv_append_probe.py measures the eager in-place KV
writes a decode graph without the full-cache rewrite would need.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gspark-etri
gspark-etri merged commit a29633a into main Oct 22, 2026
1 check passed
@gspark-etri
gspark-etri deleted the feat/14-tiers branch October 22, 2026 13:46
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.

1 participant