Skip to content

[AMD] Remove ROCm page_first+kernel -> layer_first HiCache fallback (follow-up to #28534) - #30622

Merged
HaiShaw merged 3 commits into
sgl-project:mainfrom
AMD-yanfeiwang:rocm/remove-28473-rocm-layer-first-fallback
Jul 15, 2026
Merged

[AMD] Remove ROCm page_first+kernel -> layer_first HiCache fallback (follow-up to #28534)#30622
HaiShaw merged 3 commits into
sgl-project:mainfrom
AMD-yanfeiwang:rocm/remove-28473-rocm-layer-first-fallback

Conversation

@AMD-yanfeiwang

@AMD-yanfeiwang AMD-yanfeiwang commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Motivation

#28534 enabled the JIT staged HiCache write-back path on ROCm:

  • can_use_jit / can_use_write_back_jit are now allowed on HIP (not only CUDA) in the MHA/MLA host pools;
  • hicache.cuh / staged_write_back.cuh build and run with hipcc (PTX-only helpers guarded by USE_ROCM, ROCm device-type matchers, vectorized non-temporal load/store).

As called out in #28534's description, once that landed, the ROCm layer_first fallback added by #28473 in ServerArgs._resolve_layout_io_compatibility() should be reverted.

What this PR does

Removes the ROCm-only block that rewrites page_first + kernel to layer_first:

# The page_first kernel write-back relies on the CUDA-only JIT staged
# kernel. On ROCm it falls back to a kernel that requires CUDA index
# tensors and crashes on host write-back, so use layer_first there.
if (
    self.hicache_mem_layout == "page_first"
    and self.hicache_io_backend == "kernel"
    and is_hip()
):
    self.hicache_mem_layout = "layer_first"
    logger.warning(...)

Why it must be removed (not just cleanup)

The block runs at ServerArgs resolution time, i.e. before the host KV pool is created. On ROCm it forces any page_first + kernel request to layer_first, so ROCm can never reach the page_first + kernel JIT staged write-back path that #28534 just made correct. The two are directly contradictory: #28534 says "ROCm can use the JIT staged write-back", while this fallback says "ROCm always downgrades to layer_first". Leaving it in makes #28534's ROCm work dead code.

After this change, ROCm exercises the same page_first + kernel write-back path as CUDA (platform parity, retained staged write-back bandwidth), which is what #28534 validated on MI355X (gfx950, ROCm 7.2).

Test plan

  • is_hip import still used elsewhere in server_args.py (no dead import); file byte-compiles.
  • HiCache JIT unit tests (test/registered/jit/test_hicache.py, test_hicache_page_first_write_back.py) pass on MI355X (ROCm 7.2) with the page_first + kernel JIT staged write-back path enabled (validated for [AMD] Enable JIT staged HiCache write-back and fix CPU-index crash #28534).
  • CI: AMD jit-kernel-unit + HiCache serving suites.
  • Optional: end-to-end --enable-hierarchical-cache --hicache-mem-layout page_first --hicache-io-backend kernel launch on ROCm no longer silently downgrades to layer_first.

CI States

Latest PR Test (Base): ❌ Run #29231811696
Latest PR Test (Extra): ❌ Run #29231811508

sgl-project#28534 enabled the JIT staged HiCache write-back path on ROCm: can_use_jit /
can_use_write_back_jit are now allowed on HIP, and hicache.cuh /
staged_write_back.cuh build and run with hipcc. The ROCm layer_first fallback
added by sgl-project#28473 in ServerArgs._resolve_layout_io_compatibility() is therefore no
longer needed and is now actively harmful -- it rewrites page_first + kernel to
layer_first on ROCm before the host pool is created, so ROCm can never reach the
now-correct page_first + kernel JIT staged write-back path that sgl-project#28534 added.

Remove the fallback so ROCm exercises the same page_first + kernel write-back
path as CUDA.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request removes the ROCm-specific fallback logic in _resolve_layout_io_compatibility that reverted the memory layout from page_first to layer_first when using the kernel IO backend. I have no feedback to provide as there are no review comments.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@yctseng0211 yctseng0211 self-assigned this Jul 9, 2026

@yctseng0211 yctseng0211 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

passed all related tests on AMD, LGTM

image image image

@HaiShaw

HaiShaw commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

/tag-and-rerun-ci

@HaiShaw

HaiShaw commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

AMD only change

@HaiShaw
HaiShaw merged commit a3194d3 into sgl-project:main Jul 15, 2026
122 of 161 checks passed
roopaksrivastav pushed a commit to roopaksrivastav/sglang that referenced this pull request Jul 16, 2026
Chronostasys pushed a commit to MindLab-Research/sglang that referenced this pull request Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants