Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion .github/vllm-main-verified.commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0351e9aa1fdf1a51329d1906881528dfe61fc88e
58d3918e3ea0a544ffedadad2ba84559e9c51d8f
13 changes: 9 additions & 4 deletions tests/e2e/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
# TODO: remove this part after the patch merged into vllm, if
# we not explicitly patch here, some of them might be effectiveless
# in pytest scenario
from vllm_ascend.utils import adapt_patch # noqa E402
from vllm_ascend.utils import adapt_patch, vllm_version_is # noqa E402

adapt_patch(True)
adapt_patch(False)
Expand Down Expand Up @@ -1937,9 +1937,14 @@ def qwen_prompt(questions: list[str]) -> list[str]:


def hunyuan_prompt(questions: list[str]) -> list[str]:
# vLLM's Hunyuan prompt update adds the image start/end tokens around
# this placeholder. Supplying the wrapper here would duplicate it.
placeholder = "<|hy_place▁holder▁no▁102|>" # noqa: E501
image_token = "<|hy_place▁holder▁no▁102|>"
if vllm_version_is("0.26.0"):
# v0.26.0 matches the bare image token and adds the boundaries in its
# prompt replacement. Supplying the wrapper would duplicate them.
placeholder = image_token
else:
# vLLM main PR #49691 matches the complete image placeholder.
placeholder = f"<|hy_place▁holder▁no▁100|>{image_token}<|hy_place▁holder▁no▁101|>"
return [f"<|hy_begin▁of▁sentence|>{placeholder}{question}<|hy_User|>" for question in questions]


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def test_extract_hidden_states(case: ExtractHiddenStatesCase, sampling_config):
model=case.model_name,
tensor_parallel_size=1,
enforce_eager=case.enforce_eager,
enable_chunked_prefill=False,
enable_chunked_prefill=True,
speculative_config={
"method": "extract_hidden_states",
"num_speculative_tokens": 1,
Expand Down
2 changes: 1 addition & 1 deletion tests/ut/models/minimax_m3/test_minimax_m3.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def test_moe_passes_swigluoai_config_during_construction(self) -> None:
return_value=gate,
),
patch(
"vllm_ascend.models.minimax_m3.minimax_m3.FusedMoE",
"vllm_ascend.models.minimax_m3.minimax_m3.FusedMoEFactory",
return_value=nn.Identity(),
) as fused_moe,
):
Expand Down
2 changes: 1 addition & 1 deletion tests/ut/models/test_deepseek_v4_moe.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def build_runner(**kwargs):
use_sequence_parallel_moe=False,
)

monkeypatch.setattr(deepseek_v4_module, "FusedMoE", fused_moe)
monkeypatch.setattr(deepseek_v4_module, "FusedMoEFactory", fused_moe)
monkeypatch.setattr(deepseek_v4_module, "ReplicatedLinear", lambda *args, **kwargs: gate)
monkeypatch.setattr(deepseek_v4_module, "get_ep_group", lambda: ep_group)
monkeypatch.setattr(deepseek_v4_module, "get_tensor_model_parallel_rank", lambda: 0)
Expand Down
34 changes: 24 additions & 10 deletions tests/ut/patch/platform/test_deepseek_v4_thinking.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from vllm.entrypoints.openai.chat_completion.protocol import ChatCompletionRequest
from vllm.tokenizers import deepseek_v4

from vllm_ascend.utils import vllm_version_is


class FakeTokenizer:
vocab_size = 1
Expand Down Expand Up @@ -61,16 +63,28 @@ def fake_encode_messages(messages, **kwargs):
monkeypatch.setattr(deepseek_v4, "encode_messages", fake_encode_messages)
tokenizer = deepseek_v4.get_deepseek_v4_tokenizer(FakeTokenizer())

cases = [
("none", "chat", None),
("minimal", "thinking", "high"),
("low", "thinking", "high"),
("medium", "thinking", "high"),
("high", "thinking", "high"),
("xhigh", "thinking", "max"),
("max", "thinking", "max"),
("unexpected", "thinking", "high"),
]
if vllm_version_is("0.26.0"):
cases = [
("none", "chat", None),
("minimal", "thinking", "high"),
("low", "thinking", "high"),
("medium", "thinking", "high"),
("high", "thinking", "high"),
("xhigh", "thinking", "max"),
("max", "thinking", "max"),
("unexpected", "thinking", "high"),
]
else:
cases = [
("none", "chat", None),
("minimal", "thinking", "low"),
("low", "thinking", "low"),
("medium", "thinking", "low"),
("high", "thinking", "high"),
("xhigh", "thinking", "high"),
("max", "thinking", "max"),
("unexpected", "thinking", "high"),
]
for reasoning_effort, expected_mode, expected_effort in cases:
tokenizer.apply_chat_template(
[{"role": "user", "content": "hi"}],
Expand Down
1 change: 0 additions & 1 deletion tests/ut/spec_decode/test_speculators_vwn_eagle3.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ def _mock_npu_env():
patch("vllm_ascend.ops.vocab_parallel_embedding.get_tp_group", return_value=_mock),
patch("vllm_ascend.utils.get_ascend_config", return_value=mock_cfg),
patch.object(torch.ops.vllm, "unquantized_gemm", F.linear),
patch.object(torch.ops.vllm, "maybe_calc_kv_scales", lambda *a, **kw: None),
patch.object(torch.ops.vllm, "maybe_pad_and_reduce", lambda x, *a, **kw: x),
patch("vllm.model_executor.layers.logits_processor.tensor_model_parallel_all_gather", lambda x, *a, **kw: x),
patch.object(torch_npu, "npu_rms_norm", side_effect=_cpu_rms_norm, create=True),
Expand Down
6 changes: 3 additions & 3 deletions vllm_ascend/models/deepseek_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
tensor_model_parallel_all_gather,
)
from vllm.model_executor.layers.activation import SiluAndMul, SiluAndMulWithClamp
from vllm.model_executor.layers.fused_moe import FusedMoE, fused_moe_make_expert_params_mapping
from vllm.model_executor.layers.fused_moe import FusedMoEFactory, fused_moe_make_expert_params_mapping
from vllm.model_executor.layers.layernorm import RMSNorm
from vllm.model_executor.layers.linear import (
ColumnParallelLinear,
Expand Down Expand Up @@ -433,7 +433,7 @@ def __init__(
self.gate.tid2eid = None
self.gate.e_score_correction_bias = nn.Parameter(torch.empty(config.n_routed_experts, dtype=torch.float32))

self.experts = FusedMoE(
self.experts = FusedMoEFactory(
shared_experts=self.shared_experts,
gate=self.gate,
num_experts=config.n_routed_experts,
Expand Down Expand Up @@ -475,7 +475,7 @@ def forward(
hidden_states = sequence_parallel_chunk(hidden_states)

if self.experts.is_internal_router:
# In this case, the gate/router runs inside the FusedMoE class
# In this case, the gate/router runs inside the FusedMoEFactory class
fused_moe_out = self.experts(
hidden_states=hidden_states,
router_logits=hidden_states,
Expand Down
6 changes: 0 additions & 6 deletions vllm_ascend/models/layer/attention/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import torch
import torch.nn as nn
import vllm.envs as envs
from vllm.config import CacheConfig, get_current_vllm_config
from vllm.config.vllm import VllmConfig
from vllm.model_executor.layers.attention.attention import _init_kv_cache_quant
Expand Down Expand Up @@ -150,11 +149,6 @@ def __init__(

self.use_sparse = True

# Initialize q/k/v range constants.
self.q_range = torch.tensor(envs.Q_SCALE_CONSTANT, dtype=torch.float32)
self.k_range = torch.tensor(envs.K_SCALE_CONSTANT, dtype=torch.float32)
self.v_range = torch.tensor(envs.V_SCALE_CONSTANT, dtype=torch.float32)

def forward(
self,
q: torch.Tensor,
Expand Down
4 changes: 2 additions & 2 deletions vllm_ascend/models/minimax_m3/minimax_m3.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
from vllm.model_executor.layers.attention import Attention
from vllm.model_executor.layers.attention_layer_base import AttentionLayerBase
from vllm.model_executor.layers.fused_moe import (
FusedMoE,
FusedMoEFactory,
GateLinear,
fused_moe_make_expert_params_mapping,
)
Expand Down Expand Up @@ -546,7 +546,7 @@ def __init__(
prefix=f"{prefix}.gate",
)

self.experts = FusedMoE(
self.experts = FusedMoEFactory(
shared_experts=self.shared_experts,
num_experts=config.num_local_experts,
top_k=config.num_experts_per_tok,
Expand Down
5 changes: 1 addition & 4 deletions vllm_ascend/ops/fused_moe/fused_moe.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
import torch.nn.functional as F
from vllm.distributed import get_dp_group, get_ep_group, get_tp_group
from vllm.model_executor.layers.fused_moe import FusedMoEConfig, FusedMoERouter
from vllm.model_executor.layers.fused_moe.layer import (
FusedMoE, # noqa: F401
MoERunner,
)
from vllm.model_executor.layers.fused_moe.layer import MoERunner

from vllm_ascend.ascend_forward_context import _EXTRA_CTX, MoECommType
from vllm_ascend.distributed.parallel_state import get_mc2_group
Expand Down
2 changes: 1 addition & 1 deletion vllm_ascend/ops/fused_moe/routed_experts.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def init_eplb(self, n_shared_experts):

eplb_config = get_ascend_config().eplb_config

# The upstream FusedMoE factory has already included redundant expert
# The upstream FusedMoEFactory factory has already included redundant expert
# slots in moe_config and allocated RoutedExperts weights accordingly.
# Ascend's placement builder operates on logical expert IDs, so give it
# a shallow config view with the logical count.
Expand Down
63 changes: 51 additions & 12 deletions vllm_ascend/ops/triton/mamba/postprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,29 @@ def postprocess_mamba_fused_kernel(
state_inner_sizes_ptr, # number of elements in inner dimensions
state_conv_widths_ptr, # conv width for conv states (0 for temporal)
state_group_indices_ptr, # maps state_idx to group index in block table
# DS conv row metadata. Zero keeps the single-region copy path.
state_dim_row_count_ptr, # int32: per-block dim row count for DS conv

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.

Please have the model owner confirm that the modifications are correct and there is no performance degradation.

state_dim_row_stride_ptr, # int64: bytes between rows for DS conv
# Output: num_accepted_tokens update (for src==dst case)
num_accepted_tokens_out_ptr,
# Optional: batch_idx -> req_idx mapping (V2 model runner / PP). The
# per-request decision arrays are in req-state-slot order; the block table
# is in batch order, so HAS_IDX_MAPPING splits the two indexings.
idx_mapping_ptr,
# Runtime parameter (varies per batch - NOT constexpr to avoid recompilation)
num_reqs,
# Compile-time constants (fixed after model initialization)
# block_size: determined by model config, constant for all invocations
block_size: tl.constexpr,
# COPY_BLOCK_SIZE: fixed tuning parameter for memory copy loop
COPY_BLOCK_SIZE: tl.constexpr,
CONV_STATE_DIM_FIRST: tl.constexpr,
# HAS_IDX_MAPPING: when True, program_id(0) is a batch index resolved to a
# req-state slot via idx_mapping_ptr (V2). When False, it is the req index.
HAS_IDX_MAPPING: tl.constexpr = False,

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.

[P1] Preserve the vLLM v0.26.0 output-buffer contract.

This Ascend kernel is installed for both main and v0.26.0, but their MRv2 callers have different output contracts. Main (after vLLM #50432) passes an accepted-token snapshot as input and a non-null output buffer. v0.26.0 passes None as num_accepted_tokens_out_ptr and expects the HAS_IDX_MAPPING path to update num_accepted_tokens_ptr in place. The unconditional store to num_accepted_tokens_out_ptr at line 176 therefore compiles/writes through None on the v0.26.0 lane.

Please either backport the #50432 host-side snapshot/output-buffer flow to the v0.26.0 compatibility patch, or select the write contract explicitly at host/version specialization time. Using one unconditional output-pointer store for both lanes is not compatible.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

ok

# PRECOMPUTED_NEW_COMPUTED: when True, num_computed_tokens_ptr already holds
# the post-step new_num_computed value (V2 supplies the advanced count).
PRECOMPUTED_NEW_COMPUTED: tl.constexpr = False,
):
"""
Fused GPU kernel for postprocess_mamba that computes decisions AND performs
Expand All @@ -48,9 +62,14 @@ def postprocess_mamba_fused_kernel(
because the kernel indexes directly into pre-flattened metadata arrays
using program_id(1). The grid dimensions encode the total state count.
"""
req_idx = tl.program_id(0)
batch_idx = tl.program_id(0)
state_idx = tl.program_id(1)

if HAS_IDX_MAPPING:
req_idx = tl.load(idx_mapping_ptr + batch_idx).to(tl.int32)

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.

[P1] Validate the batch index, not the mapped request slot, against num_reqs.

num_reqs is the number of active batch rows, whereas req_idx is a request-state slot and may be sparse/non-contiguous. For example, num_reqs=2 with idx_mapping=[5, 1] is valid, but the current req_idx >= num_reqs check drops slot 5 entirely. It also fails to reject the -1 skip sentinel and can read decision buffers at a negative offset. The control flow should be:

if batch_idx >= num_reqs:
    return
if HAS_IDX_MAPPING:
    req_idx = tl.load(idx_mapping_ptr + batch_idx)
    if req_idx < 0:
        return
else:
    req_idx = batch_idx

A positive request-slot bound would require the actual buffer capacity, not num_reqs.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

ok

else:
req_idx = batch_idx

# Bounds check
if req_idx >= num_reqs:
return
Expand All @@ -59,13 +78,21 @@ def postprocess_mamba_fused_kernel(
num_accepted = tl.load(num_accepted_tokens_ptr + req_idx)
src_block_idx = tl.load(mamba_state_idx_ptr + req_idx)
num_scheduled = tl.load(num_scheduled_tokens_ptr + req_idx)
num_computed = tl.load(num_computed_tokens_ptr + req_idx)
num_draft = tl.load(num_draft_tokens_ptr + req_idx)
if PRECOMPUTED_NEW_COMPUTED:

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.

[P1] Do not load num_scheduled_tokens_ptr on the precomputed path.

run_fused_postprocess_align() passes None for both num_scheduled_tokens_ptr and num_draft_tokens_ptr when PRECOMPUTED_NEW_COMPUTED=True, but line 80 performs tl.load(num_scheduled_tokens_ptr + req_idx) unconditionally before this branch. This can fail during Triton specialization/compilation by doing pointer arithmetic and a load through None; relying on dead-code elimination is unsafe. Move the num_scheduled, num_computed, and num_draft loads entirely into the else branch, matching upstream.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

ok

new_num_computed = tl.load(num_computed_tokens_ptr + req_idx)
else:
num_computed = tl.load(num_computed_tokens_ptr + req_idx)
num_draft = tl.load(num_draft_tokens_ptr + req_idx)
num_tokens_running_state = num_computed + num_scheduled - num_draft
new_num_computed = num_tokens_running_state + num_accepted - 1

num_tokens_running_state = num_computed + num_scheduled - num_draft
new_num_computed = num_tokens_running_state + num_accepted - 1
aligned_new_computed = (new_num_computed // block_size) * block_size

if not PRECOMPUTED_NEW_COMPUTED:
num_tokens_running_state = num_computed + num_scheduled - num_draft
else:
num_tokens_running_state = (new_num_computed // block_size) * block_size

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.

[P1] Restore the MRv2 running-state formula.

Under PRECOMPUTED_NEW_COMPUTED, this assigns num_tokens_running_state to the same aligned value as aligned_new_computed. Consequently, needs_copy is always true and accept_token_bias is always zero. For example, with block_size=16, new_num_computed=32, and num_accepted=3, the correct values are num_tokens_running_state=30 and accept_token_bias=2, while this code produces 32 and 0. The upstream contract is:

new_num_computed = tl.load(num_computed_tokens_ptr + req_idx)
num_tokens_running_state = new_num_computed - num_accepted + 1

Please use that formula; otherwise MRv2 align can skip required state shifts or copy at the wrong boundary.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

ok


needs_copy = aligned_new_computed >= num_tokens_running_state

if not needs_copy:
Expand All @@ -91,7 +118,9 @@ def postprocess_mamba_fused_kernel(
# block table). Reinterpret as int32* since block ids are int32.
group_base_addr = tl.load(block_table_ptrs_ptr + group_idx)
block_table_typed = group_base_addr.to(tl.pointer_type(tl.int32))
block_table_base = block_table_typed + req_idx * block_table_stride_req

bt_row_idx = batch_idx if HAS_IDX_MAPPING else req_idx
block_table_base = block_table_typed + bt_row_idx * block_table_stride_req

# Widen block ids to int64 before they reach `block_id * state_block_stride`
# below: state_block_stride can exceed 2**31 bytes for large mamba caches,
Expand All @@ -114,8 +143,16 @@ def postprocess_mamba_fused_kernel(
dst_addr = state_base_addr + dest_block_id * state_block_stride
# Number of elements to copy:
# (conv_width - accept_token_bias) * inner_size
num_elems_to_copy = (conv_width - accept_token_bias).to(tl.int64) * state_inner_size
copy_size = num_elems_to_copy * state_elem_size
if CONV_STATE_DIM_FIRST:
dim_row_count = tl.load(state_dim_row_count_ptr + state_idx)
dim_row_stride = tl.load(state_dim_row_stride_ptr + state_idx)
num_rows_to_copy = (conv_width - accept_token_bias).to(tl.int64)
copy_size = dim_row_count * dim_row_stride

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.

[P1] Fix the DS convolution row copy dimensions and advance the row address.

For DS layout (state[block, dim, state_len]), the kernel must iterate dim_row_count rows and copy (conv_width - accept_token_bias) * state_elem_size bytes per row, advancing source and destination by dim_row_stride for each row. This code swaps those quantities: it uses conv_width - bias as the loop count and dim_row_count * dim_row_stride as the per-loop copy size. The loop at lines 192-196 then never applies a row offset, so it repeats the same oversized copy.

For dim=4, state_len=3, fp16, and bias=1, this copies 24 bytes from source offset 2, reading 2 bytes past a 24-byte block, and repeats it twice. Please use num_loops = dim_row_count, copy_size = (conv_width - bias) * state_elem_size, and add row * dim_row_stride to both pointers while keeping the pointer-type cast hoisted.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

ok

num_loops = num_rows_to_copy
else:
num_elems_to_copy = (conv_width - accept_token_bias).to(tl.int64) * state_inner_size
copy_size = num_elems_to_copy * state_elem_size
num_loops = 1
else:
# Temporal state: copy
# state[block_table[req_idx, src_block_idx + accept_token_bias]]
Expand All @@ -129,6 +166,7 @@ def postprocess_mamba_fused_kernel(
# state_block_stride which is the page stride and can exceed the
# actual data when the state tensor uses as_strided page padding.
copy_size = state_inner_size * state_elem_size
num_loops = 1

# Mirror postprocess_mamba's trailing
# if src_block_idx == dest_block_idx: num_accepted_tokens_cpu[i] = 1
Expand All @@ -151,7 +189,8 @@ def postprocess_mamba_fused_kernel(
src_ptr = src_addr.to(tl.pointer_type(tl.uint8))
dst_ptr = dst_addr.to(tl.pointer_type(tl.uint8))
offsets = tl.arange(0, COPY_BLOCK_SIZE)
for i in range(0, copy_size, COPY_BLOCK_SIZE):
mask = (i + offsets) < copy_size
data = tl.load(src_ptr + i + offsets, mask=mask)
tl.store(dst_ptr + i + offsets, data, mask=mask)
for _ in range(num_loops):
for i in range(0, copy_size, COPY_BLOCK_SIZE):
mask = (i + offsets) < copy_size
data = tl.load(src_ptr + i + offsets, mask=mask)
tl.store(dst_ptr + i + offsets, data, mask=mask)
33 changes: 27 additions & 6 deletions vllm_ascend/patch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,15 @@
#
# ** 6. File: platform/patch_fused_moe.py**
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 1. `vllm.model_executor.layers.fused_moe.FusedMoE`
# 1. `vllm.model_executor.layers.fused_moe.FusedMoEFactory`
# Why:
# vllm's FusedMoE is a factory function (not a class). deepseek_v2 and
# other models do `from vllm.model_executor.layers.fused_moe import FusedMoE`
# vllm's MoE factory function (formerly FusedMoE, now FusedMoEFactory on main).
# deepseek_v2 and other models do
# `from vllm.model_executor.layers.fused_moe import FusedMoEFactory`
# and call it directly, so on Ascend we must redirect it to AscendMoERunner
# before any model is imported.
# How:
# Patch the FusedMoE binding in both the package `__init__` and the layer
# Patch the FusedMoEFactory binding in both the package `__init__` and the layer
# module so model imports pick up the Ascend runner. `worker/patch_fused_moe.py`
# reuses this platform patch to avoid double-wrapping the factory during
# worker initialization.
Expand Down Expand Up @@ -741,9 +742,9 @@
#
# ** 8. File: worker/patch_fused_moe.py**
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 1. `vllm.model_executor.layers.fused_moe.FusedMoE`
# 1. `vllm.model_executor.layers.fused_moe.FusedMoEFactory`
# Why:
# The worker process re-imports the FusedMoE factory after the platform
# The worker process re-imports the MoE factory after the platform
# patch has already redirected it to AscendMoERunner. Re-applying the
# monkey-patch directly would wrap an already-patched factory.
# How:
Expand Down Expand Up @@ -1254,3 +1255,23 @@
# Future Plan:
# Remove this patch when NPU support UVA.
#
# ** 34. File: platform/patch_vision.py**
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 1. `vllm.model_executor.models.vision.FusedInputNorm.forward`
# Why:
# Upstream vLLM uses PyTorch 2.13.0, which requires eps > 0 for training
# but allows eps >= 0 for inference. vllm-ascend bundles PyTorch 2.10.0,
# which does not distinguish scenarios and requires eps > 0 in all cases.
# So when upstream FusedInputNorm passes eps=0.0 to F.batch_norm it works
# fine upstream, but fails on vllm-ascend with "batch_norm eps must be
# positive".
# How:
# Monkey-patch FusedInputNorm.forward to use eps=1e-5 instead of 0.0.
# The patch is guarded with contextlib.suppress(ImportError) so it does
# not crash on release wheels (v0.26.0) where FusedInputNorm does not exist.
# Related PR (if no, explain why):
# https://github.com/vllm-project/vllm/pull/50411
# Future Plan:
# Remove this patch once vllm-ascend's bundled PyTorch >= 2.13.0
# (which, like upstream, allows eps >= 0 for inference).
#
1 change: 1 addition & 0 deletions vllm_ascend/patch/platform/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@
import vllm_ascend.patch.platform.patch_eplb # noqa
import vllm_ascend.patch.platform.patch_fused_moe # noqa
import vllm_ascend.patch.platform.patch_dp_device_ids # noqa
import vllm_ascend.patch.platform.patch_vision # noqa
Loading
Loading