-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add multi-column attn-out low projection kernel for small batches#399
Open
rwl4 wants to merge 1 commit into
Open
Add multi-column attn-out low projection kernel for small batches #399rwl4 wants to merge 1 commit into
rwl4 wants to merge 1 commit into
Conversation
The batched attention-output low projection dispatched one (group, token)
matvec per grid slice, re-reading the out_a weights once per token. The new
kernel_dsv4_attn_out_low_ext_q8_0_r1_{2..5} variants reuse the small-batch
ext mat-vec body (one weight read serves every token column) with a
token-major dst mode so the out_b matmul consumes the result directly.
Engaged for 2..8-token batches, which today means the MTP batch-verify
suffix passes; DS4_METAL_DISABLE_ATTN_OUT_LOW_EXT restores the per-token
path.
Measured on M5 Max: low_proj stage 0.472 -> 0.314 ms/layer in an 8-token
verify pass; --mtp --mtp-draft 4 greedy run 27.6 -> 28.4 t/s with output
byte-identical to the old path at batch widths 2/4/6/8; --long-context
gate OK. Any future consumer of small verify batches gets the same
per-pass saving.
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.
The batched attention-output low projection dispatched one (group, token) matvec per grid slice, re-reading the out_a weights once per token. The new kernel_dsv4_attn_out_low_ext_q8_0_r1_{2..5} variants reuse the small-batch ext mat-vec body (one weight read serves every token column) with a token-major dst mode so the out_b matmul consumes the result directly. Engaged for 2..8-token batches, which today means the MTP batch-verify suffix passes; DS4_METAL_DISABLE_ATTN_OUT_LOW_EXT restores the per-token path.
Measured on M5 Max: low_proj stage 0.472 -> 0.314 ms/layer in an 8-token verify pass; --mtp --mtp-draft 4 greedy run 27.6 -> 28.4 t/s with output byte-identical to the old path at batch widths 2/4/6/8; --long-context gate OK. Any future consumer of small verify batches gets the same per-pass saving.