AnswerDotAI / AnswerDotAI/fsdp_qlora

ValueError report

Open
#61 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
1.6k
Forks
201
PR merge metrics
No merged PRs in 30d

Description

Hi, I met the following error when finetune llama7b model with FSDP+HQQ:
```
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/torch/multiprocessing/spawn.py", line 74, in _wrap
fn(i, *args)
File "/workspace/fsdp_qlora/train.py", line 723, in fsdp_main
model = FSDP(
File "/usr/local/lib/python3.10/dist-packages/torch/distributed/fsdp/fully_sharded_data_parallel.py", line 481, in __init__
_auto_wrap(
File "/usr/local/lib/python3.10/dist-packages/torch/distributed/fsdp/_wrap_utils.py", line 101, in _auto_wrap
_recursive_wrap(**recursive_wrap_kwargs, **root_kwargs) # type: ignore[arg-type]
File "/usr/local/lib/python3.10/dist-packages/torch/distributed/fsdp/wrap.py", line 543, in _recursive_wrap
wrapped_child, num_wrapped_params = _recursive_wrap(
File "/usr/local/lib/python3.10/dist-packages/torch/distributed/fsdp/wrap.py", line 543, in _recursive_wrap
wrapped_child, num_wrapped_params = _recursive_wrap(
File "/usr/local/lib/python3.10/dist-packages/torch/distributed/fsdp/wrap.py", line 543, in _recursive_wrap
wrapped_child, num_wrapped_params = _recursive_wrap(
[Previous line repeated 1 more time]
File "/usr/local/lib/python3.10/dist-packages/torch/distributed/fsdp/wrap.py", line 561, in _recursive_wrap
return _wrap(module, wrapper_cls, **kwargs), nonwrapped_numel
File "/usr/local/lib/python3.10/dist-packages/torch/distributed/fsdp/wrap.py", line 490, in _wrap
return wrapper_cls(module, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/distributed/fsdp/fully_sharded_data_parallel.py", line 481, in __init__
_auto_wrap(
File "/usr/local/lib/python3.10/dist-packages/torch/distributed/fsdp/_wrap_utils.py", line 45, in _auto_wrap
_check_nested_wrapping(root_module)
File "/usr/local/lib/python3.10/dist-packages/torch/distributed/fsdp/_wrap_utils.py", line 107, in _check_nested_wrapping
raise ValueError(
ValueError: FSDP auto wrapping requires modules to not already have FSDP applied but found q_proj.lora_AB in
LlamaSdpaAttention(
(q_proj): LORA(
(base_layer): HQQLinear()
(lora_AB): FullyShardedDataParallel(
(_fsdp_wrapped_module): Sequential(
(0): Linear(in_features=4096, out_features=64, bias=False)
(1): Linear(in_features=64, out_features=4096, bias=False)
)
)
(lora_dropout): Dropout(p=0.1, inplace=False)
)
(k_proj): LORA(
(base_layer): HQQLinear()
(lora_AB): FullyShardedDataParallel(
(_fsdp_wrapped_module): Sequential(
(0): Linear(in_features=4096, out_features=64, bias=False)
(1): Linear(in_features=64, out_features=4096, bias=False)
)
)
(lora_dropout): Dropout(p=0.1, inplace=False)
)
(v_proj): LORA(
(base_layer): HQQLinear()
(lora_AB): FullyShardedDataParallel(
(_fsdp_wrapped_module): Sequential(
(0): Linear(in_features=4096, out_features=64, bias=False)
(1): Linear(in_features=64, out_features=4096, bias=False)
)
)
(lora_dropout): Dropout(p=0.1, inplace=False)
)
(o_proj): HQQLinear()
(rotary_emb): LlamaRotaryEmbedding()
)
```
the command is:
```
export CUDA_VISIBLE_DEVICES=3,4
python train.py \
--world_size 2 \
--model_name /workspace/model/Llama-2-7b-hf \
--gradient_accumulation_steps 2 \
--batch_size 1 \
--context_length 4096 \
--num_epochs 1 \
--sharding_strategy full_shard \
--precision bf16 \
--train_type hqq_lora \
--use_gradient_checkpointing true \
--use_cpu_offload true \
--dataset dummy \
--verbose true
```
How to solve this problem?
Looking forward to your reply.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at train.py, especially fsdp_main around line 723, and inspect how FSDP auto-wrapping interacts with the HQQ/LoRA modules shown in the traceback. Reproduce with the provided two-GPU command and verify that training starts without the nested-FSDP ValueError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
distributed-systems, machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.