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

Add tests for qwen + allow uninitialized weights in Llama model #8552

Open
wants to merge 6 commits into
base: jz/export_qwen
Choose a base branch
from

Conversation

jackzhxng
Copy link
Contributor

@jackzhxng jackzhxng commented Feb 18, 2025

Summary

Add basic ci test for Qwen model. Requires some changes to llama/model.py to allow uninitialized (random) weights.

Test plan

  • Tested and passed locally
  • See if CI passes for the new test.

Copy link

pytorch-bot bot commented Feb 18, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/8552

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

✅ No Failures

As of commit 9b5516b with merge base 1858086 (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 Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 18, 2025
Copy link

This PR needs a release notes: label

If your changes are user facing and intended to be a part of release notes, please use a label starting with release notes:.

If not, please add the topic: not user facing label.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "topic: not user facing"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@jackzhxng jackzhxng force-pushed the jz/export_qwen_tests branch from 5ef3fef to c58edc5 Compare February 18, 2025 23:33
@jackzhxng jackzhxng changed the base branch from main to jz/export_qwen February 18, 2025 23:33
Comment on lines +240 to +249
try:
# assign=True: load params/buffers by assignment instead of performing an in-place copy.
# Because we are using device="meta", tensors do not have memory associated with them
# and an in-place copy is a no-op. Use assign=True in load_state_dict for this scenario.
missing, unexpected = self.model_.load_state_dict(
checkpoint,
strict=False,
assign=True,
) # self.model_ = Transformer(gptconf)
except RuntimeError as e:
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So it doesn't error out when loading examples/models/llama/params/demo_rand_params.pth or any checkpoint that is incompatible with the model architecture. We also have no way to not specify a checkpoint, I looked into removing the default val for that arg but it's going to take some work since it's relied on internally in a lot of places

@pytorch pytorch deleted a comment from larryliu0820 Feb 19, 2025
Comment on lines +240 to +249
try:
# assign=True: load params/buffers by assignment instead of performing an in-place copy.
# Because we are using device="meta", tensors do not have memory associated with them
# and an in-place copy is a no-op. Use assign=True in load_state_dict for this scenario.
missing, unexpected = self.model_.load_state_dict(
checkpoint,
strict=False,
assign=True,
) # self.model_ = Transformer(gptconf)
except RuntimeError as e:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

So it doesn't error out when loading examples/models/llama/params/demo_rand_params.pth or any checkpoint that is incompatible with the model architecture. We also have no way to not specify a checkpoint, I looked into removing the default val for that arg but it's going to take some work since it's relied on internally in a lot of places

EXECUTORCH_DEFINED_MODELS = [
"stories110m",
"llama2",
"llama3",
"llama3_1",
"llama3_2",
"static_llama",
"qwen2_5",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry I accidentally deleted the original comment about ordering, but I was going to say that I think this is clearer to list all the llama models first

@jackzhxng jackzhxng force-pushed the jz/export_qwen_tests branch from 47bed4c to 9b5516b Compare February 19, 2025 16:51
Copy link
Contributor

@larryliu0820 larryliu0820 left a comment

Choose a reason for hiding this comment

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

I'm ok with the changes but I'm really concerned on llama/model.py and I think we should clean it up. I'll create a separate issue.

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 Facebook bot. Authors need to sign the CLA before a PR can be reviewed. topic: not user facing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants