You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit cb23330
Browse filesBrowse the repository at this point in the historyBrowse files
fix(moe): export fused expert lora in the corrected peft >= 0.19.1 layout (NVIDIA-NeMo#3626)
* fix(moe): export fused expert lora in the corrected peft >= 0.19.1 layout
FixesNVIDIA-NeMo#3592. peft flipped the in/out interpretation of non-transposed
3-D expert parameters in ParamWrapper in 0.19.1 (huggingface/peft#3165),
which transposes every fused expert lora weight it creates. The v5
export used the pre-flip layout, so adapters exported for qwen3_moe,
minimax_m2 and nemotron_v3 fail to load with a size mismatch on
peft >= 0.19.1, which is what a plain pip install gives today.
Following the plan discussed on the issue:
- export emits the corrected layout by default; the explicit checkpoint
option legacy_paramwrapper_layout keeps the pre-flip layout for
consumers pinned to an older peft (separate from v4_compatible)
- the peft save stamps the layout into automodel_peft_config.json and
the loader resolves it from that metadata first, falling back to
shape detection (tensors whose shapes distinguish the generations
decide for the whole file, which covers minimax_m2 where hidden ==
2x moe inter makes the gate_up pair shape-identical), and fails with
a clear error when neither settles it
- peft floor raised to 0.19.1; uv.lock and docker/common/uv-pytorch.lock
regenerated with uv 0.8.22
The real-peft round-trip suite (loading, merged deltas, forward parity)
now runs against the corrected layout with the locked peft, and unit
tests cover both layouts for gated and non-gated experts.
Signed-off-by: stanley1208 <stanley.mei08@gmail.com>
* fix(moe): fail closed on the paramwrapper layout stamp and prove peft parity
Follow-up to the review on NVIDIA-NeMo#3626.
- Qwen3MoeStateDictAdapter.convert_single_tensor_to_hf now forwards
legacy_paramwrapper_layout, so a legacy export is legacy for Qwen3 too
instead of modern tensors under a peft-0.18 stamp.
- _convert_paramwrapper_to_native accepts only the two known layout ids and
raises when the stamp is unknown, when it contradicts unambiguous tensor
shapes, or when the tensors disagree among themselves, instead of treating
any non-legacy value as modern and letting a stamp mask a mixed file.
- The PEFT v5 adapter test compares the delta real peft merges against the
delta computed from the native grouped A/B tensors, parameterized over
nemotron_v3, minimax_m2 and qwen3_moe. A converter that transposed A/B
consistently in both directions passed the old round trip and fails this.
The legacy export is checked the same way through peft's pre-flip delta
formula, since no pre-0.19.1 peft can be installed next to the test floor.
- get_peft_version / is_peft_min_version leave import_utils; the parity test
requires peft >= 0.19.1 via importorskip. The unused logger the first
commit added to the mixin is gone as well.
- finetune.mdx asks for peft >= 0.19.1 and explains when to use
checkpoint.legacy_paramwrapper_layout and what it implies.
Signed-off-by: stanley1208 <stanley.mei08@gmail.com>
---------
Signed-off-by: stanley1208 <stanley.mei08@gmail.com>
Co-authored-by: Alexandros Koumparoulis <153118171+akoumpa@users.noreply.github.com>
PEFT adapters must be loaded on top of the base model. Because the base NeMo AutoModel installation does not include the Hugging Face PEFT library, install a tested version in your active environment before running the inference code:
481
481
482
482
```bash
483
-
uv pip install "peft>=0.18.1"
483
+
uv pip install "peft>=0.19.1"
484
484
```
485
485
486
+
LoRA adapters for models with fused MoE expert weights (for example Qwen3-MoE, MiniMax-M2, Nemotron 3) are exported in the ParamWrapper layout peft has used since 0.19.1, when peft changed it (huggingface/peft#3165); that is why the step above installs `peft>=0.19.1`. If such an adapter has to be loaded by a consumer pinned to an older peft, set `checkpoint.legacy_paramwrapper_layout: true` in the training config to export the pre-0.19.1 layout instead. An adapter exported that way does not load with peft 0.19.1 or newer.
487
+
486
488
```python
487
489
import torch
488
490
from transformers import AutoModelForCausalLM, AutoTokenizer
0 commit comments