Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix saving adapter weights after disabling DSD #2351

Merged
merged 2 commits into from
Feb 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions torchtune/training/_distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from torchtune.modules.attention import MultiHeadAttention
from torchtune.modules.model_fusion import DeepFusionModel

from torchtune.modules.peft import get_adapter_state_dict
from torchtune.utils import get_device, get_logger
from torchtune.utils._logging import deprecated

Expand Down Expand Up @@ -380,6 +381,8 @@ def gather_cpu_state_dict(
if is_rank_zero:
cpu_state_dict[param_name] = param.cpu()
torch.distributed.barrier()
if adapter_weights_only:
cpu_state_dict = get_adapter_state_dict(cpu_state_dict, device=None)
return cpu_state_dict


Expand Down