[wip] Ascend 020 - #278
Closed
cyber-pioneer wants to merge 7 commits into
Closed
Conversation
| # vllm/model_executor/layers/mamba/gdn_linear_attn.py (fused_gdn_gating) | ||
| # vllm/model_executor/layers/fla/ops/l2norm.py | ||
|
|
||
| import math |
| import math | ||
|
|
||
| import torch | ||
| import torch.nn.functional as F |
| top_k = topk_ids.shape[1] | ||
|
|
||
| if global_num_experts == -1: | ||
| global_num_experts = E |
| # Patch the plugin's own FLA chunk module | ||
| try: | ||
| from vllm_fl.dispatch.backends.vendor.ascend.impl.fla import chunk as _ascend_chunk | ||
| _ascend_chunk.chunk_gated_delta_rule_fwd = chunk_gated_delta_rule_fwd_proper |
| Combines gating computation + recurrent delta rule in one function. | ||
| This is used for the DECODE path (T=1 typically). | ||
| """ | ||
| B, T, H, K_dim = q.shape |
|
|
||
| # 5. Patch l2norm_fwd | ||
| import vllm.model_executor.layers.fla.ops.chunk as _chunk_lib | ||
| import vllm.model_executor.layers.fla.ops.l2norm as _l2norm_lib |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR is focused on improving Ascend NPU (020) compatibility/stability in the vLLM-FL worker and Ascend vendor backend by avoiding known-crashing Triton/torch.compile paths and introducing safer fallbacks (pure-PyTorch / vendor ops) for attention, GDN/FLA, and MoE.
Changes:
- Add Ascend-specific runtime patches and configuration overrides to avoid Triton/Inductor/CUDAGraph failure modes.
- Change worker initialization + KV-cache memory sizing/warmup behavior to avoid NPU-forward-pass crashes.
- Add/route Ascend vendor MoE and GDN/FLA implementations (including new pure-torch kernels) and adjust operator/backend registration.
Reviewed changes
Copilot reviewed 4 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| vllm_fl/worker/worker.py | Adds NPU init patching and skips/changes memory profiling + warmup logic for Ascend stability. |
| vllm_fl/worker/model_runner.py | Skips KV cache re-striding on NPU to preserve contiguity expectations. |
| vllm_fl/platform.py | Forces NPU-specific config overrides (disable compile/cudagraphs; force float32 SSM cache). |
| vllm_fl/dispatch/config/ascend.yaml | Adjusts Ascend op backend priority + expands FlagOS blacklist for correctness/stability. |
| vllm_fl/dispatch/backends/vendor/ascend/register_ops.py | Registers additional Ascend vendor op implementations. |
| vllm_fl/dispatch/backends/vendor/ascend/patch.py | Adds extensive monkeypatching to replace/disable unstable Triton paths on NPU. |
| vllm_fl/dispatch/backends/vendor/ascend/impl/mm_encoder_attention.py | Switches MM encoder attention to pure PyTorch SDPA to avoid NPU flash-attn issues. |
| vllm_fl/dispatch/backends/vendor/ascend/impl/fused_moe.py | Introduces grouped-matmul MoE attempt with fallback to torch.mm loop. |
| vllm_fl/dispatch/backends/vendor/ascend/impl/fused_moe_kernel.py | New: pure-torch MoE alignment + GEMM loop implementation. |
| vllm_fl/dispatch/backends/vendor/ascend/impl/fla/gdn_torch_ops.py | New: pure-torch replacements for several GDN Triton kernels. |
| vllm_fl/dispatch/backends/vendor/ascend/impl/attention.py | Registers Ascend attention backend as CUSTOM + constrains supported block sizes; fixes some KV view handling. |
| vllm_fl/dispatch/backends/vendor/ascend/ascend.py | Adds Ascend backend implementations for MoE-related ops and topk_softmax. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+499
to
+503
| free_mem = current_platform.torch_device_fn.mem_get_info( | ||
| self.device | ||
| ) | ||
| free_bytes = free_mem[0] | ||
| total_bytes = free_mem[1] |
Comment on lines
+507
to
+521
| model_used = total_bytes - free_bytes | ||
| util = self.cache_config.gpu_memory_utilization | ||
| budget = int(util * total_bytes) - model_used | ||
| # Reserve 50% of the budget for activations and the one-time | ||
| # contiguous copy of non-contiguous kv_cache views. | ||
| # The kv_cache is allocated as [2, N, B, H, D] and split into | ||
| # key/value views that are non-contiguous. The first forward | ||
| # call creates contiguous copies that coexist temporarily with | ||
| # the original non-contiguous views. | ||
| activation_reserve = int(budget * 0.5) | ||
| self.available_kv_cache_memory_bytes = max( | ||
| budget - activation_reserve, 0 | ||
| ) | ||
| self.non_torch_memory = 0 | ||
| self.peak_activation_memory = activation_reserve |
Comment on lines
+508
to
+521
| util = self.cache_config.gpu_memory_utilization | ||
| budget = int(util * total_bytes) - model_used | ||
| # Reserve 50% of the budget for activations and the one-time | ||
| # contiguous copy of non-contiguous kv_cache views. | ||
| # The kv_cache is allocated as [2, N, B, H, D] and split into | ||
| # key/value views that are non-contiguous. The first forward | ||
| # call creates contiguous copies that coexist temporarily with | ||
| # the original non-contiguous views. | ||
| activation_reserve = int(budget * 0.5) | ||
| self.available_kv_cache_memory_bytes = max( | ||
| budget - activation_reserve, 0 | ||
| ) | ||
| self.non_torch_memory = 0 | ||
| self.peak_activation_memory = activation_reserve |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Category
PR Type
Description
Related Issues
Changes
Testing
Checklist