Skip to content

Admit a burst back to back and argmax with torch (#14) - #24

Merged
gspark-etri merged 2 commits into
mainfrom
feat/14-admission
Oct 22, 2026
Merged

gspark-etri merged 2 commits into
mainfrom
feat/14-admission

Conversation

@gspark-etri

@gspark-etri gspark-etri commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Background

Phase 2 of #14 found that a burst of prompts reaches its first tokens slowly. With one stream decoding, every new prompt is staged: four of its 16 layer-group calls run per scheduler iteration, between ~40 ms decode steps. Sixteen prompts at once therefore waited 1.8–2.9 s for a first token, while furiosa-llm takes 155 ms at P=128. Separately, each 16-wide decode step spent 3.4–4.1 ms on the host widening 128256×16 logits to float32 numpy for argmax.

#18 and #23 are merged; this PR is rebased onto main.

Changes

  • serving/cluster.py, _ContinuousScheduler:
    • RNGD_ADMIT=block admits every waiting prompt back to back before the next decode step, with no staging. The default stays stage, so existing deployments do not change behaviour.
    • Admission now produces, writes and seats one stream at a time. A stream's first token leaves as soon as its own cache is in, and only one stream's cache is in flight instead of all of them. This applies to both policies.
  • engines/decode_batch.py: greedy_tokens() uses torch.argmax on the bf16 lm_head output. The bf16→float32 widening is exact and both functions return the first maximum, so the token is the same.
  • deploy/k8s/serve-sweep-job.yaml: the benchmark Job sets RNGD_ADMIT=block.
  • bench/vendor_sweep.py --greedy-together sends the greedy prompts all at once, to check batch invariance. serve_sweep_job.sh passes GREEDY_TOGETHER.
  • tests/test_admission.py: a burst is not staged, every stream finishes with its own tokens, and a burst member's first token goes out before the last prefill of the burst ends.

Verification

All runs: npu-node-1, 2026-10-22, a Job with one card, S=1024, B=16, decode group 8, prefill buckets 128/256/512, the phase-1 harness.

P conc TTFT ms (#23 → this) TPOT ms (#23 → this) tok/s (#23 → this) furiosa-llm TTFT / TPOT / tok/s
128 1 44.7 → 43.2 44.8 → 42.4 22.3 → 23.6 26.3 / 17.4 / 56.9
128 4 338 → 126 45.4 → 42.3 72.8 → 91.1 78.6 / 18.7 / 203.8
128 16 2030 → 361 48.5 → 47.2 150.9 → 305.9 155.4 / 21.7 / 651.4
512 4 502 → 220 44.5 → 43.1 70.5 → 87.0 178.9 / 19.3 / 180.6
512 16 2083 → 634 50.9 → 52.1 148.1 → 260.5 453.9 / 26.5 / 460.3

Raw data: bench/harness_rngd_pd_block_S1024.jsonl.

  • Greedy, sequential: bench/greedy_compare.py bench/greedy_rngd_pd_nodelay_S1024.jsonl bench/greedy_rngd_pd_block_S1024.jsonl → 14/14 identical token for token. That covers 12 varied prompts plus P=128/512, and includes the torch argmax change.
  • Greedy, all at once: rngd-pd → 14/14 identical to its sequential run (greedy_rngd_pd_together_S1024.jsonl), so its 16-wide decode is batch-invariant. For comparison, furiosa-llm changes 4 of its 13 continuations when the same prompts arrive together (greedy_furiosa_llm_together.jsonl, all late: characters 38–258).
  • Unit tests: PYTHONPATH=src python -m pytest -q tests/test_admission.py tests/test_solo_openai.py tests/test_continuous_backlog.py tests/test_devices.py → 20 passed.

Compatibility and limits

  • block trades the TPOT of streams that are already decoding for the burst's TTFT. Running streams pause for the burst's prefills, about 31 ms each at P=128. In this burst benchmark, TPOT p50 did not move. Under steady arrivals, stage may be preferable, which is why it stays the default.
  • TPOT is still ~2.3× furiosa-llm's (~42 ms vs ~17–22). That is the cost of the 16-wide decode graph itself (35–43 ms per step). It is the remaining gap and is discussed on Match furiosa-llm per card: TTFT, TPOT and throughput under concurrency (one harness, own techniques) #14: narrower graphs or a cheaper KV path change bf16 rounding.
  • CI: tests/test_admission.py is added to the NPU-free set. The tests check passed on the rebased branch (53 passed).

Related Issue

Part of #14 (phase 3, change 2).

🤖 Generated with Claude Code

gspark-etri and others added 2 commits October 22, 2026 21:00
RNGD_ADMIT=block admits every waiting prompt before the next decode step
instead of staging one prompt a few layer groups at a time between steps,
and the scheduler now seats each stream as soon as its own cache is in, so
its first token leaves while the rest of the burst is still prefilling.
16 prompts at once (P=128): TTFT p50 2030 -> 361 ms, tok/s 151 -> 306,
TPOT unchanged; greedy tokens identical.

The decode step's host argmax widened 128256 x B logits to float32 numpy
(3.4-4.1 ms per B=16 step); torch.argmax on the bf16 tensor returns the
same first maximum.

vendor_sweep.py --greedy-together sends the greedy prompts at once: rngd-pd's
16-wide decode is batch-invariant (14/14), furiosa-llm is not (4/13 of its
continuations change when batched).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gspark-etri
gspark-etri merged commit 3955ceb into main Oct 22, 2026
1 check passed
@gspark-etri
gspark-etri deleted the feat/14-admission branch October 22, 2026 12:01
gspark-etri added a commit that referenced this pull request Oct 22, 2026
## 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 |
  |---|--:|--:|
  | #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 #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](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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