DSA indexer_top_k: fall back to scalar stores for odd top_k#407
Open
JackRao123 wants to merge 1 commit into
Open
DSA indexer_top_k: fall back to scalar stores for odd top_k#407JackRao123 wants to merge 1 commit into
JackRao123 wants to merge 1 commit into
Conversation
check_support() and the documented constraint permit any top_k in (0, 2048], but the output phase picked a width-2 vectorized store whenever top_k > num_threads_per_cta and asserted at JIT-compile time when top_k was odd. Cap the store vector width at 1 for odd top_k so those values compile; even-top_k codegen is unchanged. Fixes NVIDIA#406 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe indexer output phase now uses scalar stores for odd ChangesOdd top-k support
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before submitting
pre-commit runand committed any formatting changes.Affected area
FE OSS kernels or CuTeDSL
Summary
Cap the DSA indexer_top_k output-store vector width at 1 when
top_kis odd, so oddtop_kvalues JIT-compile instead of failingassert self.top_k % vecsize_out == 0. Addstop_k=705(odd, greater than threads-per-CTA) to the indexer_top_k test parametrization as a regression case.Why
Fixes #406.
check_support()and the documented constraint permit anytop_kin(0, 2048], but the output phase selectedvecsize_out = 2whenevertop_k > num_threads_per_cta, and the width-2 vectorized index/value store has no scalar tail — so oddtop_kabove that threshold asserted at compile time. Real workloads hit this when clampingtop_k = min(index_topk, visible_keys)on context-parallel shards (see the issue for the exact[235, 705]/top_k=705production case).Scalar stores (
vecsize_out == 1) are the path everytop_k <= num_threads_per_ctaconfig already takes; this change extends that path to oddtop_krather than adding a tail case to the vectorized writer. Only the output-phase store width changes — the selection phases and all even-top_kcodegen are untouched.Related issues
Fixes #406
API and compatibility impact
None for previously-working configs:
vecsize_outis unchanged for eventop_kand for oddtop_k <= num_threads_per_cta. Previously-asserting oddtop_kvalues now compile, using scalar output stores.Testing
black --line-length 160on both changed files.top_k=705parametrization exercises the previously-asserting configuration in bothtest_DSA_indexer_top_k_compile_executeandtest_DSA_indexer_top_k_wrapper(default shapes give 256–512 threads per CTA, so 705 previously resolvedvecsize_out = 2and failed the assert). Happy to iterate on CI results or run additional cases on a B200 and report back.Summary by CodeRabbit
Bug Fixes
Tests