Recommendation: Changes Requested
The kernel changes in ignition/components/logprobs.py are mathematically sound, bit-exact, and address a real speculative-decoding preparation bottleneck (~15×–100× faster cold prepare() by collapsing per-width cubins and bounding _finish's bitonic sort block), backed by the repository's first direct unit and CUDA tests for these kernels. No correctness, ABI, or CUDA-graph capture defects were found. However, before merge, the runtime launch changes that apply across all vocabularies (_MERGE_WARPS 8→4 for every V, chunked serial sorts for V >= 16,385) need before/after latency coverage beyond the single V = 262,144 / width = 6 point (plus complete-replay/exported-core validation per docs/logprobs-design.md:129-130), the PR description should make the 8 → 4 warp transition explicit, and CPU CI needs to run on head 1337213.
Merge Risk
Level: Medium
- Shared hot-path launch change across all vocabularies:
PreparedLogprobsis the sole generation-logprob reduction component inignition/components/logprobs.py(used byPreparedSamplingand external speculative recipes). CappingBLOCKat512alters_finishfor every vocabulary>= 16,385(up to 9 serial sorts atV = 131,072and 17 atV = 262,144), and reducing_MERGE_WARPSfrom8to4alters_finishfor every vocabulary including<= 16,384. - ABI / compatibility / concurrency safety is preserved: Scratch shapes/dtypes (
stats,lse,keys),CompletionOutputslayouts,_merge, and CUDA-graph capture safety are unchanged; previously exported cores embed their own cubins and continue to load unaffected. - Unverified CI & target hardware matrix: Head
1337213currently has 0 CI checks run, and SM103/SM120/SM121 plus end-to-endignition export/flare runremain unmeasured.
Walkthrough
ignition/components/logprobs.py:59-121: ConvertedWIDTH: tl.constexprto a runtimewidthparameter with@triton.jit(do_not_specialize=["width"])across_statistics,_normalization,_candidates, and_finish, keeping parameter positions aligned withprepare()/functional()/run()and promoting row offsets to 64-bit (pos = row.to(tl.int64) * width + col).ignition/components/logprobs.py:21-26, 136-150, 164, 182-185: Bounded_finish's sort block at_MERGE_BLOCK = 512, reduced_MERGE_WARPSfrom8to4, and added a480-key chunked merge loop (step = BLOCK - CANDIDATES) whentotal = TILES * CANDIDATES > BLOCK, preserving the running top 32 packeduint64keys after each sort.tests/components/test_logprobs.py:1-279: Added a CPUmeta-device test checkingBLOCKbounds across vocabularies1..262,144and threeFLARE_RUN_CUDA_TESTS=1tests verifying single-cubin reuse across widths(1, 2, 6, 16), exact top-20 tie ordering across chunk boundaries (BF16/FP32,+0.0,-inf,< 20padding, inactive slots), requested token IDs, epoch/live-row gating, andfunctional(dynamic_inputs=True)CUDA graph capture/replay.
Pre-merge Checks
- [PASS] Security / malicious screen: Diff is confined to Triton logprob reduction kernels and pytest tests with no network, shell, credential, or untrusted-input surfaces.
- [WARN] Charter & value fit: Cleanly placed in one shared
ignition/components/module with no model branch, flag, or ABI break, addressing a measured compile-time problem; however, the Charter's served-workload benchmark / SM103-SM120-SM121 matrix check anddocs/logprobs-design.md:129-130's complete-replay measurement requirement are not yet met. - [PASS] Related / duplicate / conflict check: No competing or conflicting PRs touch
ignition/components/logprobs.py; complementary to merged #652 (cubin pruning on export). - [WARN] Tests & verification evidence: Strong new CUDA test suite reported passing (
87 passed) on Thor (SM110) and Orin Nano (SM87), but 0 GitHub CI checks have run on1337213and runtime latency is only measured at one point (V = 262,144,width = 6on Thor).
Blockers
None.
Should Fix
- Measure the unmeasured runtime regimes and document the full before/after launch change (
ignition/components/logprobs.py:23-26, 137-147, 164):- Verified behavior & impact: Two independent launch changes apply well beyond the single measured point (
V = 262,144,width = 6):_MERGE_WARPSchanged from8to4(ignition/components/logprobs.py:26vsmain:22), affecting every vocabulary—includingV <= 16,384whereBLOCKis unchanged—while the PR description only mentions4warps inside the512cap bullet without stating the8 → 4transition.merge_block = min(triton.next_power_of_2(tiles * _TILE_CANDIDATES), _MERGE_BLOCK)(ignition/components/logprobs.py:164) replaces a single1024..4096-key sort with2..9serial512-key sorts for everyV >= 16,385(e.g., 9 serial sorts atV = 131,072). None ofV <= 16,384,32k–128k, orwidth = 1are measured before/after, anddocs/logprobs-design.md:129-130specifies: "Performance claims about the reduction require complete replay and service measurements."
- Concrete fix:
- Add before/after CUDA-graph latency measurements (e.g. using the in-repo
scripts/benchmark_logprobs.pyharness atwidth in (1, 6)) covering representative small (<= 16,384), mid (~128k), and262,144vocabularies, plus a complete replay or exported-core check (docs/logprobs-design.md:129-130,docs/performance-work.md:45-51), or explicitly bound the runtime speedup claim to the measuredV = 262,144case while tracking unrun SM103/SM120/SM121 and exported-core checks indocs/TODO.txt(AGENTS.md:57-58). - Update the PR description's "What changed" section (
AGENTS.md:88-94) to explicitly note the_MERGE_WARPS8 → 4change (affecting all vocabularies) and clarify that_finishremains specialized per vocabulary viaTILES: tl.constexpr(collapsing only the width dimension). - Ensure CPU CI (
.github/workflows/python-cpu.yml(not opened)) runs and passes on the PR head before merge.
- Add before/after CUDA-graph latency measurements (e.g. using the in-repo
- Verified behavior & impact: Two independent launch changes apply well beyond the single measured point (
Subtract / Simplify
- Drop tautological module-level
assert(ignition/components/logprobs.py:24):assert _MERGE_BLOCK > _TILE_CANDIDATES and (_MERGE_BLOCK & (_MERGE_BLOCK - 1)) == 0checks two adjacent module literals (512and32), is the only top-levelassertinignition/, cannot fail at runtime, and is stripped underpython -O. Deleting line 24 leaves the concise comment at lines 21–22 intact.
Nits
- Empty
Discord:line in PR description: Populate the line with a Discord username orDiscord: no username providedperAGENTS.md:144-153anddocs/design-review.md:163-169. - Optional doc update (
docs/logprobs-design.md:92-100): The existing sentence ("Tiles retain their best 32 integer sort keys; a final merge stores K pairs and the chosen token") still holds at the contract level, but adding one sentence noting bounded chunked merging and width-agnostic launches would keep the preparation section current. - Avoid hardcoded tuple index in CPU test (
tests/components/test_logprobs.py:67): Selecting_finishfromop._preparationby kernel identity (next(args for kernel, args, *_ in op._preparation if kernel is _finish)) rather thanop._preparation[3][1]avoids brittle failure if the launch tuple order changes.
Dropped on verification
- Dropped
if total > BLOCK:"redundant guard" deletion (ignition/components/logprobs.py:141, Subtraction & Simplicity F4): False — deleting it breaksvocab <= 1024. Whenvocab <= 1024,tiles = 1,merge_block = 32 == _TILE_CANDIDATES, sostep: tl.constexpr = BLOCK - CANDIDATESevaluates to0, andrange(BLOCK, total, 0)raisesValueError: range() arg 3 must not be zero. Additionally, the Charter forbids proposing design changes to low-level GPU kernel code without a concrete defect. - Dropped "no CI-gating test can detect a merge regression" / CPU NumPy transcription suggestion (
tests/components/test_logprobs.py:71, Correctness & Contracts 4.2): Triton GPU kernels cannot run under CPU CI (CUDA_VISIBLE_DEVICES: ""in.github/workflows/python-cpu.yml:32(not opened)), soFLARE_RUN_CUDA_TESTS=1opt-in matches repo convention (tests/components/test_completion_outputs.py:18). A separate Python/NumPy transcription would test a copy rather than_finish, violatingAGENTS.md:194-196. - Dropped High/Major severity on
docs/logprobs-design.md:92-100and contrast withignition/components/vocabulary_logprobs.py(not opened) (Subtraction & Simplicity F1, Correctness & Contracts 3.1):docs/logprobs-design.md:94-95never specifies an 8,192-key single sort and remains factually true at the contract level;ignition/components/vocabulary_logprobs.py(not opened) does not exist in this repository at1337213. Downgraded to a Nit. - Dropped High severity on 8-row parametrization in
tests/components/test_logprobs.py:50-59and formula-only replacement (Subtraction & Simplicity F2, Correctness & Contracts 4.3): The parametrized cases cover real tile/cap boundaries (1024/1025,16384/16385,262144), and asserting on a standalonemin(next_power_of_2(...), _MERGE_BLOCK)expression would stop exercisingPreparedLogprobs.__init__. Kept only the[3]tuple-index cleanup as a Nit. - Dropped merging
_REDUCTION_WARPS/_MERGE_WARPSinto_WARPS(Subtraction & Simplicity F3a) and reverting_MERGE_WARPSto8(Correctness & Contracts 2.2): Distinct semantic constants for reduction vs. merge phases avoid churn (AGENTS.md:190), and proposing a warp-count revert without a concrete defect conflicts with the Charter's GPU-kernel review standard; measurement coverage is captured in Should Fix instead. - Dropped
#231"undeclared programs" / stale on-disk Triton cache concern (Discovery Dossier, Value Prop, Correctness & Contracts): Reading#231directly confirms its failure came from compiling a Triton kernel beforeignition.preparation.tuningconfigured the CUDA toolkitlibdevicepath, not fromdo_not_specializeor stale on-disk caches (Triton hashes kernel source and specialization metadata into its cache key). - Dropped claim that
int64row indexing is purely defensive with no possible overflow (Discovery Dossier): Inint32,(row * WIDTH + col) * Voverflows signed 32-bit atbatch * width >= 8,192forV = 262,144; promotingpostotl.int64matchesignition/components/engram.py:39and cleanly avoids that overflow boundary.