[ROCm] Define the DSA head-gate graph helpers on HIP (#37118)

Co-authored-by: Zhang, Jiejing <jiejing.zhang@amd.com>
This commit is contained in:
xiaobochen-amd
2026-09-02 22:55:45 -07:00
committed by GitHub
co-authored by Zhang, Jiejing
parent 4b0edb25f2
commit 030d7e7e9b
3 changed files with 52 additions and 6 deletions
@@ -132,16 +132,19 @@ if TYPE_CHECKING:
DUAL_STREAM_TOKEN_THRESHOLD = 1024 if _is_cuda else 0
if _is_cuda or _is_hip:
# Plain-torch graph helpers: usable wherever the split-op surface is.
from sglang.srt.layers.attention.dsa.dsa_prefill_cuda_graph import (
logits_head_gate_graph,
scale_head_gate_graph,
)
if _is_cuda:
from sglang.kernels.ops.attention.dsv4 import fused_q_indexer_rope_first_quant
from sglang.kernels.ops.quantization.dsv32 import (
fused_k_indexer_norm_rope,
fused_k_indexer_norm_rope_store,
)
from sglang.srt.layers.attention.dsa.dsa_prefill_cuda_graph import (
logits_head_gate_graph,
scale_head_gate_graph,
)
@register_custom_op(mutates_args=["topk_indices"])
@register_split_op()
@@ -14,10 +14,11 @@ from sglang.srt.model_executor.runner_backend_utils.tc_piecewise_cuda_graph impo
get_tc_piecewise_forward_context,
is_in_tc_piecewise_cuda_graph,
)
from sglang.srt.utils import is_cuda
from sglang.srt.utils import is_cuda, is_hip
from sglang.srt.utils.custom_op import register_custom_op
_is_cuda = is_cuda()
_is_hip = is_hip()
GRAPH_WEIGHTS_PROJ_LORA_ERROR = (
"DSA indexer weights_proj LoRA is incompatible with "
@@ -31,7 +32,7 @@ def _is_in_piecewise_or_breakable_cuda_graph() -> bool:
return is_in_tc_piecewise_cuda_graph() or is_in_breakable_cuda_graph()
if _is_cuda:
if _is_cuda or _is_hip:
def _scale_head_gate_graph_fake_impl(
weights_raw: torch.Tensor,