Description
When attempting to convert or load a compressed-tensors (llm-compressor) NVFP4 export of a Qwen3.5 / Agents-A1 MoE model (e.g. Agents-A1-NVFP4 with model.language_model.* tensor hierarchy), ft checkpoint fails during expert bank conversion.
Depending on prefix handling, the conversion halts with:
ValueError: Missing MoE expert source layers: {'gate_up': [0..39], 'down': [0..39]} (when _NVFP4_EXPERT_KEY_RE does not match the compressed-tensors naming scheme)
KeyError: (0, 0, 'down_proj') or assertion failure in _iter_weights_compressed_tensors when encountering mixed precision (BF16 linear attention + NVFP4 full attention/experts).
Root Cause Analysis
-
Quant Detection (freetoken/models/qwen3_5_moe/config.py):
_expert_quant() checks for quant_algo == "NVFP4" (ModelOpt style) or quant_algo == "MIXED_PRECISION". For checkpoints produced by llm-compressor, the top-level field is quant_method: "compressed-tensors", which results in expert_quant falling back to "none".
-
Regex & Suffix Mismatch (freetoken/models/qwen3_5_moe/weight.pyd):
_NVFP4_EXPERT_KEY_RE expects keys matching (?P<kind>weight|weight_scale|weight_scale_2). In compressed-tensors checkpoints:
- Packed weights are named
*.weight_packed instead of *.weight.
- Global scale scalars are named
*.weight_global_scale / *.input_global_scale.
- The tensor tree carries a
model.language_model.layers... prefix rather than model.layers....
-
Hybrid Attention/GDN Quantization:
In compressed-tensors MoE checkpoints for hybrid architectures (e.g. Qwen3.5 with GatedDeltaNet + full attention), only the full attention layers and routed experts are quantized to NVFP4, while the linear recurrent (GDN) projections (conv1d, A_log, in_proj_*, out_proj) remain in BF16. The compiled loader assumes all dense projections in a compressed-tensors checkpoint share a uniform quantization scheme.
Steps to Reproduce
- Obtain a
compressed-tensors NVFP4 checkpoint of Agents-A1 or Qwen3.5-MoE.
- Run:
ft checkpoint --model <checkpoint_dir> --out <ftw_dir> --dtype bfloat16 --moe-backend offload
- Observe
ValueError: Missing MoE expert source layers or failure during weight iteration.
Environment
- OS: Windows 11
- FreeToken Version: 0.1.2+g0ee42b72c
- GPU: NVIDIA GeForce RTX 4060
Description
When attempting to convert or load a
compressed-tensors(llm-compressor) NVFP4 export of a Qwen3.5 / Agents-A1 MoE model (e.g.Agents-A1-NVFP4withmodel.language_model.*tensor hierarchy),ft checkpointfails during expert bank conversion.Depending on prefix handling, the conversion halts with:
ValueError: Missing MoE expert source layers: {'gate_up': [0..39], 'down': [0..39]}(when_NVFP4_EXPERT_KEY_REdoes not match thecompressed-tensorsnaming scheme)KeyError: (0, 0, 'down_proj')or assertion failure in_iter_weights_compressed_tensorswhen encountering mixed precision (BF16 linear attention + NVFP4 full attention/experts).Root Cause Analysis
Quant Detection (
freetoken/models/qwen3_5_moe/config.py):_expert_quant()checks forquant_algo == "NVFP4"(ModelOpt style) orquant_algo == "MIXED_PRECISION". For checkpoints produced byllm-compressor, the top-level field isquant_method: "compressed-tensors", which results inexpert_quantfalling back to"none".Regex & Suffix Mismatch (
freetoken/models/qwen3_5_moe/weight.pyd):_NVFP4_EXPERT_KEY_REexpects keys matching(?P<kind>weight|weight_scale|weight_scale_2). Incompressed-tensorscheckpoints:*.weight_packedinstead of*.weight.*.weight_global_scale/*.input_global_scale.model.language_model.layers...prefix rather thanmodel.layers....Hybrid Attention/GDN Quantization:
In
compressed-tensorsMoE checkpoints for hybrid architectures (e.g. Qwen3.5 with GatedDeltaNet + full attention), only the full attention layers and routed experts are quantized to NVFP4, while the linear recurrent (GDN) projections (conv1d,A_log,in_proj_*,out_proj) remain in BF16. The compiled loader assumes all dense projections in acompressed-tensorscheckpoint share a uniform quantization scheme.Steps to Reproduce
compressed-tensorsNVFP4 checkpoint ofAgents-A1orQwen3.5-MoE.ValueError: Missing MoE expert source layersor failure during weight iteration.Environment