DeepEP-Ascend: High-Performance Communication Library for Huawei Ascend NPUs

DeepEP-Ascend is a communication library for machine learning training and inference on Huawei Ascend NPUs. It provides expert-parallel (EP) all-to-all operations for Mixture-of-Experts (MoE) dispatch and combine, supporting FP8 dispatch and deferred epilogues. The library also offers primitives for pipeline parallelism (PP), context and data parallelism through Bucket collectives (CP/DP), and remote memory access through Engram.

Performance Benchmarks

EP sizeDispatch (GB/s)Combine (GB/s)
EP8373–375345–347
EP16348–352338–341
EP32335–340320–324
EP64323–327294–298
EP128313–320272–278

Sustained dispatch reaches roughly 90–95% of the physical payload bandwidth limit for EP sizes up to 32. Combination operations remain under optimization with additional local reduction overhead and HBM contention.

Technical Requirements

  • Linux on an Ascend host with supported NPU drivers and firmware
  • Ascend 950 (A5) with UBMEM connectivity and UBC_CTP/URMA channels
  • An even number of ranks for multi-rank communication
  • CANN with Ascend C, Bisheng compiler, HCCL and HCOMM headers/libraries
  • Python 3.10 or newer, matching PyTorch/torch_npu installation, NumPy
  • A C++20 compiler and standard library supporting std::format

Key Interfaces

  • EPBuffer: Expanded BF16/FP8 dispatch, BF16 combine, cached handles, deterministic layouts, expert padding and deferred epilogues
  • PPBuffer: Send/receive between adjacent pipeline ranks
  • EngramBuffer: NPU-backed BF16/FP8 tables and per-layer fetch hooks
  • BucketBuffer: Batched all-gather, registered storage, multiple groups and sessions
  • BufferAllocator, BufferBase, deep_ep.comm: Allocation planning, buffer lifecycle, communicator queries, barriers and stream access

Development Setup

  1. Activate the CANN environment and install matching PyTorch/torch_npu packages
  2. Clone the repository: git clone https://github.com/deepseek-ai/DeepEP-Ascend.git
  3. Fetch the DeepJIT submodule: git submodule update --init --recursive third-party/deep_jit
  4. Install: python -m pip install --no-build-isolation .

Usage Example

import torch
import torch.distributed as dist
import torch_npu
from deep_ep import EPBuffer

ep_group = dist.group.WORLD
max_tokens_per_rank = 4096
hidden = 7168
num_topk = 6
num_experts = 256

buffer = EPBuffer(
    ep_group,
    num_max_tokens_per_rank=max_tokens_per_rank,
    hidden=hidden,
    num_topk=num_topk,
    use_fp8_dispatch=False,
    explicitly_destroy=True,
)

Environment Variables

  • EP_AVOID_RECORD_STREAM: Required for Bucket all-gather
  • EP_BUFFER_DEBUG: Print EP buffer initialization diagnostics
  • EP_DISABLE_BARRIER_PROFILING: Disable extra per-iteration synchronization
  • DeepJIT settings: EP_JIT_CACHE_DIR, EP_JIT_DEBUG, EP_JIT_DUMP_ASM, EP_JIT_KERNEL_DEBUG_INFO, EP_JIT_LAUNCH_TIMEOUT, EP_JIT_PRINT_COMPILER_COMMAND, EP_JIT_PRINT_LOAD_TIME

Performance Reproduction

  1. Set required environment variables
  2. Run EP tests: python tests/ep/test_ep.py --num-processes 8 --num-ai-cores 32 --num-tokens 16384 --hidden 7168 --num-topk 6 --num-experts 256 --dispatch-dtype bf16 --test-first-only
  3. Run FP8 variant: python tests/ep/test_ep.py --dispatch-dtype fp8 --test-first-only
  4. Additional checks: buffer allocation, stream, barrier, bucket all-gather, session, PP, Engram, and utility tests

DeepEP-Ascend is built on top of Huawei's HCCL/HCOMM, UBMEM and URMA communication stack. The Ascend backend remains under active development with ongoing work on Bucket collectives, expert load balancing, PP and Engram interfaces.