[pat] (2/5) Add QKGrouper and refactor AttentionHeadGrouper for vmap - #4378
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/4378
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@claude Please review changes |
|
Claude finished @lisjin's task in 1m 25s —— View job Review of PR #4378
Overall: LGTM. The vmap refactor is clean and correct. One minor suggestion below.
|
df62bda to
cbada5f
Compare
0f63547 to
c383fbf
Compare
cbada5f to
8efeba6
Compare
QKGrouper applies pruning only to query and key weights of a packed QKV tensor. AttentionHeadGrouperDim0/Dim1 now reassign self.p instead of mutating self.p.data, so torch.vmap (used by PruneOptimizer's local_map path) can iterate over the grouped view.
8efeba6 to
23d1942
Compare
Summary
QKGrouper: new grouper that prunes only the Q and K slabs of a packed QKV tensor, leaving V untouched.AttentionHeadGrouperDim0/Dim1: stop in-place-mutatingself.p.dataand reassignself.pinstead, sotorch.vmap(used byPruneOptimizer'slocal_mappath from PR1) can iterate over the grouped view without tripping the in-place check.Changes
torchao/prototype/pat/group/attention.pytorchao/prototype/pat/group/__init__.py: re-exportQKGrouper.Depends on #4377