Repository navigation
[AMD] Enable staged HiCache write-back for DeepSeek V4 - #35043
Open
AMD-yanfeiwang wants to merge 3 commits into
Open
AMD-yanfeiwang wants to merge 3 commits into
AMD-yanfeiwang wants to merge 3 commits into
Conversation
AMD-yanfeiwang
marked this pull request as ready for review
August 17, 2026 01:56
AMD-yanfeiwang
requested review from
Ying1123,
alphabetc1,
hanming-lu,
hnyls2002,
huangtingwei9988,
hzh0425,
ispobock,
merrymercy,
xiezhq-hermann and
yizhang2077
as code owners
August 17, 2026 01:56
AMD-yanfeiwang
force-pushed
the
amd/rocm-dsv4-hicache-staged-writeback
branch
from
August 18, 2026 12:47
0749aac to
61cc587
Compare
AMD-yanfeiwang
requested review from
BBuf,
DarkSharpness,
FlamingoPg,
HaiShaw,
HydraQYH,
celve and
yuan-luo
as code owners
August 18, 2026 12:47
AMD-yanfeiwang
force-pushed
the
amd/rocm-dsv4-hicache-staged-writeback
branch
from
August 18, 2026 12:49
61cc587 to
0749aac
Compare
This was referenced Aug 18, 2026
7 of 8 tasks
This was referenced Sep 30, 2026
This branch has not been deployed
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
DeepSeek-V4 hybrid HiCache uses specialized paged, compress-state, and DSA indexer host pools. Their staged page-first write-back remained gated to native CUDA even though the shared JIT kernel supports HIP. Simply opening that gate is not sufficient on ROCm: on MI355X with ROCm 7.2.26015, mmap-backed memory registered with HIP has a device alias different from its CPU
data_ptr(), so the existing PF-to-LF GPU load kernel faults while dereferencing the CPU virtual address.Modifications
DeepSeekV4PagedHostPool,DeepSeekV4StateHostPool, andDSAIndexerPoolHost.kernel + page_firstnow fails at startup if any pool lacks staged JIT write-back, andkernel + layer_firstis rejected because its GPU kernel dereferences host CPU virtual addresses. The existing runtime checks remain as defense in depth.Scope and index routing
This PR supports the DeepSeek-V4
kernel + page_firsthost pools listed above; it is not an allocator-wide fix for every kernel that can dereference registered mmap storage. Generic MLA/MHA page-first loads and ROCm kernel layer-first transfers require separate safe paths; the latter is rejected at startup by this PR.HybridCacheControlleralready routes write-back indices per pool throughsupports_per_pool_backup_indices: pools with staged JIT keep CPU host indices as required bystaged_write_back.cuh, while non-staged pools move their indices to the GPU. This PR marks the three DeepSeek-V4 pools as staged-capable and completes that existing contract; it does not replace the controller with a new group-wide routing rule.Accuracy Tests
MI355X, ROCm 7.2.26015:
0x71c149b50000..0x71c149b58000;hipHostGetDevicePointer()returned0x717fd0020000;hipPointerGetAttributes()reported the CPU host pointer and the distinct device pointer.0x71c149b53000, inside that CPU range, confirming that the GPU kernel dereferenced the CPU VA rather than the registered device alias.Real DeepSeek-V4-Pro TP8 service smokes (
kernel/page_first, 32K L1, HiCache ratio 2):write_throughoperator-path smoke: every completed insertion eagerly backed up the prefix, deliberately forcing staged D2H without depending on eviction victim selection. Five distinct 8K prefixes filled/evicted L1; replaying the first returnedcached_tokens_details={device: 0, host: 7936}. The initial and host-tier replay output token were both 65.write_backpolicy smoke on PR head1dea66d: after three cold fills, a seed-0 replay returnedcached_tokens_details={device: 7936, host: 0}, proving the prefix remained device-only before eviction. Two additional cold fills exceeded L1; replaying seed 1 returnedcached_tokens_details={device: 0, host: 7936}, proving eviction-triggered backup and load-back. The initial and host-tier replay output token were both 65.Speed Tests and Profiling
Direct-A / staged candidate / Direct-B on one idle MI355X, C4-style rows, 8 layers, 1/4/16/64 pages, 40 repetitions per shape:
Additional 61-layer scale check on the same MI355X, C4-style rows, 1/4/16/64 pages, 10 repetitions per shape:
Checklist
CI States
Latest PR Test (Base): ❌ Run #32138879425
Latest PR Test (Extra): ❌ Run #32138879088