fix(rocm): stabilize direct paged CK attention for bitwise R/R - #394
Merged
Conversation
inaniloquentee
requested review from
Flink-ddd,
KJLdefeated and
bitborne
as code owners
September 9, 2026 02:46
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
Signed-off-by: lamentropetion <3051000145@qq.com>
maxiaosong1124
self-requested a review
September 9, 2026 15:59
maxiaosong1124
approved these changes
Sep 9, 2026
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.
This follows merged #393 on
testand makes direct paged ROCm attention usable with a fixed arithmetic schedule for strict training/rollout agreement. AITER's shape-dependent M64/M128 dispatch produced different BF16 results between full prefill and decode; incomplete tail page tables also reproduced an HSA kernel fault. The opt-in RL-Kernel CK entrypoint fixes these cases while consuming the vLLM KV cache directly.Changes
RL_KERNEL_ROCM_FIXED_PAGED_TILE=128; tile 64 is also supported, while the default0retains the existing AITER entrypoint.fixed_paged_ck.hipso its ROCm/HIP implementation is explicit.The specialization currently supports BF16, head dimension 128, page size 16, and no dropout, softcap, bias, or sliding window. It requires installed
aiter_metaCK headers and the ROCm C++ toolchain. The extension must be warmed before HIP Graph capture.Changes are confined to RL-Kernel and its examples. CUDA implementations and installed Megatron, vLLM, Vime, and AITER sources are unchanged.
Validation
R/R validation run:
/app/model/vime-runs/pr394-nograd-gemm-reduction-rr-3round-v165The direct rollout path reported:
rl_kernel_fixed_paged_ck_m128dense_kv_materialized=falsemismatch_count=0max_abs_diff=0torch.equal=trueThe emitted comparison sidecars also passed exact comparison. This validates strict bitwise agreement for the tested workload and shapes; it is not a guarantee for every possible shape.
Full-native P/P vs strict R/R
The previous P/P number published in this PR was an attention-only ablation and was not a valid all-native baseline. The comparison below replaces it with a full-native P/P run under the same PR377 workload and framework-level training/rollout-consistency mode.
P/P:
/app/model/vime-runs/pr394-full-native-pp-vime-tis-3round-v167R/R:
/app/model/vime-runs/pr394-nograd-gemm-reduction-rr-3round-v165P/P uses native attention, FFN, and logp. R/R uses strict RL-Kernel attention, FFN, and logp.
Round 2 has exactly equal generated-token work. Relative to P/P, R/R is:
The difference is a real implementation-performance gap rather than a test bug. Trace-visible
copy_,to, anditemoperations account for only about 0.36–0.61 seconds and cannot explain the rollout delta.The primary R/R bottleneck is the strict deterministic GEMM/FFN implementation, followed by fixed-schedule attention. P/P uses
--use-rollout-logprobs, while R/R uses the strict linear-logp provider, so the logp measurements are not an identical internal path. This can explain part of the logp difference but not the rollout or actor-train gaps.The fixed-paged attention path already avoids dense KV materialization. Therefore, the remaining large rollout gap is mainly arithmetic and scheduling cost, not KV-cache communication or materialization.
Operator benchmarks
Identical-input HIP Graph microbenchmarks compared the R/R AITER dynamic dispatcher with fixed M128 using seven-group medians and 200 launches per group.
The candidate remains opt-in. It restores strict agreement and safe tail-page access and benefits the tested large-cache decode shapes, but it is not uniformly faster across all attention shapes.
Additional checks
Fixed M64 and M128 each passed 804 bit-pattern comparisons covering:
Backward finite-gradient and real-adapter padding probes also passed. These tests cover the reproduced HSA fault but do not claim to cover every possible HSA failure.
git diff --check, changed Python syntax checks, launcherbash -n, and the applicable ROCm deterministic-GEMM tests passed.Reproduction