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

[Distributed] create model on meta device #1227

Merged
merged 1 commit into from
Oct 2, 2024
Merged

[Distributed] create model on meta device #1227

merged 1 commit into from
Oct 2, 2024

Conversation

kwen2501
Copy link
Contributor

@kwen2501 kwen2501 commented Sep 28, 2024

Change 1

Changing from:

    with device:
        model = Transformer(config)

to

    with torch.device("meta"):
        model = Transformer(config)

because when we later load weights, we will swap out the tensors of the model anyway. So saving an on-device init here.

Change 2

Also added a with device context to model.setup_cache() call. So that the caches are directly created on the target device -- saving a model.to(device) call.

Copy link

pytorch-bot bot commented Sep 28, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/torchchat/1227

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit cb77ba5 with merge base 77bac00 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 28, 2024
@metascroy
Copy link
Contributor

Rebase to fix failing tochao_experimental check

Copy link
Contributor

@lessw2020 lessw2020 left a comment

Choose a reason for hiding this comment

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

lgtm!
Tested with both llama2 and llama3.

@kwen2501 kwen2501 changed the base branch from pin_torch to main October 2, 2024 19:30
@kwen2501 kwen2501 merged commit 8fcb3ba into main Oct 2, 2024
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Meta Open Source bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants