Skip to content

[wip] Ascend 020 - #278

Closed
cyber-pioneer wants to merge 7 commits into
flagos-ai:mainfrom
cyber-pioneer:ascend-020
Closed

[wip] Ascend 020#278
cyber-pioneer wants to merge 7 commits into
flagos-ai:mainfrom
cyber-pioneer:ascend-020

Conversation

@cyber-pioneer

Copy link
Copy Markdown
Collaborator

PR Category

PR Type

Description

Related Issues

Changes

Testing

Checklist

  • I have run the existing tests and they pass
  • I have added tests for my changes (if applicable)
  • I have updated the documentation (if applicable)

Copilot AI review requested due to automatic review settings July 9, 2026 11:52
@github-actions github-actions Bot added the core label Jul 9, 2026
# 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

Copilot AI left a comment

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.

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 thread vllm_fl/worker/worker.py
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 thread vllm_fl/worker/worker.py
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
Copilot AI review requested due to automatic review settings July 9, 2026 14:35

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 3 out of 11 changed files in this pull request and generated 1 comment.

Comment thread vllm_fl/worker/worker.py
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants