Skip to content

[FEATURE] Support Ascend 910B NPU runtime and Wan2.2 T2V with public vllm-omni image - #42

Merged
lzx1413 merged 4 commits into
Tele-AI:mainfrom
yx0716:feat/npu-adapt
Nov 24, 2026
Merged

lzx1413 merged 4 commits into
Tele-AI:mainfrom
yx0716:feat/npu-adapt

Conversation

@yx0716

@yx0716 yx0716 commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Run Wan2.2-TI2V-5B text-to-video on Atlas 910B2 using TeleFuser's shared platform and operator interfaces. Container setup reuses the public multi-arch quay.io/ascend/vllm-omni:v0.34.0 (or vllm-ascend) image directly or layers TeleFuser in an isolated --system-site-packages venv via docker/Dockerfile.ascend.

Public vLLM-Omni NPU images · Dockerfile · Cross-device architecture · English guide · 中文手册

CUDA users who need Triton, torchao or bitsandbytes now install telefuser[cuda]. ROCm users need the Triton build paired with their PyTorch distribution.

Cross-Device Architecture: Shared Core & Hardware Switch Boundaries

Entrypoints, pipeline orchestration, stage state machines, diffusion schedulers, CPU offload, and DiT / VAE / T5 model definitions share 100% of their codebase across CUDA, ROCm, NPU, and CPU. Vendor differences are resolved once per process via current_platform (telefuser/platforms/__init__.py) and isolated into four explicit runtime boundaries:

flowchart TB
    subgraph Shared["100% Shared Device-Agnostic Core"]
        Entry["Entrypoints & Services (CLI / FastAPI / LiveKit / wan22_t2v_5b.py)"]
        Pipe["Pipeline & Stage Orchestration (BasePipeline / BaseStage / ModuleManager / Offload)"]
        Models["Model & Sampling Math (WanDiT / Wan22VideoVAE / T5 / UniPC)"]
        Entry --> Pipe --> Models
    end

    subgraph Platform["Platform Resolution Hub (telefuser/platforms/)"]
        Probe["Import-time probe _resolve_current_platform(): ROCm -> CUDA -> NPU -> CPU"]
        Validate["Pre-spawn check resolve_device(): verify visibility, index, and backend"]
        Probe --> Validate
    end

    Shared --> Platform

    Platform --> Sw1["Switch 1: Ops & Attention (telefuser/ops/)"]
    Platform --> Sw2["Switch 2: 3D Conv Layout (distributed/vae_spatial.py)"]
    Platform --> Sw3["Switch 3: Mesh, Collectives & Ports (distributed/ + platforms/hccl.py)"]
    Platform --> Sw4["Switch 4: Cross-Process Tensor Transport (worker/)"]

    Sw1 --> Cuda1["CUDA: forward_cuda + lazy Triton / tf-kernel / FlashAttn / FP8"]
    Sw1 --> Npu1["NPU: forward_npu -> forward_native + TORCH_SDPA (no Triton import)"]

    Sw2 --> Cuda2["CUDA / ROCm / CPU: channels_last_3d (NDHWC)"]
    Sw2 --> Npu2["NPU: contiguous_format (standard NCDHW)"]

    Sw3 --> Cuda3["CUDA / ROCm: NCCL / RCCL + MASTER_PORT"]
    Sw3 --> Npu3["NPU: pre-init set_device + HCCL + 16-port flock lease & recycle"]

    Sw4 --> Cuda4["CUDA: Direct device IPC + persistent CUDA IPC pool"]
    Sw4 --> Npu4["NPU: requires_host_tensor_queue -> CPU share_memory_() staging & sharding"]
Loading
Switch Boundary Unified Call Site CUDA / ROCm Path Ascend NPU Path
0. Platform Resolution current_platform, resolve_device() (telefuser/platforms/) Probes ROCm (torch.version.hip) then CUDA (CudaPlatform) Probes torch_npu + visible device (NPUPlatform); validates rank indices before worker spawn
1. Ops & Attention CustomOp, CustomOpFunction, attention registry (telefuser/ops/) Eager dispatches to forward_cuda / forward_rocm; FP8 & Sparse SageAttention load kernel/triton/* lazily on use Prefers forward_npu, otherwise falls back to forward_native + TORCH_SDPA with zero Triton dependency
2. VAE 3D Conv Layout conv3d_activation_layout() (distributed/vae_spatial.py, wan_video_vae.py) torch.channels_last_3d (NDHWC for cuDNN 3D convs); Wan22VideoVAE.decode accepts batched tensors directly torch.contiguous_format (NCDHW) to satisfy CANN contiguous memory rules
3. Collectives & Ports create_device_mesh_from_config, PipelineP2PComm, ParallelWorker Defaults to device_type="cuda", nccl backend, MASTER_PORT Defaults to device_type="npu", binds set_device pre-init, hccl backend + reserve_hccl_ports() 16-port flock lease recycled on close/failure
4. Worker Tensor Queues requires_host_tensor_queue() (parallel_worker.py, tensor_channel.py) False: direct device IPC queues and _CudaIpcPayload zero-copy pool True: bidirectional host staging via share_memory_() across ordinary queues and WorkerTensorChannel

Validation

  • CANN 9.3.0-beta.1, 910B2. Wan2.2-TI2V-5B took 157.07 s on one card and 92.05 s on two cards with CFG 2. The 121-frame 480p MP4s were pixel-for-pixel identical. Two-rank HCCL and host-staged tensor transfer also passed.
  • CANN 8.2, 910B2. 480p runs took 180.9, 120.8 and 87.0 s on one, two and four cards (CFG 2 × Ulysses 2); 720p took 477.8 and 173.9 s on one and four cards.
  • Local & CI checks. Passed Ruff lint/format, Ascend platform unit tests, Bash snippet checks, and full MkDocs bilingual site build. CI checks

@lzx1413

lzx1413 commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Please add the tutorial document on how to run with Ascend NPU.

@yx0716 yx0716 changed the title [FEATURE] Run Wan2.2 pipelines on Ascend NPU [FEATURE] Run Wan2.2 on Ascend 910B with a CANN 9.3 image Nov 20, 2026
@yx0716 yx0716 changed the title [FEATURE] Run Wan2.2 on Ascend 910B with a CANN 9.3 image [FEATURE] Run Wan2.2 on Ascend 910B with a CANN 9.3.0-beta.1 image Nov 20, 2026
@yx0716 yx0716 changed the title [FEATURE] Run Wan2.2 on Ascend 910B with a CANN 9.3.0-beta.1 image [FEATURE] Support Ascend 910B NPU runtime and Wan2.2 T2V with public vllm-omni image Nov 24, 2026
Move Triton, torchao, and bitsandbytes into the optional cuda extra so non-CUDA platforms install cleanly. Defer Triton kernel imports in FP8 QKV quantization and sparse SageAttention until execution while keeping pure-PyTorch smoothing and native helpers identical to main.
… host queues

Validate explicit accelerator devices before worker startup while letting unmounted NPU containers fall back cleanly to CpuPlatform. Default DeviceMesh and pipeline P2P receive buffers to current_platform, bind logical NPU ranks before HCCL init, reserve and recycle 16-port HCCL blocks via kernel file locks, and stage NPU tensors through host shared memory across worker queues and direct tensor channels.
…2 auto-device

Keep contiguous NCDHW Conv3d activations on Ascend NPU while preserving channels_last_3d elsewhere, accept already-batched tensors in Wan22VideoVAE parallel decode, and default the Wan2.2 5B T2V example to current_platform.device_type.
…architecture diagram

Layer docker/Dockerfile.ascend onto the public multi-arch quay.io/ascend/vllm-omni:v0.34.0 base image using an isolated --system-site-packages venv. Document container setup, device mapping, 1/2/4-card Wan2.2 T2V execution, hardware baselines, and the cross-device dispatch architecture in English and Chinese.
@lzx1413
lzx1413 merged commit c09c953 into Tele-AI:main Nov 24, 2026
8 checks passed
lzx1413 pushed a commit that referenced this pull request Nov 26, 2026
Eliminate major Ascend 910B2 bottlenecks under strict BF16 eager + SDPA +
model-level CPU offload parity (Wan2.2-TI2V-5B 864x480 121f 50-step UniPC):

- Keep scalar-timestep t_mod at seq_len=1 ([B, 1, 6, dim]) for broadcasting
  instead of expanding and materializing [B, seq_len, 6, dim] per block
- Add RMSNorm.forward_npu via torch_npu.npu_rms_norm
- Add apply_rotary_emb NPU path via torch_npu.npu_rotary_mul(interleave)
  and cache device RoPE cos/sin frequencies on WanModel
- Avoid redundant pure-BF16 torch.autocast('npu') upcasts in TI2V denoising
  and VAE decode stages, and avoid float64 NPU fallbacks in sinusoidal
  embeddings and UniPC linalg.solve
- Replace redundant einops.rearrange/double-reshapes with unflatten/flatten,
  use torch.addcmul in GateModule and in-place modulation on NPU
- Add persistent pinned CPU parameter mirror and NPU non_blocking transfers
  in BaseModel offload, plus device-side uint8 conversion before D2H in
  tensor2video

Measured on Atlas 910B2 64GB (matched vllm-ascend v0.23.0.post1 / CANN 9.1.0,
4 runs: 1 cold + 3 warm):
- TeleFuser baseline (PR #42): 147.06s warm median (0.82 fps, ~132s denoise)
- vLLM-Omni 0.23.0rc1:         106.95s warm median (1.13 fps, ~96s denoise)
- TeleFuser optimized:          98.90s warm median (1.22 fps, ~90s denoise)
  (1.49x faster than baseline; 8.05s / 7.5% faster than vLLM-Omni;
   middle-frame PSNR 31.39 dB / Pearson r 0.9939 vs baseline)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants