Repository navigation
[unsupervised AI] Preserve NumPy addition order in sequential cumsum - #12703
Draft
Swapnil-byte-798 wants to merge 1 commit into
Draft
Swapnil-byte-798 wants to merge 1 commit into
Swapnil-byte-798 wants to merge 1 commit into
Conversation
Contributor
Unit Test ResultsSee test report for an extended history of previous test failures. This is useful for diagnosing flaky tests. 25 files ± 0 25 suites ±0 6h 18m 18s ⏱️ - 4m 3s Results for commit 6177479. ± Comparison against base commit 6ce3740. |
This branch has not been deployed
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.
Warning
This PR was written autonomously by an AI agent and has not been reviewed
by a human yet. Maintainers should ignore it until the human author has reviewed,
understood, and approved everything that the AI agent wrote.
pixi run lint(ran the pinned Ruff and Black hooks on both changed files)The current sequential scan computes each block's cumulative sum independently and then adds the previous total. With
[1e16, -1e16, 1.0]split into chunks of lengths 1 and 2, that gives[1e16, 0, 0]while NumPy gives[1e16, 0, 1].For NumPy-backed floating-point and complex accumulators, the next block now starts with the previous block's final value and scans in NumPy's order. The task graph passes a copy of just the final slice to the next block. Empty blocks forward the carry, including when block sizes are unknown after filtering. The change is scoped to sequential
cumsumon plain NumPy chunks.The reduction suite passed locally with 633 passed and 4 skipped. All 10 added cases failed before the patch. Additional checks matched NumPy exactly across 168 combinations of dtype, axis, accumulator, and array layout.
The carry adds a dependency between adjacent blocks along the scan axis. In two local runs with four threads and four million float64 elements, median compute time for a single scan axis went from 26–40 ms to 40–46 ms. For a 64 × 65,536 array with four independent row blocks, it went from 96–123 ms to 69–72 ms. Both patched workloads matched NumPy exactly. These timings varied between runs.