Repository navigation
fix(cuda): guard exhausted candidates in TopK stage 2 - #2104
Conversation
Skip the invalidation store when a reduction returns NOT_FOUND. Add regression coverage for exhausted rows, masked values, and multiple k values. Validation: 12 TopK tests passed on Windows CUDA. AI-assisted analysis, implementation, and test execution.
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved blocking issues were identified.
Review effort: Lite
Findings: None
What changed in this PR
Fixes CUDA TopK stage 2 handling for exhausted candidates and adds regression coverage.
Changes:
- Skip invalidation stores when reduction returns
NOT_FOUND. - Add tests for masked values, repeated calls, row positions, data types, and multiple
kvalues.
| File | Description |
|---|---|
tests/ops_test.cc |
Adds comprehensive TopK regression coverage. |
src/ops/topk_gpu.cu |
Prevents invalid memory writes for exhausted reductions. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Could you also run the new regression test under CUDA Compute Sanitizer, ideally before and after the fix? The invalid write may not reliably cause an output mismatch, so this would help confirm the regression is caught. |
Thanks, agreed — the output assertions alone may miss the invalid write. I also ran the regression under Compute Sanitizer The before-fix build contains the new regression test on Environment: Windows x64, RTX 4070 SUPER, CUDA 12.8.93, Compute Sanitizer 2025.1.0.0; Release build with
All runs used This confirms that memcheck catches the regression without relying on an output mismatch. after-memcheck-async.txt |
|
please let me know if anything else is needed from my side. |
|
Thanks, great job! |
Skip the invalidation store when a reduction returns NOT_FOUND. Add regression coverage for exhausted rows, masked values, and multiple k values.
Validation: 12 TopK tests passed on Windows CUDA.
AI-assisted analysis, implementation, and test execution.