Skip to content

Rm sort for decode gdr - #4656

Closed
IzacharyI wants to merge 1 commit into
ROCm:Qwen3.5_devfrom
IzacharyI:rm_sort_for_decode_gdr
Closed

IzacharyI wants to merge 1 commit into
ROCm:Qwen3.5_devfrom
IzacharyI:rm_sort_for_decode_gdr

Conversation

@IzacharyI

Copy link
Copy Markdown
Contributor

Motivation

Remove the host-side GDN index sorting path, which is unsafe with CUDA Graph padding and replay when the cached permutation no longer matches the active indices.

Technical Details

  • Remove host-side argsort and index_select.
  • Remove the sorted-index cache and reset API.
  • Remove HIP_GDN_SORT_IDX_BS.
  • Remove batch_perm and sorted HIP kernel dispatch.
  • Always launch HIP GDN decode with the original state indices.

Test Plan

  • Rebuild the HIP GDN extension.
  • Compare HIP output and recurrent state against Triton.
  • Test CUDA Graph replay at batches 192, 256, and 512 while changing state indices before replay.

Test Result

  • B192 replay passed.
  • B256 replay passed.
  • B512 replay passed.
  • Output and recurrent state matched Triton.
  • SGLang GDN regression suite: 48 passed, 1 skipped.

Submission Checklist

Always use direct state indices to avoid CUDA Graph padding mismatches and remove obsolete sort cache and permutation plumbing.

Copilot AI 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.

Pull request overview

This PR removes the host-side (and associated kernel-side) sorted-index decode path for HIP GDN, motivated by correctness/safety issues when CUDA Graph padding/replay can cause a cached permutation to no longer match the active indices. The resulting implementation always launches decode using the original (unsorted) state indices and eliminates the sorted-index cache/reset API.

Changes:

  • Removed the Python/API surface for invalidating the sorted-index cache (hip_gdn_decode_reset_sort_cache) and corresponding export.
  • Deleted the C++ extension’s host-side argsort/index_select flow, sorted-index cache, and HIP_GDN_SORT_IDX_BS threshold logic.
  • Simplified the HIP kernel interface by removing batch_perm plumbing and deleting sorted kernel variants/dispatch.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
aiter/ops/hip/gated_delta_net/hip_gdn_decode.py Removes documentation and Python wrapper for reset-sort-cache behavior.
aiter/ops/hip/gated_delta_net/gdn_decode_kernel_hip.hip Removes batch_perm parameter and sorted kernel variants; always uses original batch indexing.
aiter/ops/hip/gated_delta_net/gdn_decode_ext.cpp Removes host-side sorting/caching and updates launcher calls to pass original indices only.
aiter/ops/hip/gated_delta_net/init.py Stops exporting the removed reset-sort-cache API.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@zufayu
zufayu requested a review from valarLip August 11, 2026 01:26
@yiijin

yiijin commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Looks good. Please ensure this change is deployed together with the paired SGLang update, since the removed reset API is still referenced by older SGLang versions.

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

No activity for 15 days, so this is now labelled stale. A push or a comment clears it; keep-open exempts it.

@github-actions github-actions Bot added the stale The PR hasn't been updated in 2 weeks label Oct 7, 2026
@zufayu
zufayu requested review from junhaha666 and removed request for valarLip October 10, 2026 03:00
@github-actions github-actions Bot removed the stale The PR hasn't been updated in 2 weeks label Oct 11, 2026
@junhaha666 junhaha666 closed this Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants