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 ZeRO-3 generation context manager #1617

Merged
merged 1 commit into from
May 3, 2024
Merged

Fix ZeRO-3 generation context manager #1617

merged 1 commit into from
May 3, 2024

Conversation

lewtun
Copy link
Member

@lewtun lewtun commented May 3, 2024

This PR incorporates a fix from @pacman100 to enable the unwrap_model_for_generation() context manager to work with other trainers like DPO.

The basic issue with our original implementation is that we weren't removing all active parameters during the hook removal and this led to DeepSpeed errors like:

AssertionError: {'id': 0, 'status': 'AVAILABLE', 'numel': 25755648, 'ds_numel': 25755648, 'shape': (50304, 512), 'ds_shape': (50304, 512), 'requires_grad': True, 'grad_shape': None, 'persist': False, 'active_sub_modules': {182}, 'ds_tensor.shape': torch.Size([3219456])}

Tested with this gist: https://gist.github.com/pacman100/a6c89a681f8f76bdf17f5bf6874eb983

cc @edbeeching you should rebase on main once this is merged so #1605 will work

Closes #1543

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Collaborator

@edbeeching edbeeching left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM

Copy link
Collaborator

@younesbelkada younesbelkada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot !

@lewtun lewtun merged commit 0347f58 into main May 3, 2024
9 checks passed
@lewtun lewtun deleted the fix-fast-gen branch May 3, 2024 14:00
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

Successfully merging this pull request may close these issues.

Speed up ZeRO-3 generation with DPO
5 participants