SIGN IN SIGN UP

[BugFix] Release unused unquantized weights for fused MC2 (#15216)

### What this PR does / why we need it?

When fused MC2 uses CANN MegaMoe, unquantized expert weights are cloned
into per-expert `w13_weight_list` and `w2_weight_list` tensors. The
original fused `w13_weight` and `w2_weight` parameters remain registered
even though the forward and dynamic EPLB paths consume the cloned lists,
which keeps a redundant full copy of the local expert weights on the
NPU.

This change:

- creates split expert-weight lists for CANN MegaMoe or dynamic EPLB
through one shared path;
- removes the original fused parameters after the independent clones are
ready;
- releases cached NPU allocator blocks after removing the unused
parameters.

The execution tensors are unchanged: fused MC2 and dynamic EPLB continue
to receive the same cloned per-expert weights.

For a BF16 example with 43 MoE layers, 4 local experts per rank, hidden
size 4096, and expert intermediate size 2048, the calculated persistent
saving per rank is:

`43 × 4 × 3 × 4096 × 2048 × 2 bytes = 8.0625 GiB`

This is a calculated weight-memory saving. No end-to-end throughput
improvement is claimed.

### Does this PR introduce _any_ user-facing change?

No API or inference-output behavior changes. It reduces NPU memory usage
for unquantized fused-MC2 deployments that materialize per-expert weight
lists.

### How was this patch tested?

- `git diff --check github/main...HEAD`
- `python3 -m py_compile vllm_ascend/ops/fused_moe/routed_experts.py`
- Reviewed the fused-MC2 and dynamic-EPLB consumers to confirm they use
`w13_weight_list` and `w2_weight_list` after split-list creation.

The focused pytest file was not run on the development control host
because `pytest` is not installed there (`No module named pytest`).
- vLLM main:
https://github.com/vllm-project/vllm/commit/ba07e4a48fc951300d97eb506217dd530583dea3

Signed-off-by: Zheng Shoujian <zheng.shoujian@outlook.com>
J
Jade Zheng committed
e41435157d3a80937bb01f60efb46b28d663f2d5
Parent: 895ca07
Committed by GitHub <noreply@github.com> on 8/29/2026, 1:52:10 AM