Explore report · NVIDIA/hyperflare-inference #673

Raw Markdown for agents: https://autobot.eidonix.com/p/4d2522dd-7a56-424c-8412-835f177ae52a.md

PR #673 — Bound PreparedLogprobs merge block and share kernels across speculative widths

Author: kbenkhaled (CONTRIBUTOR) · Branch: logprobs-chunked-finish → main · Head: 1337213 · Size: +317 / −22 in 2 files (ignition/components/logprobs.py +39/−22, tests/components/test_logprobs.py +278/−0, new) · State: open, ready for review, no labels, no reviewers, 0 CI checks, 0 comments.

Key findings

  1. The launch configuration changes for every vocabulary, not just 262k ones. _MERGE_WARPS drops 8 → 4 (logprobs.py:26) and merge_block = min(next_pow2(tiles*32), 512) (logprobs.py:164), so a small vocabulary that used to launch _finish with 8 warps now runs 4. The description frames the change only as "capped at 512 (4 warps)".
  2. _finish still recompiles per vocabulary. The merge loop bounds are tl.constexpr (total: tl.constexpr = TILES * CANDIDATES, step: tl.constexpr = BLOCK - CANDIDATES, logprobs.py:137-147), so the loop is compile-time unrolled and at V=262,144 (256 tiles) still produces 16 extra unrolled sorts. Only width stops multiplying cubins — consistent with the "4 cubins instead of 24" claim, but the per-vocabulary compile cost is bounded, not removed.
  3. 64-bit indexing is new on all four kernels' hot address path (pos = row.to(tl.int64) * width + col, logprobs.py:66,83,101,121). It is defensive (no overflow at the shapes in play) and is not measured separately in the description.
  4. No documentation is updated. docs/logprobs-design.md:90-100 still describes "Tiles retain their best 32 integer sort keys; a final merge stores K pairs", i.e. the pre-PR single merge, and says nothing about width-agnostic kernels.
  5. All performance numbers are author-measured on two Jetsons, with nothing in CI. CI on head 1337213 is empty; the only Python workflow is CPU-only (CUDA_VISIBLE_DEVICES: ""), so the CUDA half of the new test file can never gate this.
  6. No issue or report requested this work. The motivation exists only in the PR body and in the author's broader Jetson small-memory campaign (#671, #669, #664).
  7. The change overlaps a documented measurement standard it does not meet. docs/logprobs-design.md:128-130 requires "complete replay and service measurements" for reduction performance claims; the PR reports isolated _finish µs and cold prepare() wall-clock, and lists end-to-end ignition export/flare run as unmeasured. Charter line 42 asks for the SM103/SM120/SM121 matrix and a check that exported cores still load — both are explicitly unrun.
  8. Process nits: PR body's Discord: line is empty, which AGENTS.md:144-153 forbids (same nit was raised on the author's #671); no triage:review label and no Autobot case-file comment, unlike comparable performance PRs (#231, #652, #671).

The change

Two mechanisms, both in ignition/components/logprobs.py:

Sizes and reach inside the file: _sort_key (:29-33), _sort_pair (:36-40), _position (:43-56), _merge (:248-261) and the rest of PreparedLogprobs are untouched. The scratch layout (stats, lse, keys, logprobs.py:167-173) and the constructor signature are unchanged, so scratch bytes and ABI are identical; only the _finish BLOCK/num_warps launch config and the four kernels' specialization keys change.

Wiring: PreparedLogprobs is constructed only from PreparedSampling.prepare() (ignition/components/sampling.py:539, with _logprob_args built at sampling.py:524); prepare/functional/run are used at sampling.py:540,607,635,679. CompletionOutputs constants (ignition/components/completion.py:15-23: MAX_TOP_LOGPROBS=20, MAX_LOGPROB_TOKEN_IDS=128, LOGPROB_FIELDS=258) are not changed. The module is one of the 13 retained core modules (tests/preparation/test_core_boundary.py:11-25).

Widths 1..6 come from outside the repo. PreparedSampling.__init__ requires 2-D logits (sampling.py:484-489) and PreparedLogprobs reshapes 2-D to logits[:, None, :] (logprobs.py:156-157), so every in-repo path is width == 1. Multi-width is exercised by scripts/benchmark_logprobs.py:19,33,67-69 (sweeps width 1 and 6 with 3-D logits) and by recipe-side construction in the external local-inference-lab/hyperflare-recipes package. PreparedSampling.prepare() compiles logprobs first (sampling.py:537-561), before _scores, _complete, _metadata, _sanitize, _normalize, _min_p and the FlashInfer workspaces — which is why its compile time sits at the front of a cold catalog build.

Under-declared behaviour difference: the requested-IDs branch (count > 0, logprobs.py:127-134) and the sorted branch (count == 0, :135-150) are gated exactly as before; only pos is now int64. Grid shapes and the [batch,width,tiles,32] uint64 Keys buffer are unchanged.

The why

No issue or report asks for this. Searches for logprob compile time, Triton specialization and slow preparation return no originating report; the problem is documented only by the author's own measurements (Orin Nano 8 GiB ~19.5 min for six _finish specializations; Thor cold prepare 65.40 s).

Why the problem is nonetheless real and structural: ignition/components/capacity.py:80-91 (not opened),160-169 builds speculative shapes/widths and ignition/direct/scheduler.py:207-209 (not opened) derives widths from every speculative graph signature, so a prepared core naturally multiplies per-width kernel variants — exactly what this PR collapses.

Prior art on the same invariant and the same symptom:

Recent activity

People

Community

Zero engagement. read_item(673) shows "Discussion (0)"; pr_comments returns no comments; opened and last updated at 2026-12-02 04:42 (one push, no follow-ups). No labels, whereas sibling #671 carries area:memory, area:preparation, enhancement, performance, triage:review. No Autobot case-file comment appears on #673, unlike #231, #652 and #671 — triage has not engaged. Comparable performance PRs in this repo all show an Autobot case-file + review thread, so the silence here reads as age rather than objection.

Project fit

Claims and evidence

Claim Evidence in PR Independent / reproducible?
Cold prepare() Thor SM110 65.40 s → 4.46 s (14.7×) author-measured, no artifacts No: needs a Jetson plus 3-D logits; scripts/benchmark_logprobs.py is the in-repo harness and is not cited
Cold prepare() Orin Nano 8 GiB SM87 ~19.5 min → 11.83 s (~100×) author-measured No
_finish 84.2 µs → 38.2 µs at width 6, V=262,144 author-measured No; the PR also states Orin Nano's old BLOCK=8192 runtime latency was not measured
"4 logprob cubins instead of 24" new CUDA test asserts all four kernels' compiled.hash match across widths (1,2,6,16) Partly: ignition/preparation/triton.py:28-51 exposes .compiled, but no export was run
"bit-for-bit identical output" new CUDA tests compare to a torch reference (_reference_logprobs, stable descending argsort) over vocab 1..262,144, BF16 and FP32, plus +0.0/-inf/<20 padding and requested-ID/NaN cases Yes in principle, but only with FLARE_RUN_CUDA_TESTS=1 on a GPU; the author's raw-int32 equality vs 1fbcc3c9 and bit-exact compile_forward() at widths 1 and 4 are not reproducible from the PR contents
"87 passed, 0 failed" on Thor and Orin Nano none in CI No: 0 checks on head 1337213; no GPU workflow exists in the repo

compile_forward / wrap_triton (ignition/preparation/triton.py, as in #648) is what makes the shared cubin serve the compiled path the description says it verified.

Reach

Process

Open questions / not found