Repository navigation
datadeps: NoAliasing arguments no longer share one slot - #792
AnnaLena77 wants to merge 1 commit into
Conversation
The slot cache (aliased_object!) is keyed by aliasing identity, and every NoAliasing value is equal, so the second distinct NoAliasing argument of a region was handed the first one's slot: the task that should have received its own value received another one's. A NoAliasing value has no aliasing to preserve, so it now gets its own copy instead of going through the cache. Regression test (test/mpi/noaliasing_args.jl, added to test/mpi/cpu.jl): a type whose aliasing is NoAliasing, one value per task, two partitions per rank, InOut buffers record which value each task saw. On upstream master at 2 ranks x 2 threads (MPICH) both assertions fail; with this change both pass.
|
I'm not sure I understand the need for this change - |
Thanks for looking at this. For the built-in types you're right, What I ran into is a user type that says struct NoAliasVal; part::Int; v::Vector{Float64}; end
Dagger.aliasing(::NoAliasVal) = Dagger.NoAliasing()
I don't think sharing the slot is irrelevant here, since the slot contains the value itself. I found it in an application where each task got a different |
|
@jpsamaroo @fda-tome Where it came from. Dagger.aliasing(::Vector{TileOut}) = Dagger.NoAliasing()With several partitions in flight, writer 1 got the tiles of partition 2, and writer 3 the tiles of partition 4. There was no error, the results were just wrong. Plain What was going on. Reproducer. No MPI and nothing from our fork, only upstream functions: using Dagger
struct Part
id::Int
data::Vector{Float64}
end
Dagger.aliasing(::Part) = Dagger.NoAliasing()
record!(out::Vector{Float64}, p::Part) = (out[1] = p.id; nothing)
parts = [Part(i, fill(Float64(i), 4)) for i in 1:4]
outs = [zeros(1) for _ in 1:4]
Dagger.spawn_datadeps() do
for i in 1:4
Dagger.@spawn record!(InOut(outs[i]), parts[i])
end
end
[Int(o[1]) for o in outs] # task i should see part iOn current master ( I'm happy to change the approach if you'd rather fix it somewhere else, for example on the |
c8be746 to
f730e05
Compare
|
Thanks so much! Squashed into a single commit and merged as part of #804. |
…l#792) * datadeps: NoAliasing arguments no longer share one slot
On PRs JuliaParallel#792 and JuliaParallel#793, both merged essentially unchanged, reviewers returned 6 and 7 `concern` verdicts. `concern` meant anything from "silently loses buffers" to "a comment names wait_all imprecisely", so the verdict table could not tell the maintainer what to look at. Problem claims now carry `blocker`, `should-fix` or `nit`, and the worst supported severity fixes the verdict (blocker -> fail, should-fix -> concern, nits only -> pass). A category whose only findings are nits now passes instead of reading as a concern. The task rules also say that a weakness predating the change is at most a nit. Schema version 2; reports written for version 1 must be redone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TRNkMLrH1mZo3YmkaHP8Jr
The PR JuliaParallel#792 and JuliaParallel#793 briefs repeated one defect under every category that noticed it (the unfreed NoAliasing copies three times, the removed in_task() guard three times), clipped each repetition at ~300 characters, and put the result in "Read these" lists of 49 and 73 lines. The maintainer had to reconstruct which items were the same issue before deciding anything. A consolidation step (`review.py findings`, fragments/_findings.json) now groups problem claims by the defect they describe; submit requires every problem claim to be in exactly one finding. A finding carries the worst severity of its claims and says how many reviewers raised it independently, which is evidence that it is real rather than noise. The brief now opens with at most three blocker/should-fix findings, each with a plain-words title and the merged lines to read; further findings follow the verdict table, and nits are counted, not listed (`render --nits`; folded in brief.md). Categories that are unverified only because their measurement was never collected, and that raised nothing, share one UNMEASURED line instead of one line each. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TRNkMLrH1mZo3YmkaHP8Jr
On PR JuliaParallel#792 the maintainer's first reaction was to ask why the change was needed at all, since NoAliasing values should never reach aliased_object!. The review had the answer (type_may_alias looks at field types, not at `aliasing`, so such values do reach it), but only inside the claims backing a Necessity `pass`, where nobody reads. Fragments may now `explain` up to two likely questions, each answer backed by the indices of that fragment's measured or traced claims (the validator checks), and the brief shows up to three under "You might ask". The Necessity reviewer is told to always answer "Why is this needed?". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TRNkMLrH1mZo3YmkaHP8Jr
Reviewers of PR JuliaParallel#793 flagged removing an `in_task()` guard from `execute!(::MPIProcessor)` as a regression in three categories, because `execute!` is listed in the manual and nothing says it is only called inside a task. The maintainer had asked for that removal. Rules like this live only in the maintainer's head or in review comments, so every fresh reviewer rediscovers them as bugs. The new Invariants section holds such rules, starting with that one; the review tooling will hand it to every reviewer verbatim. Lesson 99 records why NoAliasing values still reach aliased_object! (the maintainer's own first reading of PR JuliaParallel#792 was that they could not). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TRNkMLrH1mZo3YmkaHP8Jr
Since #792, aliased_object! returned early for NoAliasing, so the copy made for another memory space never entered the object cache and region teardown (which frees the cache's non-original entries) no longer freed it. And an identity-less aliasing that is not NoAliasing itself, such as the empty CombinedAliasing of a struct whose fields are all NoAliasing, still shared one cache key, so a distinct argument could get another one's slot. Add aliasing_has_identity (false for NoAliasing, wrappers of it, and empty CombinedAliasing; dispatchable for user aliasing types). Such values bypass the keyed lookup, and a copy made for another space is recorded under a fresh CopyKey, so teardown frees it while originals stay untouched. Fixes #822.
The Datadeps slot cache (
aliased_object!) is keyed by aliasing identity, and everyNoAliasingvalue compares equal, so the second distinctNoAliasingargument of a region was handed the first one's slot: a task received another task's value (no error, wrong data). ANoAliasingvalue has no aliasing to preserve, so it now gets its own copy instead of going through the cache (4 lines insrc/datadeps/aliasing.jl).Regression test
test/mpi/noaliasing_args.jl(included fromtest/mpi/cpu.jl): a type whosealiasingisNoAliasing, one value per task, two partitions per rank,InOutbuffers record which value each task saw. At 2 ranks x 2 threads (MPICH, Julia 1.13) both assertions fail on current master and pass with this change; the whole CPU MPI suite passes with it (1131 / 1134 assertions, both ranks). I could not reproduce it with Distributed workers alone (strings and a custom type with a move method did not trigger it), so the test is an MPI test.AI disclosure: I prepared this change with the help of Claude (Anthropic) and reviewed it myself.
🤖 Generated with Claude Code