Skip to content

MXFP4 expert weights lose their scale attribute when a mixture-of-experts model loads under FSDP2

A quantised mixture-of-experts checkpoint loads on a single device and fails under sharded loading. Materialising a module from the placeholder device reads each parameter by name, and the quantised expert block does not expose the scale attribute the checkpoint expects, so loading stops on a missing attribute with a helpful suggestion naming a different one.

Quick answer

The quantised expert module and the checkpoint disagree about what the scale tensors are called, and sharded loading resolves names against the live module rather than into a state dictionary. Load first and shard afterwards, and ignore the attribute the error suggests.

Distributed Training#fsdp#fully_sharded#mxfp4#mixture-of-experts#quantized-experts#meta-device

What this failure is

A load-time failure in which sharded materialisation resolves a checkpoint key against a live quantised module by attribute name, and the quantised expert implementation does not expose the scale tensor under the name the checkpoint uses.

Why it happens (the mechanism)

Sharded construction is designed to avoid ever holding the whole model, so it builds an empty skeleton and fills each parameter in as its key is read. That requires the module to already expose every name the checkpoint will mention. A quantised implementation is free to store packed weights and scales however it likes, and when its choice differs from the checkpoint's key layout, the discrepancy surfaces here rather than in a conventional load that assigns into a dictionary first.

What you'll observe

  • The identical checkpoint loads correctly without sharding, so the file is plainly fine
  • The error names a missing attribute and suggests a near neighbour, which invites editing the name rather than understanding it
  • It fails during loading, before any training step, so no gradient or collective is involved
  • Quantised experts and sharded loading are each supported, and only their combination fails

Common symptoms and what they mean

SymptomWhy it happens
AttributeError naming a quantised expert module and an absent scale attribute, with a suggestion pointing at the corresponding biasA quantised expert block does not hold the same tensors as the unquantised one. The packed weights and their scales may be registered under different names, fused into one buffer, or reconstructed on first use, and which of those a given implementation chooses is an internal detail that the checkpoint's key layout does not have to agree with.
The failure raised while a state dictionary is loaded into a model still on the placeholder deviceSharded loading makes that disagreement fatal. Building the model without data and then materialising parameter by parameter requires the attribute to exist on the module at the moment its name comes up, whereas a conventional load can assign into a state dictionary and let the module sort itself out afterwards.
Checkpoint shard loading reaching completion on some ranks and stopping partway on anotherThe suggestion in the error is misleading and worth ignoring. It is a spelling hint generated from the attributes that do exist, and the neighbour it proposes is a different tensor entirely; acting on it would load a bias where a scale belongs.
A launcher reporting a non-zero exit code for local rank zero with no collective error beneath itA quantised expert block does not hold the same tensors as the unquantised one. The packed weights and their scales may be registered under different names, fused into one buffer, or reconstructed on first use, and which of those a given implementation chooses is an internal detail that the checkpoint's key layout does not have to agree with.

Which systems are affected

  • Mixture-of-experts models whose expert weights are stored in a block-scaled four-bit format
  • Fully sharded loading, which builds the model without data and fills parameters in by name
  • Quantised module implementations that register some tensors as parameters and derive or fuse others
  • Any loader that pairs a checkpoint key with an attribute lookup on the live module

How to confirm this is the problem

Apply the following checklist to a small reproduction: each box below is a positive signal that you are looking at this exact failure rather than a sibling in the same taxonomy.

  • Load the same checkpoint on one device with no sharding. Succeeding there confirms the sharded materialisation path rather than the checkpoint.
  • List the expert module's parameters and buffers and compare the names against the checkpoint keys. The absent name is the disagreement, stated exactly.
  • Check the quantisation library version against the one that produced the checkpoint, since these attribute names change with the scheme.

Example training logs (fingerprint)

training.log (synthetic fingerprint)
AttributeError: 'Mxfp4GptOssExperts' object has no attribute 'down_proj_scales'. Did you mean: 'down_proj_bias'?
  File ".../transformers/modeling_utils.py", in _load_state_dict_into_meta_model
    value = getattr(module, param_type)
Loading checkpoint shards:   0%|          | 0/3 [00:00<?, ?it/s]

Timestamps and exact values vary across runs, but the pattern. An info-level start, an early WARN, an ERROR carrying the symptom. Is the actual fingerprint you should alert on. The Denpex platform flags this combination automatically.

Root cause, fix & prevention, signed in

Sign up free to see why this failure really happens, the exact remediation steps, and the production-grade prevention pattern. You also get 3 free full diagnoses for your own training logs.

Sign up free. Unlock the full analysis

No credit card · 3 free diagnoses · Instant access

Why the recommended fix works

Loading before sharding restores the ordinary path, where the checkpoint is read into a fully constructed model and the quantised module can reconcile its own tensors before anything is sharded. Aligning the quantisation library with the one that wrote the checkpoint removes the disagreement at its source. Both mean the name being looked up is one the module actually has.

Code examples

typical reference pattern
// Typical pattern:
import torch.optim as optim
optimizer = optim.AdamW(model.parameters(), lr=3e-4)
scheduler = optim.lr_scheduler.CosineAnnealingLR(optimizer, T_max=num_training_steps)
for step in range(num_training_steps):
    optimizer.zero_grad()
    loss = model(batch)
    loss.backward()
    optimizer.step()
    scheduler.step()

Adapt the snippet to your framework. The same pattern holds for PyTorch Lightning, Hugging Face Trainer, DeepSpeed, Megatron-LM, and vLLM training wrappers. Where the wrapper exposes a config flag (for examplelr_scheduler_type in Trainer), prefer the flag over the imperative API to keep the schedule declarative and reproducible.

Best practices by model family

Model / StackRecommendationNotes
Quantised MoE under shardingLoad first, shard afterwardsAvoids name-by-name materialisation.
Memory permitsLoad the unquantised formThe mismatch is in the quantised tensor layout.
Checkpoint from elsewhereMatch the quantisation library versionAttribute names are part of the format.
DiagnosingDiff module attributes against checkpoint keysStates the disagreement exactly.

With the fix vs without the fix

DimensionWith the fixWithout the fix
Why single-device loading worksAssigns into a state dictionary firstAssumed to be the same code path
What the Did you mean hint meansA spelling neighbour, nothing moreRead as the correct attribute
Where the disagreement livesBetween module attributes and checkpoint keysBlamed on the sharding layer

Real engineering notes

The suggested attribute in that error has cost people real time. A missing-attribute message with a Did you mean hint is generated by scanning what does exist for a similar spelling, and similarity of spelling says nothing about similarity of meaning. A bias and a scale differ by one word in the name and by everything in what they contain. Treat the hint as noise whenever the attributes are tensors rather than methods.

Visual fingerprint

Two loading paths, one of which needs the name to exist first
  conventional load
    build full model -> read checkpoint into state dict -> module reconciles   ✓

  sharded materialisation
    build skeleton on meta
      for each key: getattr(module, name)   <- name must ALREADY exist
        'down_proj_scales' absent  ->  AttributeError
A conventional load hands the module a whole state dictionary and lets it sort out its own tensors. Sharded materialisation looks each name up on the live module as it goes, so a quantised block that names its scales differently fails at that lookup.

Root cause, fix & prevention

Frequently asked questions

Twelve targeted questions that engineers and on-call staff most commonly ask about this failure.

Should I use the attribute it suggests?
No. The suggestion is generated by spelling similarity over the attributes that exist. A bias is not a scale, and loading one where the other belongs corrupts the model silently.
Why does it load fine on one GPU?
A conventional load reads the checkpoint into a state dictionary and lets the module reconcile its tensors. Sharded materialisation resolves each name on the live module as it goes.
Is the checkpoint broken?
Not usually. It disagrees with the quantised module about tensor names, which most often means the quantisation library and the checkpoint come from different releases.
Can I keep sharding?
Yes. Load the model fully first and shard the materialised model, which avoids the name-by-name path without giving up sharded training.

Don't just read the fix, diagnose your run

The encyclopedia tells you what went wrong. Denpex tells you what went wrong in YOUR training run. With your logs, your config, and your stack.