perf(indexer): keep exact long-context top-k on the fast path - #77
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe tiled top-k kernel now selects coarse threshold buckets with a 10-bit radix histogram, expands shared-memory storage, and sends oversized threshold buckets directly to exact overflow fallback. Long-context regression cases move to larger sequence lengths. ChangesWide coarse top-k selection
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant TiledTopKKernel
participant SharedHistogram
participant CandidateBuffer
participant ExactOverflowFallback
TiledTopKKernel->>SharedHistogram: build and scan widened coarse histogram
SharedHistogram-->>TiledTopKKernel: return threshold_bin
TiledTopKKernel->>CandidateBuffer: collect threshold-bin candidates
CandidateBuffer-->>TiledTopKKernel: return bin_count
TiledTopKKernel->>ExactOverflowFallback: rescan when candidate count exceeds _SMEM_CANDS
ExactOverflowFallback-->>TiledTopKKernel: rebuild exact top-k outputs
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Why
#55 fixed silent top-k corruption when the threshold bucket exceeded the fixed candidate buffer. On GLM-5.2 long-context prefill, however, the 8-bit coarse bucket commonly exceeded 4,096 entries. That sent ordinary rows through four full exact rescans and reduced 64k prefill throughput.
SM120 already runs this 1,024-thread selector at one CTA per SM. The wider histogram uses all CTA lanes, and the larger candidate arrays keep the complete shared-memory allocation below the 99 KiB opt-in block limit without reducing occupancy. Truly degenerate rows still take the exact fallback.
Validation
ruff checkpassed on both changed files7 passedintest_paged_prefill_topk_long_context.pyon SM120Matched TP8/DCP1/MTP0 GLM-5.2 runs:
The last row uses
SPARKINFER_PAGED_INDEX_SUPERTILE_K=65536, which is deliberately not made a library-wide default in this PR. It measured 87.70 tok/s CC1 decode and reduced KV capacity by 2,816 tokens (0.51%) versus the default 32k supertile.Summary by CodeRabbit
Bug Fixes
Tests