Add loops for ATen compiler MHA asm gen to reduce instruction count#45
Merged
Conversation
b0c6806 to
55caddf
Compare
55caddf to
6b8ae98
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Loops the ATen per-head MHA attention helper emission to reduce instruction memory pressure while preserving the old Python-unrolled path.
Changed helpers:
Default emission now uses hardware loops. The existing public unroll path is preserved: ATEN_UNROLL=1 / unroll_loops=True now also sets unroll_attention=True, so the attention helpers use the Python-unrolled path. Tests and harnesses can still override prog.unroll_attention directly after construction for A/B comparisons.
CLM-60M Native Layer 0 Counts
Rerun locally from the simulator workspace with compile_hf_model(model, seq_len=64, hidden_size=None, inter_dim=None, num_layers=1). Native dims: hidden=384, inter=1408, heads=6, kv_heads=2, head_dim=64.
Verification
Companion simulator branch asm-count-verification adds the harnesses and report. Results from that branch: