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

Accelerate.unwrap should fully unwrap the model. #3281

Open
2 of 4 tasks
ggoggam opened this issue Dec 9, 2024 · 0 comments
Open
2 of 4 tasks

Accelerate.unwrap should fully unwrap the model. #3281

ggoggam opened this issue Dec 9, 2024 · 0 comments

Comments

@ggoggam
Copy link

ggoggam commented Dec 9, 2024

System Info

- `Accelerate` version: 0.28.0
- Platform: Linux-5.15.0-124-generic-x86_64-with-glibc2.35
- Python version: 3.10.12
- Numpy version: 1.26.3
- PyTorch version (GPU?): 2.5.1+cu118 (True)
- PyTorch XPU available: False
- PyTorch NPU available: False
- System RAM: 250.55 GB
- GPU type: NVIDIA T4
- `Accelerate` default config:
        Not found

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • One of the scripts in the examples/ folder of Accelerate or an officially supported no_trainer script in the examples folder of the transformers repo (such as run_no_trainer_glue.py)
  • My own task or dataset (give details below)

Reproduction

When the model is wrapped in both distributed wrapper (e.g. DistributedDataParallel or DeepSpeedEngine) and compiled module (e.g. OptimizedModule), calling Accelerator.unwrap_model should return a fully unwrapped model (torch.nn.Module). Instead, it currently returns the distributed wrapper.

import accelerate

# some model
model = ...
optimizer = ...

accelerator = accelerate.Accelerator(
    deepspeed_plugin=accelerate.utils.DeepSpeedPlugin(
        **{"zero_stage": 2, "train_micro_batch_size_per_gpu": 4}
    ),
    dynamo_backend="INDUCTOR"
)
model, optimizer = accelerator.prepare(model, optimizer)

# unwrap
unwrapped = accelerator.unwrap_model(model)

# assert
# currently raises error
assert model == unwrapped

Expected behavior

Accelerator.unwrap_model should return fully unwrapped model, i.e. torch.nn.Module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant