Repository navigation
perf: stream a repeated broadcast operand instead of materialising it - #14
Merged
Merged
Conversation
M + row (1024x1024 plus 1x1024) lost to NumPy 0.26x on a Zen 3 even in a Workspace, because the broadcast path copied the row out to a full 8 MiB matrix before adding. When one operand has the full result shape and the other, leading 1s dropped, is a suffix of it, the second just repeats in blocks of its own length: binOp now hands the live slices to the SIMD kernel block by block (kernels.RepeatP), split across cores. Blocks under 64 elements keep the old path. Zen 3, 16 cores pinned, BroadcastAdd 1024^2 + row: heap 3.1 ms -> 0.84 ms Workspace 1.76 ms -> 114-196 us (NumPy 1 thread: 460 us) The new test checks Sub and Div in both operand orders, matrix+row, matrix+1-D, 3-D minus 2-D, 3-D plus a (1,1,n) row and a too-short row, serially and with the block loop forced parallel, against an element by element oracle; swapping the operands in RepeatP makes it fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tannevaled
force-pushed
the
perf/broadcast-rows
branch
from
October 4, 2026 14:07
dac2121 to
d5fc1e3
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.
M + row (1024x1024 plus 1x1024) lost to NumPy 0.26x on a Zen 3 even in a
Workspace, because the broadcast path copied the row out to a full 8 MiB
matrix before adding. When one operand has the full result shape and the
other, leading 1s dropped, is a suffix of it, the second just repeats in
blocks of its own length: binOp now hands the live slices to the SIMD
kernel block by block (kernels.RepeatP), split across cores. Blocks under
64 elements keep the old path.
Zen 3, 16 cores pinned, BroadcastAdd 1024^2 + row:
heap 3.1 ms -> 0.84 ms
Workspace 1.76 ms -> 114-196 us (NumPy 1 thread: 460 us)
The new test checks Sub and Div in both operand orders, matrix+row,
matrix+1-D, 3-D minus 2-D, 3-D plus a (1,1,n) row and a too-short row,
serially and with the block loop forced parallel, against an element by
element oracle; swapping the operands in RepeatP makes it fail.
🤖 Generated with Claude Code