Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docker/rocm.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -569,10 +569,13 @@ RUN pip uninstall -y aiter
# produced by a fresh `git clone` above, so there are no real user changes to
# preserve.
# cherry pick 8578af1 commit for v4 fp4 indexer kv-cache fix, may be removed in next aiter upgrade
# apply fix for v4 fp4 indexer, may be removed in next aiter upgrade
RUN git clone ${AITER_REPO} \
&& cd aiter \
&& git checkout -f ${AITER_COMMIT} \
&& git cherry-pick --no-commit 8578af153f4fa1e007fede7e3c1e1b373f07af4c \
&& sed -i 's/from functools import lru_cache/from functools import cache/' aiter/ops/flydsl/kernels/mqa_logits/pa_mqa_logits_fp4_prefill.py \
&& sed -i 's/@lru_cache(maxsize=32)/@cache/' aiter/ops/flydsl/kernels/mqa_logits/pa_mqa_logits_fp4_prefill.py \
&& git submodule update --init --recursive \
&& pip install -r requirements.txt \
&& if [ "${GPU_ARCH_LIST}" = "gfx1250" ]; then \
Expand Down
26 changes: 25 additions & 1 deletion python/sglang/kernels/ops/attention/dsv4/compress.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import TYPE_CHECKING, Literal, NamedTuple, Optional, Union
from typing import TYPE_CHECKING, Literal, NamedTuple, Optional, Union, cast

import torch

Expand Down Expand Up @@ -430,9 +430,33 @@ def compress_norm_rope_store(
page_size: int,
use_fp4: bool = False,
bf16_store: bool = False,
# HIP FP4 uses split scale storage and precomputed BF16 RoPE tables.
kvcache_scale: Optional[torch.Tensor] = None,
rope_cache: Optional[tuple[torch.Tensor, torch.Tensor]] = None,
fp4_k_write_metadata=None,
) -> None:
if use_fp4:
assert kv.shape[-1] == 128
if is_hip() and use_fp4:
from sglang.kernels.ops.attention.dsv4.fp4_indexer_hip import (
aiter_k_indexer_fp4_cache_write,
)

cos, sin = cast(tuple[torch.Tensor, torch.Tensor], rope_cache)
aiter_k_indexer_fp4_cache_write(
k=kv,
norm_weight=norm_weight,
norm_epsilon=norm_eps,
cos=cos,
sin=sin,
plan=plan,
out_loc=out_loc,
k_payload=kvcache,
k_scale=cast(torch.Tensor, kvcache_scale),
write_metadata=fp4_k_write_metadata,
)
return

freq_cis = torch.view_as_real(freq_cis).flatten(-2)
if _is_xpu:
compress_norm_rope_store_xpu(
Expand Down
Loading
Loading