Skip to content

Add Initial Compile for Llama 3.2 11B: Decoder TransformerSelfAttentionLayer, TransformerCrossAttentionLayer #1287

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

Merged
merged 1 commit into from
Oct 10, 2024

Conversation

Jack-Khuu
Copy link
Contributor

Based on https://github.com/pytorch/torchtune/blob/57ab583c84c4a9dcacac23aeabc81f2a679670fe/torchtune/training/_compile.py#L42-L52

Compile as much of the Llama3.2 11B Vision Model from tune as we can


Testing:

 python torchchat.py generate llama3.2-11B --prompt "What's in this image?" --image-prompt assets/dog.jpg --compile

Run it a few times to avoid caching times: On the 4th iteration

What's in this image?The image is of a dog wearing sunglasses and riding a skateboard in the street. The dog is white with some brown spots on its face and ears, and it has its tongue out. It's wearing red sunglasses and a blue collar, and its front paws are on a red penny board with yellow wheels. The background is a road with green trees on either side.2024-10-09:18:43:33,307 INFO     [generate.py:1158] 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                
Generated 74 tokens                 
Time for inference 3: 1.9990 sec total                 
Time to first token: 0.1759 sec with parallel prefill.                

      Total throughput: 37.5180 tokens/sec, 0.0267 s/token                 
First token throughput: 5.6850 tokens/sec, 0.1759 s/token                 
 Next token throughput: 40.5893 tokens/sec, 0.0246 s/token                     
2024-10-09:18:43:33,307 INFO     [generate.py:1169] 
Bandwidth achieved: 798.83 GB/s

Copy link

pytorch-bot bot commented Oct 10, 2024

🔗 Helpful Links

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

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

✅ No Failures

As of commit 1b83644 with merge base 438ebb1 (image):
💚 Looks good so far! There are no failures yet. 💚

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

@Jack-Khuu Jack-Khuu requested a review from iseeyuan October 10, 2024 01:49
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 10, 2024
Comment on lines +943 to +946
else:
self.decode_one_token = torch.compile(
self.decode_one_token, fullgraph=True, **kwargs
)

Choose a reason for hiding this comment

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

Out of curiosity, how long does it take to compile in this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

About 2 Minutes for Llama 3.1

Copy link
Contributor

@iseeyuan iseeyuan left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@Jack-Khuu Jack-Khuu merged commit 1371a41 into main Oct 10, 2024
52 checks passed
@Jack-Khuu Jack-Khuu deleted the compile_mm branch January 24, 2025 23:48
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