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
Error when saving FSDP weights with cpu_offload=True [rank1]: AttributeError: 'Params4bit' object has no attribute 'absmax' #1405
...
[rank1]: File "/home/Documents/llama-recipes/src/llama_recipes/utils/train_utils.py", line 259, in train
[rank1]: save_peft_checkpoint(model, train_config.output_dir)
[rank1]: File "/home/Documents/llama-recipes/src/llama_recipes/model_checkpointing/checkpoint_handler.py", line 276, in save_peft_checkpoint
[rank1]: state_dict = get_model_state_dict(model, options=options)
[rank1]: File "/home/miniconda3/envs/llama_recipes_new/lib/python3.10/site-packages/torch/distributed/checkpoint/state_dict.py", line 995, in get_model_state_dict
[rank1]: model_state_dict = _get_model_state_dict(model, info)
[rank1]: File "/home/miniconda3/envs/llama_recipes_new/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
[rank1]: return func(*args, **kwargs)
[rank1]: File "/home/miniconda3/envs/llama_recipes_new/lib/python3.10/site-packages/torch/distributed/checkpoint/state_dict.py", line 475, in _get_model_state_dict
[rank1]: fqns = _get_fqns(model, key)
[rank1]: File "/home/miniconda3/envs/llama_recipes_new/lib/python3.10/site-packages/torch/distributed/checkpoint/state_dict.py", line 224, in _get_fqns
[rank1]: curr_obj = getattr(curr_obj, curr_obj_name)
[rank1]: AttributeError: 'Params4bit' object has no attribute 'absmax'
Apparently as per meta-llama/llama-cookbook#674 a temporary fix is making cpu_offload=False but this is only a bandaid fix that disables CPU offloading
Root cause: PyTorch's FSDP state_dict machinery (get_model_state_dict with cpu_offload=True) uses _get_fqns() to resolve state dict keys back to model attributes by walking dotted paths with getattr(). For 4-bit quantized models, Linear4bit._save_to_state_dict produces keys like weight.absmax, weight.quant_map, and weight.quant_state.bitsandbytes__nf4. When _get_fqns calls getattr(params4bit, "absmax"), it fails because absmax lives inside params4bit.quant_state, not directly on the parameter object.
Fix: Add __getattr__ to Params4bit that proxies known QuantState attributes (including the quant_map→code alias), and add __getattr__ to QuantState that handles the packed bitsandbytes__* keys. This allows the full FQN traversal to succeed without changing how quantization works.
Verified with a single-GPU FSDP integration test using a QLoRA-style model (frozen 4-bit base + trainable adapter). The PR will be reviewed in the next days.
Activity
llajan commentedon Nov 22, 2024
I have the same issue with Llama 70B FSDP QLora training. When cpu offloading is turned off, it runs out of memory (as one might expect).
PanagiotisFytas commentedon Nov 22, 2024
I have still not find a resolution for this for anyone wondering
luismsgomes commentedon Dec 26, 2024
I am also facing this problem :-(
vz-2244 commentedon Jan 2, 2025
Got same issue when I tried Llama-3.2-90B-Vision QLora FSDP training. Any solution?
smartinezai commentedon Mar 24, 2025
I also get the same error when running finetuning from the llama cookbook using FSDP and 4 bit quantization
Fix Params4bit/QuantState attribute access for FSDP state_dict traver…
Add FSDP integration test for 4-bit state_dict save (#1405)
TimDettmers commentedon Feb 14, 2026
A fix for this has been submitted in #1866.
Root cause: PyTorch's FSDP state_dict machinery (
get_model_state_dictwithcpu_offload=True) uses_get_fqns()to resolve state dict keys back to model attributes by walking dotted paths withgetattr(). For 4-bit quantized models,Linear4bit._save_to_state_dictproduces keys likeweight.absmax,weight.quant_map, andweight.quant_state.bitsandbytes__nf4. When_get_fqnscallsgetattr(params4bit, "absmax"), it fails becauseabsmaxlives insideparams4bit.quant_state, not directly on the parameter object.Fix: Add
__getattr__toParams4bitthat proxies knownQuantStateattributes (including thequant_map→codealias), and add__getattr__toQuantStatethat handles the packedbitsandbytes__*keys. This allows the full FQN traversal to succeed without changing how quantization works.Verified with a single-GPU FSDP integration test using a QLoRA-style model (frozen 4-bit base + trainable adapter). The PR will be reviewed in the next days.
Fix Params4bit attribute access for FSDP state_dict traversal (#1866)