#8626·DeepSpeed

[REQUEST] Support FusedLion / FusedLamb and Zero++ quantized communication (hpZ / qgZ) on NPU

Author: VenusTZZCreated Sep 22, 2026Updated Sep 22, 2026
Labelsenhancement

Is your feature request related to a problem? Please describe.

On Ascend NPU, the FusedLion / FusedLamb optimizers and the Zero++ quantized communication paths (hpZ / qgZ) all crash at engine initialization: the accelerator builder resolves to the NPU NotImplementedBuilder and load() raises ValueError: This op had not been implemented on NPU backend.

The crash chain for the optimizers: "optimizer": {"type": "Lion" | "Lamb"} → deepspeed.initialize → FusedLionBuilder().load() (deepspeed/ops/lion/fused_lion.py) / FusedLambBuilder().load() (deepspeed/ops/lamb/fused_lamb.py). For quantized communication: zero_quantized_weights / zero_quantized_gradients → CUDAQuantizer initialization → QuantizerBuilder().load() (deepspeed/runtime/zero/partition_parameters.py).

The other accelerator backends have implemented these ops (SUPA ships all three in op_builder/supa/, #8054); NPU is the remaining gap, verified on real hardware: any of the three configs above crashes at init, so LAMB / Lion training and all Zero++ quantized communication are unavailable on Ascend.

Describe the solution you'd like

Add three pure-torch stateless op modules under op_builder/npu/ (registered in op_builder/npu/__init__.py), honoring the same per-parameter op contract as the CUDA kernels and the same interface shape as the SUPA backend (#8054):

python
# op_builder/npu/fused_lion.py -> NPUFusedLion  (multi_tensor_lion)
# op_builder/npu/fused_lamb.py -> NPUFusedLamb  (per-parameter lamb)
# op_builder/npu/quantizer.py  -> NPUQuantizer  (quantize / dequantize /
#                                swizzle_quant / quantized_reduction / dequantize_fp32)

Contract points that must hold bit for bit:

  • NPUFusedLion — sign-based update with the c==0 → +lr branch and multiplicative weight decay, bitwise-compatible with the reference.
  • NPUFusedLamb — full semantics: per-parameter trust ratio clamped by max/min coefficients, bias correction, both eps modes, weight decay, zero-norm fallbacks. Uses explicit two-step arithmetic instead of in-place add_(alpha=) chains, which fuse into FMA with backend-dependent rounding.
  • NPUQuantizer — grouped symmetric quantization matching the existing wire format exactly: truncation toward zero (the CUDA reference is a static_cast; round-to-nearest would silently change every quantized value), clamping to [-2**(b-1), 2**(b-1)-1], stored value = 1/scale per group. The qgZ int4 path implements swizzle_quant (group permutation into the two-stage all-to-all layout, signed two's-complement nibble packing, even→low / odd→high) and quantized_reduction (dequantize, fp16 accumulation, re-quantize to int8, matching quant_reduce.cu).

Validation: the implementations are pure torch, so the contract tests (bitwise comparison against independent numpy oracles) run without any accelerator present; real-device end-to-end results are reported in the PR with the hardware spec, as done in #8532.

Describe alternatives you've considered

  1. Leave the NotImplementedBuilder fallback as-is. The init-time ValueError remains and Lion / Lamb / Zero++ stay unavailable on Ascend.
  2. Back the ops with torch_npu's native quantize operators (npu_quantize / npu_quant_scatter / npu_quant_max / npu_anti_quant). Measured on 910B4: npu_quantize rounds half-to-even (1.5→2, 2.5→2) while the wire format requires truncation toward zero, so CUDA and NPU nodes would dequantize to different values in a mixed cluster; npu_quant_scatter ignores its round_mode argument (all six modes produce identical output) and npu_quant_max documents rint only — CANN exposes no reachable truncation mode; npu_anti_quant unpacks quint4x2 as unsigned (the reference PackedInt4 is signed two's-complement), has no fp32 output, and does not match quantized_reduction's re-quantized-int8 output side.
  3. Use torch_npu's stateful NpuFusedLamb or npu_combine_tensors. NpuFusedLamb does not match the stateless per-parameter op contract (no lamb() entry point, no bias_correction / combined_scale, eps_mode 1 only, whole-group trust ratio without coefficient clamping); npu_combine_tensors only pays off by merging updates across parameters — unreachable under the per-parameter contract — and rewrites tensor storage pointers, unsafe for ZeRO-managed parameters. No kernel-level lamb/lion operators exist in any torch_npu namespace or the CANN operator metadata (the only optimizer kernels are the Adam family).
  4. Wait for torch_npu / CANN to expose truncation quantization or kernel-level LAMB. The module docstrings record these upgrade points so a native kernel can be swapped in later without changing the contract.

Additional context

  • Config chains, verified end-to-end on device once implemented: Lion 20 steps 1.1281 → 0.6392; a 5-step Lion engine run is bitwise-equal to a manual oracle loop; LAMB 20 steps 1.1281 → 1.1196; hpZ ZeRO-3 2-rank, 8 steps: the quantized path fires on the training loop, quantized on/off loss trajectories overlap (final gap 1.7e-4), per-rank weight-fetch payload 33152 B → 16592 B (−50.0%).
  • Benchmark on this machine (2 ranks, intra-node): pure-torch quantize/dequantize throughput 12.3–28.6 GB/s / 32.1–91.7 GB/s (8–537 MB tensors); intra-node HCCL all_gather 4.7–16.2 GB/s (2–537 MB per rank); computed break-even communication bandwidth 14.4 GB/s; hpZ is slower than the fp16 baseline at every measured size on this machine (0.62–0.97×). Inter-node links were not available for measurement.
  • Validation environment: CANN 8.5.0, torch 2.9.0+cpu, torch_npu 2.9.0.post7, Ascend 910B4 ×4 (aarch64).