Explore scratchpad · NVIDIA/hyperflare-inference #673

Raw Markdown for agents: https://autobot.eidonix.com/p/5930f63e-c08f-4c3c-bff9-8fcd70e3c729.md

#1 [high] Change: what PR #673 does mechanically (logprobs.py)

PR #673 (kbenkhaled, head 1337213, base main, 2 files +317/-22).

File 1: ignition/components/logprobs.py (+39/-22)

File 2: tests/components/test_logprobs.py (new, +278) — whole file is new; previously there was no test file for logprobs.py at all (see separate note).

Verification: the difference in behaviour beyond the description — kernels _statistics, _candidates now use 64-bit pos in address computation (int64 arithmetic may be slightly slower but avoids overflow for large V*width); _finish also uses pos * V for the chosen/requested token loads, i.e. int64 there too. Note that total = TILES * CANDIDATES remains a tl.constexpr and the loop is unrolled at compile time (range(BLOCK, total, step) with constexpr bounds), so the number of iterations still depends on TILES (i.e., on vocabulary), not on width. So the cubin count reduction is width-only, while vocab still yields distinct _finish compilations (but now bounded block=512 instead of up to 8192).

#2 [high] Change: docs not updated — logprobs design doc still describes old merge

The PR touches exactly 2 files (ignition/components/logprobs.py, tests/components/test_logprobs.py) — no doc changes. The repo documents this mechanism in docs/logprobs-design.md:90-100 ("Preparation and scratch"): "Four prepared Triton launches reduce requested positions … Tiles retain their best 32 integer sort keys; a final merge stores K pairs and the chosen token." After the PR the final merge is chunked (512-element blocks, 480 new candidates per iteration) and kernels are width-agnostic; that section and docs/logprobs-design.md:128-130 ("A zero request flag bypasses vocabulary reads, sorting…") are unchanged. docs/api.md:38,107-122 (max_top_logprobs, tie ordering by decreasing logprob then increasing token ID) also unchanged and still accurate per the PR's bit-exactness claim. Charter/AGENTS.md:194-199 asks a PR to "describe its problem, resulting behavior, validation, and material limitations" — the description does; but AGENTS.md also treats "inaccurate documentation" as a contribution basis, and no doc is updated to reflect the new preparation/scratch shape. Reach note: docs/core-design.md:1276-1279 states "threshold ties must never be truncated to a fixed number of candidates" — this PR keeps 32 candidates across chunk boundaries rather than a fixed 32 overall, so that constraint is respected (merge carries the running top 32, not a per-chunk top 20); the PR description says so explicitly and the new CUDA test plants >32 ties straddling chunk boundaries.

#3 [high] Change: how logprobs.py is wired (callers, constants, ABI)

Wiring facts (verified by reading, ref pr/673):

#4 [high] Change: undeclared or under-declared behaviour differences

Things a reader should know beyond the headline (all read from pr/673 diff and current file):

  1. _MERGE_WARPS 8 -> 4 (logprobs.py:26) applies to every vocabulary, not only large ones; combined with merge_block = min(next_pow2(tiles*32), 512) (logprobs.py:164) a small vocabulary now runs _finish with BLOCK=32 and 4 warps (before: BLOCK up to next_pow2(tiles*32) with 8 warps). So the change alters launch config for small vocabularies too; the description frames it only as capping at 512/4 warps.
  2. 64-bit indexing (pos = row.to(tl.int64) * width + col, logprobs.py:66,83,101,121) applies to all four kernels and is defensive: for the shapes in play (batchwidthV ≈ 8.4M elements at V=262144, width=16, batch=2) int32 would not overflow; it does add int64 address arithmetic to every kernel. Not measured separately in the description.
  3. The merge loop is for offset in range(BLOCK, total, step) with total: tl.constexpr = TILES * CANDIDATES and step: tl.constexpr = BLOCK - CANDIDATES (logprobs.py:137-147), so it is compile-time unrolled and the iteration count still depends on the vocabulary (V=262144 -> 256 tiles -> 8192 candidates -> 16 extra sorts). Consequently per-vocabulary _finish compilations still exist; only width no longer multiplies them. The description's "4 logprob cubins instead of 24" is consistent with that (width-only multiplication).
  4. _statistics/_candidates/_finish grids and the Keys layout are unchanged, so the chunked merge reads the same [batch,width,tiles,32] uint64 keys buffer (logprobs.py:170).
  5. Nothing in the diff changes behaviour for the requested-IDs branch (count > 0) except that pos is int64; the sorted-top-20 branch is gated on count == 0 exactly as before.

#5 [high] Claims and evidence: what backs each performance and correctness claim

Claims in the description, and what is available to support them:

#6 [high] Tests: test_logprobs.py is brand new; no prior coverage existed; CI reach

#7 [high] Why: the problem, prior reports, and whether it was requested

Searches for an originating issue/report came up empty: search_items "logprobs", "Triton compile time specialization", "preparation slow compile minutes" return no issue about logprob kernel compile time (only #231, which states the underlying Triton rule). So the "problem" is documented only by the author's own measurements in the PR description (Orin Nano 8 GiB ~19.5 min for 6 _finish specializations; Thor cold prepare 65.40 s). Context that makes the problem real and recurring:

#12 [high] Project fit: charter, contribution rules, and design-review principles

#16 [high] Research summary

Case file prepared for PR #673 (kbenkhaled, logprobs-chunked-finish, head 1337213, +317/−22 in 2 files, open/ready-for-review, no comments, no labels, no CI checks).

All ten angles have scratchpad entries (15 notes, 8 high). Highlights a reader cannot get from the description: (1) _MERGE_WARPS drops 8→4 and merge_block collapses to 32 for small vocabularies, so launch configuration changes for every vocabulary, not just 262k ones; (2) the merge loop's bounds are tl.constexpr, so _finish still recompiles per vocabulary (16 unrolled extra sorts at 256 tiles) — only width stops multiplying cubins; (3) 64-bit pos indexing is now on all four kernels' hot address path; (4) no documentation is updated, though docs/logprobs-design.md:90-100 still describes the pre-PR single 32-key merge, and both that doc (:128-130, "performance claims require complete replay and service measurements") and docs/core-design.md:1276-1279 set standards the PR's isolated _finish/cold-prepare numbers don't meet; (5) in-repo callers pass 2-D logits (width==1) — widths 1..6 come from the external hyperflare_recipes package, so only scripts/benchmark_logprobs.py reproduces the multi-width case in this repo.

Also recorded: the new tests/components/test_logprobs.py is the first direct test coverage of these four kernels (CUDA half can never be CI-gated, since the only Python workflow runs CPU-only); no issue or report requested this work; no other PR has touched logprobs.py in 180 days and nothing on main conflicts; _merge, buffers and ABI are untouched so previously exported cores still load; the file's history is derek → lukealonso, making lukealonso the natural reviewer and derek the author of the merge semantics being changed; zero engagement so far (age, not objection); the PR body's Discord: line is empty, which AGENTS.md:144-153 forbids (same nit raised on the author's #671); and the untested SM103/SM120/SM121 matrix plus unrun end-to-end ignition export/flare run is exactly the gap charter line 42 and the logprob doc's measurement standard point at.

#8 [medium] Related work: nothing else touches logprobs.py; neighbours and supersession

#9 [medium] Recent activity: what changed lately around this file and these tests

From the orientation packet plus verification:

#10 [medium] People: author history and area owners

#11 [medium] Community: zero engagement; PR is a day-zero draft-quality submission marked ready

#13 [medium] Reach: who is affected, compatibility, dependencies

#14 [medium] Process: ready-for-review, no CI, no review, same-day submission; Discord line empty

#15 [medium] Reach: the multi-width case is exercised by external recipes, not in-repo callers

Where the width dimension actually comes from (affects how a reviewer can verify the headline claim):

#17 [medium] Related work: triage of every orientation-packet lead

The orientation packet listed 20 "possibly related items". Triage, so nobody re-walks them: Followed and useful (recorded elsewhere):

#18 [medium] Project fit: charter roadmap lines quoted and applied

Roadmap/charter wording relevant to how this PR should be judged (from read_charter, quoted as facts):