-
Notifications
You must be signed in to change notification settings - Fork 207
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
Jcaip/llm bsr #1601
base: main
Are you sure you want to change the base?
Jcaip/llm bsr #1601
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/1601
Note: Links to docs will display an error until the docs builds have been completed. ❌ 10 New FailuresAs of commit b414b49 with merge base 11333ba (): NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
offsets = tl.arange(0, 16)[None, :] | ||
dense_block = tl.load( | ||
dense_block_ptrs + dense_tiled_row_stride * dense_row_idx, | ||
mask=offsets < BLOCKSIZE_COL, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @cpuhrsch masking added in here for the padding
row_block_arange = tl.arange(0, BLOCKSIZE_ROW) | ||
inner_block_arange = tl.arange(0, BLOCKSIZE_INNER) | ||
|
||
if BLOCKSIZE_COL < 16 or BLOCKSIZE_COL % 16 != 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the padding logic (need to do this properly instead of hardcoding 16)
|
||
|
||
@implements(aten.sum.dim_IntList) | ||
def block_sparse_sum(func, types, args, kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @cpuhrsch This computes the sum properly for the fast path reduction, but doesn't work with compile because of L300 temp_sum = bsr.values()[start:stop]
which errors out on data dependent flow.
I think we can add a new kernel to the bsr_dense_addmm
implementation to handle the fast path there instead, and rewrite this using triton
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, so here it's useful to view crow_indices and values as a NestedTensor and then use sum from there :) This is possible because values + crow_indices is like values + offsets.
This PR promotes Supermask and block sparsity from prototype ->
torchao.sparsity
It adds a new public API for
SupermaskLinear
, which users can use to add Supermask to their models withI have also modified all the existing supermask sam testing code to use this new API.
It also ports over the triton addmm kernels from core, to let us modify them as needed. I've added padding support into the triton kernel, which was a 4 tok/s improvement (214 -> 218).
On a H100 benchmarking with the following commands
yields a 134 -> 218 tok/s improvemnt on LLM decoding.