Repository navigation
Cheaper issue path for small ops on pending arrays - #5
Merged
Merged
Conversation
…om viproc) a[i, ...] of a pending array is issued in the C slot as one placement task (no Python hook, no view objects), still a 0-d snapshot marked _scalar. A NumPy scalar operand gets its dtype from its type, never defers, and its bytes are copied as they are when the dtype matches. i7-12700K, 2 workers: the loop ES[i] = ES[i - 1] + abs(sin(A[:, i])).sum() at 500 x 500 0.94x -> 1.31x of NumPy, 1000 x 1000 1.70x -> 1.80x; results bit-identical. Tests: pending elements of all dtypes and key forms against NumPy, snapshot semantics, one task without a sync, the cumulative loop, NumPy scalars of every dtype as operands. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s behind the copy chain) At SIZE elements the chain of 20 copies could finish before y[17] was issued on a fast runner; y[17] then took the ready path and issued no task (seen on viproc's CI, ubuntu 3.13). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JT2yHm85oFjgf1AcgGLUux
…r mutex per op (port from viproc) - nx_ufunc_issue: 0-d inputs of the loop's dtypes and a 0-d result take the loop's shared kernel with a constant layout (no order-K layout, single-call or cast check): the same kernel and layout as before. - Task::copies_ inline: a write into an array a pending task reads (copy- on-write each time) did a heap allocation per op. - Graveyard::drain() checks an atomic flag before taking its mutex. i7-12700K, 2 workers: the loop ES[i] = ES[i - 1] + abs(sin(A[:, i])).sum() at 500 x 500 1.31x -> 1.45x of NumPy (0.94x before this branch), 1000 x 1000 1.80x, 1500 x 1500 1.88x; bit-identical. Test: 0-d ops of every dtype on pending operands, FP errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Port from viproc (hokb/viproc#66), O1 only. Makes the main thread's issue path cheaper for small per-iteration ops such as
ES[i] = ES[i-1] + np.abs(np.sin(A[:, i])).sum(). It adds no synchronous work on the main thread.Changes
ES[i-1]): a C path issues the 0-d copy as one task, instead of going through the Python hook. It is still a snapshot like NumPy's scalar, with no sync.Graveyard::drain(): no mutex per C ABI call.Measurements
i7-12700K, numpy2x's 2 workers, using the README method. Results are bit-identical.
Accumulating variant of example 1:
Tests
New tests:
assert_async);The full suite passes. One run had 3 failures in timing-dependent svd count checks, which pass on their own and in a rerun.
🤖 Generated with Claude Code
https://claude.ai/code/session_01JT2yHm85oFjgf1AcgGLUux