[AMD] Support speculative decoding v2 for aiter backend on ROCm/HIP (#17450)
Co-authored-by: kkHuang-amd <wunhuang@amd.com> Co-authored-by: HaiShaw <hixiao@gmail.com>
This commit is contained in:
co-authored by
kkHuang-amd
HaiShaw
parent
acab24a76a
commit
67f02681c9
@@ -310,7 +310,7 @@ class EagleVerifyInputV2Mixin:
|
||||
accept_length = torch.empty((bs,), dtype=torch.int32, device=device)
|
||||
|
||||
# Sample tokens
|
||||
if sampling_info.is_all_greedy or _is_npu:
|
||||
if sampling_info.is_all_greedy or _is_npu or _is_hip:
|
||||
target_predict = torch.argmax(next_token_logits, dim=-1)
|
||||
target_predict = target_predict.reshape(bs, self.draft_token_num)
|
||||
predict, accept_index, accept_length = verify_tree_greedy_func(
|
||||
|
||||
@@ -59,6 +59,7 @@ from sglang.srt.utils.common import (
|
||||
fast_topk,
|
||||
get_available_gpu_memory,
|
||||
is_cuda,
|
||||
is_hip,
|
||||
is_npu,
|
||||
next_power_of_2,
|
||||
)
|
||||
@@ -66,6 +67,7 @@ from sglang.srt.utils.patch_torch import monkey_patch_torch_reductions
|
||||
|
||||
_is_npu = is_npu()
|
||||
_is_cuda = is_cuda()
|
||||
_is_hip = is_hip()
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -280,18 +282,27 @@ class EagleDraftWorker(BaseDraftWorker):
|
||||
"npu": EAGLEDraftExtendNpuGraphRunner,
|
||||
"cuda": EAGLEDraftExtendCudaGraphRunner,
|
||||
}
|
||||
supports_hip_aiter_draft_extend_graph = False
|
||||
if _is_hip:
|
||||
# Keep import local so non-HIP environments do not require aiter.
|
||||
from sglang.srt.layers.attention.aiter_backend import (
|
||||
AiterMultiStepDraftBackend,
|
||||
)
|
||||
|
||||
supports_hip_aiter_draft_extend_graph = isinstance(
|
||||
self.draft_attn_backend, AiterMultiStepDraftBackend
|
||||
)
|
||||
|
||||
supports_cuda_draft_extend_graph = _is_cuda and (
|
||||
isinstance(self.draft_attn_backend, TritonMultiStepDraftBackend)
|
||||
or isinstance(self.draft_attn_backend, TRTLLMMLAMultiStepDraftBackend)
|
||||
)
|
||||
# Capture extend
|
||||
# TODO: support draft extend cuda graph for more attention backends
|
||||
if self.draft_extend_attn_backend and (
|
||||
_is_npu
|
||||
or (
|
||||
_is_cuda
|
||||
and isinstance(self.draft_attn_backend, TritonMultiStepDraftBackend)
|
||||
)
|
||||
or (
|
||||
_is_cuda
|
||||
and isinstance(self.draft_attn_backend, TRTLLMMLAMultiStepDraftBackend)
|
||||
)
|
||||
or supports_cuda_draft_extend_graph
|
||||
or supports_hip_aiter_draft_extend_graph
|
||||
):
|
||||
tic = time.perf_counter()
|
||||
before_mem = get_available_gpu_memory(self.device, self.gpu_id)
|
||||
|
||||
Reference in New Issue
Block a user