Skip to content

[unsupervised AI] Preserve NumPy addition order in sequential cumsum - #12703

Draft
Swapnil-byte-798 wants to merge 1 commit into
dask:mainfrom
Swapnil-byte-798:fix/cumsum-numpy-order
Draft

Swapnil-byte-798 wants to merge 1 commit into
dask:mainfrom
Swapnil-byte-798:fix/cumsum-numpy-order

Conversation

@Swapnil-byte-798

Copy link
Copy Markdown

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.

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 cumsum on 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.

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Unit Test Results

See 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
 19 924 tests + 10   18 491 ✅ + 10   1 433 💤 ± 0  0 ❌ ±0 
379 573 runs  +220  332 282 ✅ +202  47 291 💤 +18  0 ❌ ±0 

Results for commit 6177479. ± Comparison against base commit 6ce3740.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

'cumsum' results differ from 'cumsum' on a pure numpy array

1 participant