idxsknorm_shuffle_layout support shuffle kv cache layout#3795
Open
ganyi1996ppo wants to merge 1 commit into
Open
idxsknorm_shuffle_layout support shuffle kv cache layout#3795ganyi1996ppo wants to merge 1 commit into
ganyi1996ppo wants to merge 1 commit into
Conversation
Signed-off-by: ganyi <ygan@amd.com>
Contributor
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
|
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for a SHUFFLE (“asm_layout”) KV-cache layout in the fused_qknorm_idxrqknorm ROCm op by switching the op API to accept separate K/V cache tensors and introducing an asm_layout flag to select addressing logic, along with test coverage for the new layout (including fp8 variants).
Changes:
- Updated the fused kernel + C++/pybind API to take
kv_cache_kandkv_cache_vseparately and addedasm_layoutto enable SHUFFLE (page-16) cache addressing. - Extended the Python wrapper to pass the new arguments through and added new asm_layout test modes.
- Added test-side reference validation for SHUFFLE caches using
reshape_and_cache(asm_layout=True)as ground truth.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
op_tests/test_fused_qknorm_idxrqknorm.py |
Adds SHUFFLE cache allocation + reference comparisons; adds asm_layout parameterized cases. |
csrc/kernels/fused_qknorm_idxrqknorm.cu |
Implements SHUFFLE K/V cache addressing and updates kernel launcher/API to use separate K/V caches + asm_layout. |
csrc/include/rocm_ops.hpp |
Updates pybind signatures/args for the new cache parameters and asm_layout. |
csrc/include/fused_qknorm_idxrqknorm.h |
Updates public C++ header signatures to kv_cache_k/kv_cache_v and adds asm_layout. |
aiter/ops/fused_qknorm_idxrqknorm.py |
Updates Python entrypoint signatures to kv_cache_k/kv_cache_v and forwards asm_layout. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| py::arg("k_scale"), \ | ||
| py::arg("v_scale")) | ||
| py::arg("v_scale"), \ | ||
| py::arg("asm_layout") = false) |
Comment on lines
+102
to
111
| # The main K/V caches are always passed as separate kv_cache_k / kv_cache_v | ||
| # tensors. asm_layout selects the in-cache addressing: page-16 SHUFFLE | ||
| # (asm_layout=True) vs plain page-128 (asm_layout=False, where kv_cache_k / | ||
| # kv_cache_v are typically the key/value slices of a fused | ||
| # [num_blocks, 2, block_size, num_kv_heads, head_dim] cache). | ||
| if ( | ||
| kv_cache is not None | ||
| kv_cache_k is not None | ||
| and isinstance(kv_cache_dtype, str) | ||
| and kv_cache_dtype.startswith("fp8") | ||
| ): |
1 task
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.
Motivation
Technical Details
Test Plan
Test Result
Submission Checklist