Repository navigation
Instantiate per-partition Broadcasted in NamedArrayPartition copyto! - #677
Merged
ChrisRackauckas merged 1 commit intoOct 10, 2026
Conversation
Mirrors the ArrayPartition fix: unpack() drops a Broadcasted's axes, and the per-partition copyto! never recomputed them before handing the slice to the partition's own copyto!, which on Julia 1.12 takes a slower, non-SIMD path. Wrap the per-partition unpack in Broadcast.instantiate. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude <noreply@anthropic.com> Agent-Harness: Claude Code 2.1.294 Agent-Model: claude-sonnet-5 Agent-Session: https://claude.ai/code/session_01LPHREnnonfLg1VcE1EJovv Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LPHREnnonfLg1VcE1EJovv
Member
Independent review (Devin CLI 3000.11.3, model fusion-claude-opus-5-5-high-sidekick-swe-2-medium): MERGE, risk low. Full reviewVERDICT: MERGE Blocking findingsNone. Non-blocking findings
What I ranAll results below are confirmed by running. I used copies of the repo in
What I did not verify
🤖 Posted by an AI agent — harness: Devin CLI 3000.11.3 (review), Claude Code 2.1.285 (posting) · model: fusion-claude-opus-5-5-high-sidekick-swe-2-medium |
ChrisRackauckas
marked this pull request as ready for review
October 10, 2026 19:38
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.
Conflicts with #447
#447 rewrites
src/named_array_partition.jlsubstantially (adds anAbstractNamedArrayPartitiontype and generalizes the constructors/accessors), and its diff touches this
exact
Base.copyto!method, changingdest::NamedArrayPartitiontodest::AbstractNamedArrayPartitionandgetfield(dest, :array_partition).x[i]to
ArrayPartition(dest).x[i]. This PR will textually conflict with #447 ifboth are open; whichever lands second will need the
Broadcast.instantiate(...)wrapping re-applied to the other's version of the method. Flagging this per
the audit; not attempting to resolve it here since #447 is a larger,
independent change.
What and why
Same root cause as the
ArrayPartitionfix(#670):
unpack(bc, i)drops a
Broadcasted's axes, andNamedArrayPartition'scopyto!(
src/named_array_partition.jl:222) never recomputed them before handing theper-partition slice to that partition's own
copyto!. On Julia 1.12 thatforces a slower, non-SIMD path. Wrapped the per-partition
unpackinBroadcast.instantiate.Before/after (reused from the audit's
scratch/a1_misc.jl)Julia 1.12.4,
@benchmark,NamedArrayPartition(a = rand(1000), b = rand(2000))(3000 elements), in-place
@. x = x * 2.0 + y:30-element case (
a = rand(10), b = rand(20)), same op:Julia 1.10.12, 3000-element case:
1.10 is close to neutral, matching the audit's note that this is a Julia
1.12-specific regression.
Results are bitwise identical. Seeded script comparing
(collect(nap.a), collect(nap.b))after@. nap = nap * 2.0 + nap2on a3000-element
NamedArrayPartition, serialized from the unpatched tree andcompared against this branch:
identical: true.Failing-before / passing-after
Same technique as PR #670 (neither
@allocatednorJET.@report_optdiscriminates this fix for the same reason — it's a lost-SIMD timing effect,
not an allocation or dispatch effect). Added
test/Core/named_array_partition_tests.jl::"NamedArrayPartition broadcast instantiates partition Broadcasted", a deterministic structural test using acustom partition array type that records whether the
Broadcasteditreceives in its own
copyto!was instantiated (axes !== nothing):Before this fix (
git stashthesrc/named_array_partition.jlchange):After:
Test results
GROUP=Core: all 12 Core testsets pass (NamedArrayPartition Tests: 41 Pass, 0 Fail).GROUP=QA:QA: 20 Pass, 0 Fail— required the same:instantiateadditionto
test/QA/qa.jl's ignore list as #670 (this PR branches offmasterindependently, so it needed its own copy of that one-line change).
Both re-run on Julia 1.12.4 and 1.10.12.
What was not verified
scratch/a1_misc.jlsublibrary benchmarks(
RecursiveArrayToolsArrayPartitionAnyAll,RecursiveArrayToolsRaggedArrays)for a regression from this change specifically — they're unrelated to
NamedArrayPartition'scopyto!and were unaffected in both runs (numbersmatch within noise before/after), included above only as a byproduct of
reusing the audit's script.
What a reviewer should push back on
As noted above, this conflicts with #447 and the two should be sequenced
(whichever merges second re-applies this one-line change to the other's
version of the method). Chris should decide the merge order.
Please ignore until reviewed by @ChrisRackauckas.
Risk assessment
src/named_array_partition.jl, onecopyto!method; nosignature or public API change. Affects every
NamedArrayPartitionbroadcast.
bitwise-identical correctness check; Core and QA test groups pass; a
deterministic structural regression test (same technique as Instantiate per-partition Broadcasted in ArrayPartition copy/copyto!, use type-level homogeneity check #670).
order should be a human decision.
🤖 Generated with Claude Code
https://claude.ai/code/session_01LPHREnnonfLg1VcE1EJovv
Independent review: Devin Fusion (fusion-claude-opus-5-5-high-sidekick-swe-2-medium) rated it low, verdict MERGE: #677 (comment)