Repository navigation
MPI: skip the planning of tasks a rank neither runs nor owns data for (owner elision) - #818
AnnaLena77 wants to merge 65 commits into
Conversation
…ank, start the others pinned
execute!(::ThreadProc) binds the function to the processor's thread, and MPI's
execute! hands every task to its inner thread, so an MPI task waits behind
whatever occupies that thread without yielding (a long kernel, a rank-local task)
even when nobody asked for that thread: the scheduler merely named it.
A task whose scope leaves every thread of its rank open now runs inline in the
pooled, migratable task that executes it, so Julia puts it on whichever thread is
free. A task whose scope excludes some thread of its rank asked for a thread and
stays bound to the processor the scheduler picked within that scope: an ExactScope
(explicit pinning, and every Datadeps task), but also a union of only some threads
of the rank. The decision looks at the scope the scheduler placed the task under
(TaskSpec.scope), so it includes Datadeps' exact scope and the scopes of chunk
arguments. A union that names every thread of the rank (scope(mpi_rank=r)) is not a
request.
Measured on a 2 ranks x 8 threads cluster (three threads of rank 0 kept busy by
non-yielding tasks, eight short tasks scoped to rank 0 placed round robin): the task
that the scheduler placed on a busy thread waited 3.32 s (of 4 s) before, and all
eight finished within 0.23 s with this change. Uniform-placement benchmarks of
128 uneven tasks, 2 ranks x 16 threads: makespan 1.60 s (6.4x of ideal) ->
0.36-0.40 s.
Second part: start the task of an MPI processor pinned to its inner thread. The
scheduler pins each task to its processor's thread through task_tid_for_processor,
which had no method for MPIProcessor, so MPI tasks started migratable.
execute!(::ThreadProc) then missed its inline fast path (already on the
processor's thread) and, for every task, created a second task pinned to the thread,
scheduled it and waited for it. Measured inside execute! on a dependent chain at 4
ranks x 16 threads: 160-190 us per task for that hand-over, 7 us once the task
starts pinned.
task_tid_for_processor now also receives the task. MPIProcessor{ThreadProc} returns
the tid of its inner processor, for processors of this rank, and leaves a task that
asked for no thread unpinned. Because that decision now differs per task, the pooled
task slots (pinned or made migratable once, when a slot is created, then reused for
later tasks) are kept in two caches: a migratable task that reused a slot an earlier
pinned task had created stayed bound to that thread.
Dependent chain of tasks pinned to a non-driver thread (4 ranks x 16 threads, 3000
links, two runs each): same rank 458 / 414 -> 284 / 254 us per link, alternating
between two ranks 572 / 557 -> 296 / 307.
Tests: test/mpi/free_threads.jl (new). With three of four threads busy, sixteen
rank-scoped tasks finish in under 1.5 s while the busy tasks still have a second
to run; a task scoped to two busy threads of the rank stays on one of them
(this fails if only an ExactScope counted as a request); an explicit thread is kept.
spawn.jl checks the thread of tasks with a compute_scope or exact scope; threads.jl
(Datadeps) is unchanged.
With one rank (a one-rank job, or a rank-local graph on COMM_SELF) there is nobody to tell about the status, the type or the space of a result, so execute! runs the function and stamps its result without planning or broadcasting. Laptop, 4 threads, plain independent @Spawn under MPI with one rank, interleaved 4 times: 16.05 -> 15.32 us per task (shared memory 11.7 us).
…on starts Datadeps slots and received tiles are libc buffers of tens to hundreds of KB, allocated and freed in every region. With glibc's defaults each is a fresh mmap or a trimmed heap top, so every use pays page faults. mallopt keeps up to 16 MB buffers in the heap and never trims it. This is a process-wide setting and is never undone. A tiled factorization on 2 nodes x 1 rank x 32 threads ran about 10 % faster on our cluster; not re-measured on upstream. Linux/glibc only; a no-op elsewhere.
Task + sticky=false still starts on the creator's thread when the creator is thread-bound (the driver, once Distributed has used @async). The relay then shares the driver's thread, and a driver parked in a blocking MPI call (an MPI.Allgather or Barrier in user code) stops it from forwarding the broadcasts the other ranks wait for: a cross-rank cycle that hung the full MPI suite across two nodes (found with a task-backtrace watchdog: three ranks in MPI_Allgather at 100 % CPU, the fourth's relay dead of the send timeout). The relay is made migratable from 4 default threads on. Below that it keeps the old placement: a migratable relay is a polling loop that keeps a thread busy and, at 2 threads per rank, competes with the tasks for the only free thread. That hung the delegation test at 4 ranks x 2 threads (cluster 3 of 3 runs, MPICH laptop 1 of 5, old placement 0 of 5; pinning the relay to the last thread was worse, 3 of 5). From 4 threads on it passes (4 and 8 threads, 2 nodes). test/mpi/relay.jl: restarts the relay from a thread-bound driver and checks it forwards while the last rank's driver is busy. On macOS with Julia 1.13 a Task made by a thread-bound driver did not start on its thread, so this test also passes without the change there; it guards the placement, it does not reproduce the cluster hang.
The relay spun 4096 yield() calls after every message. On a multi-threaded scheduler each yield() puts the task back on the shared queue and wakes a sleeping thread to run it, so one polling loop kept most of a rank's threads out of sleep. A migratable relay now sleeps 100 us between probes from the first idle iteration; a relay that stays on the driver's thread (fewer than 4 default threads) keeps the spin, because it shares that thread and must yield to the tasks there. Measured with the relay migratable: one cross-rank dependency in a Datadeps chain 2.2-2.9 ms against 0.37-0.44 ms without the spin (2 ranks x 4 threads, laptop). On our cluster, 2 ranks x 32 threads, a rank used 181-216 CPU seconds per region against 44 for the same work without the spin, and its kernels ran 6-14 % slower while the spin was on. Not re-measured on upstream master. A migratable relay on only 2 default threads is not used.
A process that takes no part in executing a task (it neither runs it nor owns data it reads) still builds, schedules and dispatches a thunk for it under an SPMD acceleration, only to stamp an empty result. Measured on our cluster (4 ranks x 16 threads), that is 168 us per task on such a process against 188 us on the task's owner; 165 of the 170 us are scheduling and submission. Core support, inert unless an acceleration opts in (default elides nothing, switch off by default: Dagger.elide_foreign_tasks!(true) or JULIA_DAGGER_ELIDE_FOREIGN_TASKS=1, read at startup): * eager_launch! asks elide_task!(accel, spec, task) first (driver-level tasks only). Task ids are still taken in eager_spawn, so they stay uniform. The first submission starts the eager scheduler, which takes an id of its own; with elision that start is made at the same point in the id sequence whether or not the first task is elided. * DTask gains 'stub' (the placeholder result, nothing for ordinary tasks) and 'owner' (the rank/worker known to own the result at spawn, -1 if unknown). istaskstarted accounts for a stub. Later submissions use the placeholder in place of the task (eager_process_elem_submission_to_local!), and a syncdep on an elided task, which has no thunk and is already finished, adds no edge. * Sch.task_failed! is called once from store_result! when a failure is recorded (the task's own error, a failed argument move, an upstream failure), so an acceleration can tell processes that cannot see it. It must not block. * fetch of a task with a known owner calls fetch_failed_uniform! when the future holds an error, so an acceleration can keep the ids its successful fetch takes uniform on the processes that fail before getting there. No behaviour change with the switch off (test/allocations.jl unchanged: task spawn 183 allocations, bound 500).
Implements elide_task! for MPIAcceleration (off by default, see the previous
commit). A rank elides a task when
* its scope is a single ExactScope(::MPIProcessor) of another rank,
* it owns none of the arguments (an owner has to send its data); every argument
is a plain value, an MPIRef chunk without a scope restriction, or an earlier
task whose owner is known,
* the return type is concrete and uniformity checks are off (they are
collective), and
* the task has no tag option (Datadeps tasks keep the old protocol).
It builds no thunk: it takes the task id as before and stamps exactly the
placeholder execute! stamps on a non-owner, ref id included (execute! first takes
an id for the task's tag, so the result is the task's second id).
Failure-only status. A task that may throw made the owner broadcast :ok/:error
and every other rank wait for it, coupling every rank to every task. For these
tasks (mpi_failure_only) the owner now reports only failures: Sch.task_failed!
sends the error asynchronously on the task's tag, covering an error in the task,
in moving its arguments and upstream failures alike; nobody waits for success.
A rank that later needs the task's data (argument move, fetch) stops waiting
when the failure arrives: such waits install the ref they wait on behalf of
(POISON_REF) and mpi_deadlock_detect, which every polling wait goes through,
throws the failure stored in the relay's (owner, tag) slot. fetch of a task whose
owner fails keeps task ids uniform (fetch_failed_uniform!): a successful fetch
takes a generic id on every rank, so the owner that throws first takes the same.
Measured with benchmark/suites/tasks.jl on our cluster (AMD Opteron 6272), 4 ranks x 16
threads per node, median of 7, switch on vs off, same nodes (1/2/4 nodes = 4/8/16
ranks):
tasks pinned to another rank, seen from rank 0, 256 tasks
46.5 / 44.5 / 66.9 ms -> 5.0 / 4.8 / 4.8 ms (~19 us per foreign task, 14x at 16 ranks)
... bodies that may throw 43.7 / 50.9 / 46.2 -> 5.0 / 4.9 / 4.9 ms
round robin over all ranks, 256 tasks
44.6 / 58.9 / 47.8 ms -> 15.3 / 10.6 / 8.1 ms (5.9x at 16 ranks)
... bodies that may throw 38.5 / 37.5 / 39.7 -> 16.1 / 11.0 / 7.9 ms
fan-in tree, 256 leaves 95.5 / 98.4 / 134.2 -> 39.9 / 29.1 / 20.5 ms (6.5x)
all-to-all exchange step 15.4 / 36.3 / 124.9 -> 9.3 / 15.3 / 33.3 ms (3.7x)
dependent hops 55.4 / 66.2 / 64.8 -> 49.6 / 54.0 / 51.5 ms
unscoped (never elided) 11.0 / 12.8 / 15.9 -> 13.5 / 11.6 / 14.4 ms (noise)
Per-rank time is now ~ (own tasks) x 170 us + (foreign tasks) x 20 us instead of
(all tasks) x 170 us.
45 assertions per rank at 3 ranks x 4 threads: results, placeholders and uniform ids/chunk identity on every rank; chains and a consumer on a third rank; a rank that owns an argument takes part; tagged and unscoped tasks are not elided; a failing task gives every rank an error without hanging, also for tasks that consume its result, and later SPMD work and ids still agree. Building it found three real divergences, all fixed in the commits above: a rank that elided its first task did not start the eager scheduler and took one id fewer; the placeholder and the real chunk had different ref ids; after a failed fetch the generic ids differed between ranks and later collectives hung.
The first version elided a task only when its scope was a single ExactScope(::MPIProcessor), which makes the application pin every task to a thread. A spectator needs only the owner's rank, not its thread, so a scope that names a whole rank (Dagger.scope(mpi_rank=r), a UnionScope of the ExactScopes of that rank's processors) is enough: the scheduler keeps choosing the thread, and the rank that elides the task stamps its placeholder with a fixed representative processor of that rank (the chunk's processor is not part of its identity). * mpi_union_scope_processor works out which rank a union scope names, once per scope object (scopes are shared by every task spawned under a with_options block); several ranks, other scope kinds, or mixed contents elide nothing. * mpi_scope_processor is also what decides failure-only status at execution time, so a rank-scoped task reports only failures like a thread-scoped one. test/mpi/elide.jl gains 27 assertions (72 per rank at 3 ranks x 4 threads): a rank-level scope elides on every other rank with uniform ids and chunk identity, sixteen tasks under one with_options scope are spread over several threads of the owner, a chain across two rank scopes, a failing task and its consumer, and a scope that allows several ranks elides nothing.
…ided Tasks without a scope were never elided, because the scheduler places them and so no rank knows the owner when the task is created. The placement rule is deterministic and identical on every rank (canonical candidate order, the rank that owns the first MPI argument first, rotation by task id), so elide_task! now applies it at spawn time and pins the task to the result with an ExactScope. The scheduler is handed the decision instead of making it, so it cannot disagree with the ranks that elide the task (which would leave the task running nowhere). Left to the scheduler, and nothing elided, whenever the owner cannot be decided at spawn time: an argument whose owner is unknown (a task not placed this way, a weak chunk, a chunk with a scope restriction), a result or execution scope, a processor list, a retry/restore hook, a tag, syncdeps, or a processor that would reject the function or an argument. All of these conditions are uniform across ranks. Measured with benchmark/suites/tasks.jl on our cluster (AMD Opteron 6272), 4 ranks x 16 threads per node, median of 7, switch on vs the previous commit's build with the switch off (same nodes; 1/2/4 nodes = 4/8/16 ranks): unscoped, 64 tasks 7.5 / 10.9 / 12.1 ms -> 5.1 / 1.8 / 2.0 ms unscoped, 256 tasks, may throw 33.1 / 33.2 / 34.8 ms -> 20.1 / 12.5 / 11.1 ms all-to-all exchange step 13.7 / 32.4 / 99.1 ms -> 9.1 / 14.7 / 37.2 ms fan-in tree, 256 leaves 90.4 / 92.8 / 91.6 ms -> 42.9 / 29.6 / 21.8 ms tasks pinned to another rank 45.3 / 41.1 / 40.8 ms -> 5.2 / 5.1 / 5.2 ms test/mpi/elide.jl: 84 assertions per rank at 3 ranks x 4 threads, including that the scheduler runs every such task exactly on the rank the spawn-time rule named (round robin reaches every rank, data affinity, chains, a failing task).
…t fits its own scope A rank skipped elision for any task with a chunk argument whose scope was not AnyScope, and a DArray block has one: every task that reads a block was planned in full by every rank (measured in one of our applications: 181 us on a rank that neither runs the task nor owns the block, against 28 us for a chunk without a restriction). A chunk's scope only matters through constrain(task scope, chunk scope) in the scheduler, which fails the task when the two cannot be satisfied together. Compute that chain on the rank that elides (the same one the scheduler computes) and elide when it is valid; an invalid one keeps the ordinary protocol, which reports the failure as before. Test: test/mpi/elide.jl, 'chunk arguments with a scope restriction' (a chunk of the target rank with a rank scope, also with a pinned task; a contradicting scope is not elided and fails). It fails on the old rule and passes on the new one (3 ranks x 2 threads).
…ne is elided on the other ranks Under MPI the tasks that make the blocks of a DArray run inside a Datadeps region (they carry a tag, are not elidable and have no owner), so every task reading a block counted its argument as of unknown owner and was planned in full by every rank: 181 us per task on a rank that neither runs it nor owns the block, against 28 us for a per_rank chunk, in one of our applications (it had to stop using DArray). The placement itself is the same grid on every rank: each block's compute scope is one processor. Add DTask.placed, set it from the placement code through a new hook (note_chunk_placement!, called by emit_chunk_tasks! and the staging path of darray.jl, no-op by default), and let the MPI elision logic read it in mpi_arg_participates / mpi_arg_owner. DTask.placed is separate from DTask.owner on purpose: owner also switches fetch to the failure-only path, which is wrong for Datadeps tasks. Also let a task without a scope use a scope-restricted chunk's rank as its placement preference, after checking that the chosen processor is inside every chunk argument's scope. Test: test/mpi/elide.jl 'DArray blocks ...' (recorded rank equals the holder, consumers elided on all other ranks, a task on a third rank, uniform ids; 3 ranks x 2 threads).
…ries a restriction The elision check I added for scope-restricted chunk arguments computed constrain(compute scope, result scope) for every task. For a task scoped to a whole rank that is a union scope with one entry per thread, and constrain on it costs time proportional to the thread count: the foreign-rank planning cost of a rank-scoped task went from 38-43 us to 69-76 us at 16 threads (interleaved runs of the builds before and after), and 123-130 us at 32 threads, against ~20 us for an ExactScope. The result scope is always nothing for a task that gets here, so start the chain from the compute scope and only for the arguments that carry a restriction, in a function of its own.
`mpi_scope_processor` returns an entry of `MPI_UNION_SCOPE_CACHE`, a
`Dict{UInt,Tuple{Any,Any}}`, so its inferred type was `Any` and everything
`elide_task!` did with the processor (field reads, `memory_space`,
`tochunk(...; type=T)`) was a dynamic dispatch, once per planned task.
Assert `Union{Nothing,MPIProcessor}` at the two return sites.
Rank that only plans a foreign task (2 ranks x 4 threads, M-series, 20000
tasks, spawn+wait): 1.37 -> 1.24 us per task, 2135 -> 1895 B per task.
test/mpi elide, spawn and free_threads pass at 3 ranks.
The branch read the scoped value twice (`!= 0`, then the value). A scoped value is a walk of the scope chain and `take_ref_id!` runs for every task, and twice for every elided one; one lookup saves the other. Planning a foreign task (same setup as the previous commit): 1.24 -> 1.16 us per task, 1895 -> 1831 B per task.
…Scope task A rank scope (Dagger.scope(mpi_rank=r)) is a UnionScope with one ExactScope per thread. elide_task! asked what it names three times per task (mpi_task_processor twice, mpi_failure_only once), each time through a cache keyed by objectid(scope) behind a lock, and objectid of a UnionScope hashes its whole tuple of processors, so the lookup cost grew with the thread count. A profile of a rank that only plans put most samples in mpi_union_scope_processor. elide_task! now resolves the processor once and hands it to mpi_failure_only. The cache is keyed by a function of the scope's contents (length and three members; `===` confirms a hit) and read without a lock (copy-on-write table). The key is deliberately not the scope's address: for a statically typed immutable the compiler may pass a fresh box, so such an "address" differs per call and the cache never hits. On our cluster, 2 ranks x 32 threads, a rank plans a task the other rank runs, us per task: rank scope 60.1 -> 22.2 (ExactScope 18-24), plain task with an argument owned by the other rank 61.2 -> 36.0. Not re-measured on upstream master. Tests: test/mpi/elide.jl (same rank for equal scopes, no entry per equal scope object, no stale answer for a replaced scope).
The generic constrain(::UnionScope, y) wrapped y in a union and rebuilt a new UnionScope of every member (Set, hashing, a fresh tuple). schedule_one! does constrain(compute_scope, AnyScope()) for every task without a result scope, so a task scoped to a rank (a union of its 32 thread processors) paid ~90 us and ~11 KB of garbage for nothing: profile of the owner side, 1754 of 4875 samples in constrain(::UnionScope, ::AnyScope); 19 KB/task and 246 ms GC per 20000 tasks against 8 KB/task for an ExactScope task. AnyScope allows everything, so the answer is x.
…it on A rank that elides a task (it neither runs it nor sources its data) stamps a placeholder result. For a task scoped to a whole rank its processor came from mpi_union_scope_processor, a fixed member of the union, while the owner's scheduler picks the thread inside the rank by rotation (select_processors_uniform!). The ranks therefore disagreed on chunk.processor: with free threads and elision on, test/mpi/spawn.jl had 35 failures at 2 ranks x 4 threads (62 on our cluster), all check_uniform(proc) or the spread over threads ([16, 0, 0, 0] on the spectator against [4, 4, 4, 4] on the owner). On CPU only the checks notice; with several GPUs per rank the placeholder would name another device. Under uniform execution the owner takes the candidate at mod(id - 1, n) + 1 of the scope's processors in canonical order (the owner rank is either the whole candidate list or not in it). The placeholder now uses the same index, from a lock-free cache of the ordered processors per union scope, so the per-task cost does not grow with the thread count. Test: test/mpi/elide.jl, the processors stamped on 16 tasks of one rank scope agree across ranks; fails without the change.
…ironment variable The flag is a plain Ref read at submission time and set by Dagger.elide_foreign_tasks!(on); it stays off by default. No environment variable is read, so nothing depends on the state of the process at startup.
Whether a task reports only failures is decided when it runs (execute! and task_failed! read the flag), not when it is submitted. A task submitted with the switch on that ran after it was turned off made its owner send the ordinary status while the ranks that had elided it waited for nothing, and the reverse left the ranks that planned it in full waiting for a status that never came. elide_foreign_tasks! now waits until the eager scheduler has no task in flight before it changes the value, and refuses to change it from inside a task. The docstring was also attached to the flag, not the function. The new testset fails without the wait (the owner's task is still running when the switch returns).
Task ids, tags and failure tags are those of the world communicator. A failure-only decision for a processor of another communicator would use them, so such tasks are never failure-only or elided and take the ordinary path. Adds the section on owner elision to the MPI docs.
3979870 to
58761b9
Compare
`__init__` registered `ThreadProc(myid(), tid)` for `tid in 1:Threads.nthreads()`. `nthreads()` counts only the default pool, but Julia numbers the interactive pool first: with an interactive thread (the default since Julia 1.12, or `-t N,1` on 1.10/1.11) thread 1 is interactive and the default pool is threads 2:N+1. So Dagger ran tasks on the interactive thread, where the main task and the REPL live, and never used the last default thread. Measured on Julia 1.12 with `-t 4` (found while checking ThreadPinning.jl against JuliaParallel#810): Dagger's ThreadProcs were tids [1, 2, 3, 4], and the CPU pinned to tid 5 never ran Dagger work. This loop dates from 2020-2021, before interactive threads existed, so using thread 1 was never a decision. Register the default pool's tids (`Threads.threadpooltids(:default)`, available since 1.9) instead. Dagger now never schedules tasks on an interactive thread: Julia reserves those for short, latency-sensitive work, and they are where the REPL and usually the eager scheduler's own loop run. Everything that meant "the first thread" by writing a literal 1 now asks for it: - The eager scheduler's long-lived thunk was pinned to `ExactScope(ThreadProc(1, 1))`, which no longer exists when thread 1 is interactive; pin it to the first default-pool thread. - The precompile workload registered `__cpu_thread_1__` directly (`__init__` has not run yet), and that Dict is saved in the package image. `__init__` used to overwrite that entry; now that it registers other names, a stale ThreadProc(1, 1) would survive into every session. Register the first default thread and delete the callback at the end of the workload. `Threads.nthreads()` elsewhere sizes parallel work by the default pool's size, which is still correct. `stealing_permitted` still excludes worker 1's thread 1 (the main thread); when that thread is interactive there is simply no ThreadProc for it. Tests that scheduled on `ThreadProc(1, 1)` or `thread=1` (or on a worker's threads 1 and 2) only passed on 1.12+ because tasks could run on the interactive thread; they now use the real first threads. CI's 1.12+ multithreaded jobs (`-t auto`) have an interactive thread, but 1.10/1.11 do not, so the processors suite also starts a `-t 2,1` subprocess and checks that ThreadProcs are exactly the default pool, that tasks pinned to each run there, and that no task runs on the interactive thread. That test fails on master. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An integer `assignment` array maps each block to "the first CPU thread of the worker" (as docs/src/darray.md says), but the code built `ThreadProc(proc, 1)`. When the worker has an interactive thread, thread 1 is that thread, which no longer has a ThreadProc, so blocks were placed on a processor the scheduler does not know. Use the worker's lowest-numbered registered ThreadProc instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ranks that are neither end of an in-place copy execute it on a plain ThreadProc so that no unrelated GPU context is activated. That was `ThreadProc(myid(), 1)`, which is the interactive thread whenever one exists (test/mpi/run.jl's `--threads=2` gives each rank one on Julia 1.12). Use the first default-pool thread, which Dagger actually schedules on. `first_default_tid` does not allocate, since this runs for every copy on every spectator rank. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Record why `1:nthreads()` and literal thread 1 are wrong once an interactive thread exists, and which CI configurations can see it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review finding F6 (should-fix) on PR JuliaParallel#815: MPI duplicated the CPU fast path for profiling, invokelatest and captured errors. Extract one core helper and call it from both paths. Isolated one/two-rank mixed-pool tests pass task results, exact pinning and one-rank exception propagation/recovery. Written by an AI agent on jpsamaroo's review feedback.
Review finding F3 (blocker) on PR JuliaParallel#815: task_processor() returned the scheduler-selected CPU even when the kernel ran on another free thread. Add a processor dispatch hook and derive an MPI CPU processor from the thread executing the query. The two-rank 2-default+1-interactive-thread probe checks 32 unscoped queries per rank and exact-thread scopes; all pass. Written by an AI agent on jpsamaroo's review feedback.
Review finding F2 (blocker) on PR JuliaParallel#815: Every CPU launch and execution scanned a union containing all ranks. Retain the union constructor's deduplication set and exact-member flag, cache canonical local thread scopes, and invalidate those scopes with processor children. Mixed scopes retain the generic fallback, and union hashing agrees with order-independent equality. Credential-free Julia 1.13.4 measurements: 5000 checks, ten warmups, GC before each of five samples, minima over five runs. At 4/64/512 virtual ranks: before 3.837/38.560/414.665 ms and 2.56/40.96/327.68 MB (40k/640k/5.12m allocations); after 1.679/1.698/1.660 ms and zero bytes/allocations throughout. Retaining set metadata grows those scope objects from 652/10252/81932 to 1308/18828/168076 bytes. This deliberately trades retained scope metadata for constant-rank-cost, allocation-free task checks. One/two-rank MPI tests at two default plus one interactive thread pass membership/cache invalidation, exact pinning, busy-thread progress, results and one-rank failure recovery. Written by an AI agent on jpsamaroo's review feedback.
Review finding F5 (should-fix) on PR JuliaParallel#815: A task-aware pinning hook may choose migratable execution or the processor's fixed thread; arbitrary changing non-nothing thread IDs cannot reuse one pinned pool. State that contract in the hook docstring. Existing and new MPI tests exercise alternation between migratable and exact pinned work in mixed Julia pools. Written by an AI agent on jpsamaroo's review feedback.
A mutable Set field changed UnionScope ===/objectid and prevented scheduler compatible-set reuse across freshly constructed equivalent regions. Retain only a deterministic immutable content hash and publish the constructor's membership dictionary in a bounded external cache. Check tuple identity on hash collisions and invalidate communicator entries with processor caches. Keep the mixed-scope fallback and exercise one-member unions with two threads. Measured 5000 membership checks after ten warmups and GC, minimum of five: 4/64/512 virtual ranks take 0.877/0.919/0.865 ms, zero bytes and allocations. The original pre-optimization branch took 3.837/38.560/414.665 ms and allocated 2.56/40.96/327.68 MB. Scope retention is 660/10260/81940 bytes (original +8); the shared bounded cache retains 188644 bytes for these three scopes. Profiling also avoided abstract-tuple indexing and escaping immutable Set wrappers. One- and two-rank MPI checks with two default plus one interactive threads cover fresh scope identity, compatible-set reuse, cache invalidation, actual thread placement, busy-thread progress, and failure recovery. Written by an AI agent on jpsamaroo's review feedback.
Specify ownership and immutable retention for acceleration caches. Written by an AI agent on jpsamaroo's review feedback.
Retain master’s concrete-spec launch barrier and value-based untyped argument checks alongside elided-result replacement and owner-elision preparation. Integrate current scheduler, option pooling and memory-space fixes before repairing lifetime and eligibility. Written by an AI agent on jpsamaroo's review feedback.
The pre-existing TaintScope == compares taint contents while its inherited hash used mutable Set identity. Portable union scopes expose that prerequisite when equivalent scopes are reconstructed. Hash the inner scope and taint contents, with round-trip equality/hash/Dict regressions. After ten warmups and GC, 5000 DefaultScope/ProcessorTypeScope hashes remain zero bytes and allocations (minimum of five samples). Written by an AI agent on jpsamaroo's review feedback.
A serialized cached hash retained sender-side member identities. Reconstruct UnionScope from its normalized member tuple so the receiving process computes its own metadata and registers its membership cache. The previous round-trip probe produced equal fresh scopes with different hashes. Final focused checks pass 57 assertions on one MPI rank and 54/56 on two ranks, including fresh received identity, hash/Dict behavior, portable scope values across ranks, placement, and failure recovery. Membership lookups remain zero bytes/allocations after warmup. Written by an AI agent on jpsamaroo's review feedback.
An equal membership hash can represent a different tuple order. Preserve the existing membership dictionary when its contents match, and publish the current constructor tuple so task lookups avoid recursively comparing a previous large tuple. Fresh equivalent 512-rank scopes improved from 166.8 ms to 0.89 ms per 5000 checks in a same-process old/new callback control, with zero bytes/allocations in both hot paths. Publishing adds 576 bytes and 4 allocations per constructor at 4/64/512 virtual ranks; 100-constructor samples follow ten warmups and GC, minimum of five. The fresh-scope membership/compatible-cache identity regressions pass. Written by an AI agent on jpsamaroo's review feedback.
Bring in the current JuliaParallel#815 processor registry, free-CPU execution and normalized scope serialization repairs, including JuliaParallel#841 default-pool registration. Preserve both owner-elision scope constraints and the independent hash/serialization regression tests. Written by an AI agent on jpsamaroo's review feedback.
Julia can make a reusable task sticky when a payload schedules @async. The setup callback only runs at creation, so later rank-wide MPI work can remain stuck behind that physical thread. Retire such slots by closing their channel before publishing readiness and replace closed slots on reuse. Leave intentionally pinned slots and outstanding async children with their original affinity; never unset sticky on a running task. The new unit controls fail four assertions before the repair and pass all 14 after it; the23 existing lazy-slot assertions still pass. Two ranks x 4default+1interactive pinned to2 CPUs reproduce the independent async-poison probe: subsequent slots are now nonsticky and16quick tasks complete in 0.179/0.190s with another thread occupied, versus1.799s in the independent old-head control. This repairs a preexisting pooled-state weakness exposed by the free-MPI path. After10x1000calls warmup and GC, minimum of five1000call GC-delta runs is 0bytes/0allocations before and after for ordinary unpoisoned dispatch. Retirement deliberately allocates a fresh slot only after async poisoning. Written by an AI agent on jpsamaroo's review feedback.
Capture failure-only mode at ordered root submission, independently of later optimization switches. Route typed failures into weakly registered state held by DTask/MPIRef handles, including early relay delivery and serialized refs, instead of retaining every exception in global broadcast slots. Raw failed fetches consume no data-fetch tag. Generate IDs after metadata hooks so a reentrant submission cannot skip registration. Prove host-result/CPU eligibility against registered candidates, option defaults, and function/argument compatibility before binding the owner. Pin the logical processor while preserving the requested scope for free-CPU execution. GPU and custom result metadata keeps the ordinary exchange; failure-only execution uses mpi_execute_inner rather than bypassing that path. The original two-rank switch-off fetch hung; it now throws on both ranks and subsequent uniform work succeeds. Expanded owner-elision coverage passes170/166 assertions, including repeated/raw fetches, early delivery, serialization and weak reclamation. OpenCL metadata fallback passes10 assertions/rank. Before/after 1000-placement GC profiles after10 deep warmups+GC/5samples:92000/3504000B -> 102000/3920000B for the additional proof; a separate follow-up removes candidate copy/sort costs. Full MPI and allocation suites are recorded separately. Written by an AI agent on jpsamaroo's review feedback.
Visit the captured submission mode of each pair before building the remaining bulk payload. This lets later pairs consume earlier placeholders and preserves bulk scheduling for participating ranks. Three bulk-chain assertions pass on each of two ranks as part of the170/166 owner-elision checks. The disabled path borrows the existing batch without allocating a filtered vector. Written by an AI agent on jpsamaroo's review feedback.
Reuse the scheduler canonical candidate cache and select its preferred-rank rotation directly. Borrow a typed processor scratch vector instead of allocating a worker filter per task. Ten1000-call warmup batches, GC, then five samples: original preplacement92000allocs/3504000B; correctness-proof version102000/3920000B; final17000/704000B. Existing owner/rank/argument-affinity checks compare actual placement and result metadata across ranks. Written by an AI agent on jpsamaroo's review feedback.
A rank-wide scope can still have function or argument compatibility that admits only some CPU threads. The old scope-only decision allowed the selected logical processor to execute on an incompatible physical thread. Check every canonical CPU candidate before choosing the migratable path; otherwise pin to the scheduler's validated processor. Use the same Tf, argument types and options as scheduling, and permit an explicit scope argument for the owner-elision layer's retained requested scope. Real two-rank control expected threadids[3,3] but observed[2,3] before. New compatibility controls pass3 assertions/rank. The combined scopes, serialization and free-thread suites pass on two ranks with4default+1 interactive (pinned to2CPUs) and1default+1interactive. Replace the old scope-only fake launch fixture with real TaskSpecs so it also exercises compatibility metadata. After10x5000 warm queries+GC, minimum of5 samples: scope-only TaskSpec control and full compatibility query both allocate240000bytes/5000calls at4/64/512virtual ranks with2local CPU candidates (48B/call unchanged). The retained canonical scope-only lookup remains covered by the earlier zero-allocation probe; this is the broader task-metadata query, not an end-to-end benchmark. Exact-membership cache remains188644bytes. Written by an AI agent on jpsamaroo's review feedback.
Custom compatibility predicates can inspect task options. Rewriting scope and compute_scope after validating a candidate changed those predicates before the scheduler ran them. Keep the proven scope in private elision state and constrain only the effective scheduler scope. Preserve the original requested scope for CPU execution policy. The previous option-scope probe fails; expanded two-rank owner-elision coverage including this predicate passes175/171 assertions. Written by an AI agent on jpsamaroo's review feedback.
A source can advance past arguments it does not own while the task owner is still waiting for an earlier one. If that earlier source fails, a later rendezvous send has no receiver and MPI.Cancel need not finish it. Publish failures from every participating rank, propagate task poison through argument moves, and use point-to-point readiness on the independent metadata relay before posting data. Readiness waits share the progress heartbeat and retain only blocked consumers. A weak task-id index avoids per-argument scans and prunes dead metadata once per GC. The two-rank egress failure and three-rank failed-first-argument/8MiB-later-send controls previously hang; both now throw and complete later uniform work. Three-rank owner-elision suite passes226/226/222 assertions, including repeated source permits and1MiB successful transfers. Native no-memory/function arguments retain their existing move context; readiness applies only to data chunks. Written by an AI agent on jpsamaroo's review feedback.
A poison or timeout exception must not let Request_free release an in-flight communication buffer. Cancel pending sends and drain their request; matched Imrecv requests finish their existing transfer. Cleanup ignores task poison and sleeps between polls so the paired peer can make progress. Receiver readiness separately prevents later data sends from depending on an owner that abandoned an earlier argument. A real8MiB rendezvous request control notifies the paired peer precisely at cancellation, avoiding JIT/timing assumptions: the old wait passes2/fails2 lifetime assertions; the new wait passes4. Full three-rank owner-elision checks including this control pass230/226/222. Written by an AI agent on jpsamaroo's review feedback.
Written by an AI agent on jpsamaroo's review feedback. # Conflicts: # AGENTS.md # ext/MPIExt.jl
…suite A GPU-scoped task may return a host scalar or Array. Assert that elision is refused and all ranks retain the actual host type/space from the ordinary exchange. The shared OpenCL entrypoint passes12 assertions/rank; the original pre-fix control stamped nonowner host results as VRAM. Written by an AI agent on jpsamaroo's review feedback.
Clear creation-time dynamic scope before starting the persistent metadata relay. Port the exact074f2f9a relay test: it validates cleared scope and compares the delayed consumer timestamp strictly inside the destination-local non-yielding interval, avoiding cross-node clock assumptions and planning-window false passes. Focused2rank×2default+1interactive checks pass3 assertions/rank; the independent816 reviewer already validated the exact4default overlap test and its legacy-placement negative control. Written by an AI agent on jpsamaroo's review feedback.
Per-task checkpoint hooks run on each normal local thunk result, including metadata-only spectators. Conservatively reject checkpointed tasks after option defaults, so owner elision cannot drop a documented callback. Independent exact-d150 control recorded hits[1,1] with elision off and[0,1] on. Durable on/off all-rank regression now passes as part of240/236/232 three-rank owner-elision checks. Written by an AI agent on jpsamaroo's review feedback.
A declared concrete return type may infer as Union{} for an always-throwing kernel. Ordinary metadata then has no consumer on an elided rank and retains the error indefinitely. Honor the submission protocol before inference planning and stamp its declared type. Three-rank owner suite passes 244/240/236 assertions, including repeated failed fetches with no FIFO residue.
Written by an AI agent on jpsamaroo's review feedback.
Port the independently reviewed Python fix from JuliaParallel#815 commit c5ccdcc. The work stealer can run a Python callable on a default CPU thread even though Python's GIL is owned by an interactive thread. Route that typed execution through PythonProcessor. Each offload gets a private pinned task and response, preserving captured Python exceptions and distinct concurrent results. Pass only the profiling flag and scalar task ID into that task so cancellation cannot expose recycled Dagger task metadata. Keep the existing branch-specific MPI execution code. Validation: on this branch's immutable source snapshot, Julia 1.13.4 with 2 default + 1 interactive threads, PythonCall 0.9.37 and Python 3.14.6 passes 6 public NumPy assertions, 10 CPU-dispatch/keyword/error/concurrent-result assertions, the matching 3-assertion stolen-dispatch control, and 2 ordinary CPU controls. The controller exits successfully in a credential-free offline sandbox. These checks do not establish full MPI or backend CI parity. The upstream offload allocation measurement is an intentional correctness tradeoff: after ten 1000-call warmups and five GC-separated samples, 1000 calls change from 112000 B / 6000 allocations to 416000 B / 8000 (+304 B / 2 allocations per call). This branch port does not claim a new whole-package allocation or throughput measurement. Written by an AI agent on jpsamaroo's review feedback.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #818 +/- ##
==========================================
- Coverage 64.35% 63.00% -1.35%
==========================================
Files 126 126
Lines 20191 20835 +644
==========================================
+ Hits 12993 13128 +135
- Misses 7198 7707 +509 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The acceleration failure hook runs during dependency failure propagation, including for thunks without execution options. Reading acceleration from nothing aborts the eager scheduler before downstream futures are filled, masking the original failure. Return when there is no options metadata and keep normal acceleration notifications unchanged. Add a source-to-dependent failure regression with a real scheduler state and future, including positive acceleration dispatch and duplicate-finish suppression. Current OpenCL jobs on both owner-elision branches expose the missing-options exception; this repair does not claim to fix the original GPU failure hidden by it. Native validation is pending the resource grant. Written by an AI agent on jpsamaroo's review feedback.
ComputeState's channel field belongs to the transport Dagger selected. A stdlib RemoteChannel cannot initialize it in DistributedNext runs, so bind the fixture to Dagger's provider before constructing channels. Production logic is unchanged. Written by an AI agent on jpsamaroo's review feedback.
Port the independently reviewed two-file test repair from JuliaParallel#815. Record kernel overlap and physical thread placement while other CPUs remain occupied, release and fetch every busy task before reporting assertions, and retain explicit-scope and compatibility checks. Only the lesson number is adapted to this branch; the registered test is byte-identical to JuliaParallel#815. Production code and existing branch fixes are unchanged. The shared JuliaParallel#815 source passes 96 and 114 focused assertions on Julia 1.10.14 at two ranks with two and three default threads. A private forced- pinning control gives only the five intended failures with zero errors and full cleanup. No native test or whole-CI pass is claimed for this port. Written by an AI agent on jpsamaroo's review feedback.
Dagger benchmarks:
|
| Backend | Regressions | Improvements | Within noise | Inconclusive metrics | Suites |
|---|---|---|---|---|---|
| Threads | 2 | 3 | 11 | 3 | 4/4 |
| Distributed | 2 | 0 | 1 | 0 | 4/4 |
| Distributed+Threads | 3 | 2 | 0 | 1 | 4/4 |
| MPI | 0 | 0 | 1 | 1 | 4/4 |
| MPI+Threads | 1 | 6 | 23 | 4 | 4/4 |
| Total | 8 | 11 | 36 | 9 | 20/20 |
Regressions across all backends
| Backend | Benchmark | Metric | Change |
|---|---|---|---|
| Distributed+Threads | array/dagger/N=1024 (block 128)/alloc (rand) |
time | +142.4% |
| Distributed+Threads | array/dagger/N=1024 (block 128)/transpose (permutedims) |
time | +85.3% |
| Distributed | linalg/dagger/N=1024 (block 128)/syrk (A'*A) |
allocs | +58.3% |
| Distributed+Threads | linalg/dagger/N=1024 (block 128)/lu! (fixed workspace) |
time | +42.8% |
| Threads | linalg/dagger/N=1024 (block 128)/svd |
allocs | +39.6% |
| Distributed | linalg/dagger/N=1024 (block 128)/syrk (A'*A) |
memory | +36.3% |
| MPI+Threads | linalg/dagger/N=1024 (block 128)/matmul (A*A) |
time | +35.6% |
| Threads | linalg/dagger/N=256 (block 256)/syrk (A'*A) |
time | +28.1% |
Improvements across all backends
| Backend | Benchmark | Metric | Change |
|---|---|---|---|
| Threads | stencil/dagger/N=1024 (block 512)/assign (const) |
time | -73.0% |
| Threads | stencil/dagger/N=256 (block 128)/neighbors (Pad) |
time | -66.9% |
| MPI+Threads | array/dagger/N=1024 (block 512)/add (X + X) |
time | -65.3% |
| MPI+Threads | stencil/dagger/N=256 (block 256)/assign (const) |
time | -62.9% |
| Threads | stencil/dagger/N=1024 (block 512)/multi-expr |
time | -62.5% |
| MPI+Threads | array/dagger/N=1024 (block 512)/norm |
time | -54.9% |
| Distributed+Threads | array/dagger/N=1024 (block 512)/alloc (rand) |
time | -53.4% |
| MPI+Threads | linalg/dagger/N=1024 (block 512)/solve (A\b via lu) |
time | -52.1% |
| MPI+Threads | stencil/dagger/N=256 (block 256)/multi-expr |
time | -37.8% |
| MPI+Threads | linalg/dagger/N=256 (block 256)/lu |
time | -37.3% |
| Distributed+Threads | stencil/dagger/N=1024 (block 512)/neighbors (Pad) |
time | -35.9% |
Advisory allocation changes
Paired fixed-placement measurements gate Distributed CPU allocating LU counts and bytes and allocating X + X bytes. Review the advisory changes for costs specific to the allocating path. The original X + X count gate still applies.
| Backend | Benchmark | Metric | Change |
|---|---|---|---|
| Distributed | array/dagger/N=1024 (block 128)/add (X + X) |
memory | +39.1% |
Threads (1 process × 4 threads) — 2 regressions, 3 improvements
| Suite | Regressions | Improvements | Within noise | Inconclusive metrics |
|---|---|---|---|---|
| array | 0 | 0 | 2 | 3 |
| linalg | 2 | 0 | 8 | 0 |
| sparse | 0 | 0 | 0 | 0 |
| stencil | 0 | 3 | 1 | 0 |
Regressions
| Benchmark | Metric | Change |
|---|---|---|
linalg/dagger/N=1024 (block 128)/svd |
allocs | +39.6% |
linalg/dagger/N=256 (block 256)/syrk (A'*A) |
time | +28.1% |
Improvements
| Benchmark | Metric | Change |
|---|---|---|
stencil/dagger/N=1024 (block 512)/assign (const) |
time | -73.0% |
stencil/dagger/N=256 (block 128)/neighbors (Pad) |
time | -66.9% |
stencil/dagger/N=1024 (block 512)/multi-expr |
time | -62.5% |
Within noise
| Benchmark | Metric | Change |
|---|---|---|
array/dagger/N=256 (block 128)/norm |
time | +39.9% |
linalg/dagger/N=256 (block 256)/qr |
time | +32.4% |
array/dagger/N=256 (block 256)/norm |
time | +31.6% |
stencil/dagger/N=256 (block 128)/multi-expr |
time | -26.1% |
linalg/dagger/N=1024 (block 128)/cholesky |
time | -27.2% |
linalg/dagger/N=256 (block 256)/solve (A\b via lu) |
time | -32.3% |
linalg/dagger/N=256 (block 128)/matmul (A*A) |
time | -33.7% |
linalg/dagger/N=256 (block 256)/matmul (A*A) |
time | -42.7% |
linalg/dagger/N=256 (block 128)/cholesky |
time | -42.8% |
linalg/dagger/N=256 (block 256)/lu |
time | -55.8% |
linalg/dagger/N=256 (block 256)/matvec (A*x) |
time | -74.9% |
Inconclusive metric changes
| Benchmark | Metric | Change |
|---|---|---|
array/dagger/N=256 (block 128)/alloc (rand) |
time | +45.7% |
array/dagger/N=1024 (block 128)/transpose (permutedims) |
time | +43.4% |
array/dagger/N=1024 (block 512)/reduce (sum) |
time | +25.7% |
Distributed (4 processes × 1 thread) — 2 regressions, 0 improvements
| Suite | Regressions | Improvements | Within noise | Inconclusive metrics |
|---|---|---|---|---|
| array | 0 | 0 | 0 | 0 |
| linalg | 2 | 0 | 1 | 0 |
| sparse | 0 | 0 | 0 | 0 |
| stencil | 0 | 0 | 0 | 0 |
Regressions
| Benchmark | Metric | Change |
|---|---|---|
linalg/dagger/N=1024 (block 128)/syrk (A'*A) |
allocs | +58.3% |
linalg/dagger/N=1024 (block 128)/syrk (A'*A) |
memory | +36.3% |
Within noise
| Benchmark | Metric | Change |
|---|---|---|
linalg/dagger/N=1024 (block 128)/syrk (A'*A) |
time | +131.5% |
Distributed+Threads (2 processes × 2 threads) — 3 regressions, 2 improvements
| Suite | Regressions | Improvements | Within noise | Inconclusive metrics |
|---|---|---|---|---|
| array | 2 | 1 | 0 | 0 |
| linalg | 1 | 0 | 0 | 0 |
| sparse | 0 | 0 | 0 | 0 |
| stencil | 0 | 1 | 0 | 1 |
Regressions
| Benchmark | Metric | Change |
|---|---|---|
array/dagger/N=1024 (block 128)/alloc (rand) |
time | +142.4% |
array/dagger/N=1024 (block 128)/transpose (permutedims) |
time | +85.3% |
linalg/dagger/N=1024 (block 128)/lu! (fixed workspace) |
time | +42.8% |
Improvements
| Benchmark | Metric | Change |
|---|---|---|
array/dagger/N=1024 (block 512)/alloc (rand) |
time | -53.4% |
stencil/dagger/N=1024 (block 512)/neighbors (Pad) |
time | -35.9% |
Inconclusive metric changes
| Benchmark | Metric | Change |
|---|---|---|
stencil/dagger/N=1024 (block 128)/assign (const) |
time | +39.1% |
MPI (4 ranks × 1 thread) — 0 regressions, 0 improvements
| Suite | Regressions | Improvements | Within noise | Inconclusive metrics |
|---|---|---|---|---|
| array | 0 | 0 | 1 | 0 |
| linalg | 0 | 0 | 0 | 0 |
| sparse | 0 | 0 | 0 | 0 |
| stencil | 0 | 0 | 0 | 1 |
Within noise
| Benchmark | Metric | Change |
|---|---|---|
array/dagger/N=256 (block 128)/transpose (permutedims) |
time | -70.1% |
Inconclusive metric changes
| Benchmark | Metric | Change |
|---|---|---|
stencil/dagger/N=1024 (block 128)/neighbors (Reflect) |
time | +44.6% |
MPI+Threads (2 ranks × 2 threads) — 1 regressions, 6 improvements
| Suite | Regressions | Improvements | Within noise | Inconclusive metrics |
|---|---|---|---|---|
| array | 0 | 2 | 11 | 1 |
| linalg | 1 | 2 | 2 | 1 |
| sparse | 0 | 0 | 0 | 0 |
| stencil | 0 | 2 | 10 | 2 |
Regressions
| Benchmark | Metric | Change |
|---|---|---|
linalg/dagger/N=1024 (block 128)/matmul (A*A) |
time | +35.6% |
Improvements
| Benchmark | Metric | Change |
|---|---|---|
array/dagger/N=1024 (block 512)/add (X + X) |
time | -65.3% |
stencil/dagger/N=256 (block 256)/assign (const) |
time | -62.9% |
array/dagger/N=1024 (block 512)/norm |
time | -54.9% |
linalg/dagger/N=1024 (block 512)/solve (A\b via lu) |
time | -52.1% |
stencil/dagger/N=256 (block 256)/multi-expr |
time | -37.8% |
linalg/dagger/N=256 (block 256)/lu |
time | -37.3% |
Within noise
| Benchmark | Metric | Change |
|---|---|---|
array/dagger/N=256 (block 128)/transpose (permutedims) |
time | +191.2% |
array/dagger/N=256 (block 256)/alloc (rand) |
time | +182.5% |
array/dagger/N=256 (block 128)/map (sin.(X)) |
time | +133.6% |
stencil/dagger/N=256 (block 128)/neighbors (Reflect) |
time | +74.2% |
array/dagger/N=1024 (block 512)/broadcast (X .+ 1) |
time | +62.5% |
array/dagger/N=1024 (block 512)/reduce (sum) |
time | +62.3% |
array/dagger/N=1024 (block 128)/broadcast (X .+ 1) |
time | +57.1% |
array/dagger/N=1024 (block 128)/map (sin.(X)) |
time | +52.6% |
stencil/dagger/N=1024 (block 128)/neighbors (Clamp) |
time | +49.3% |
array/dagger/N=256 (block 128)/broadcast (X .+ 1) |
time | +48.7% |
array/dagger/N=256 (block 128)/add (X + X) |
time | +45.4% |
stencil/dagger/N=256 (block 128)/neighbors (Wrap) |
time | +43.4% |
stencil/dagger/N=1024 (block 512)/alloc (neighbors Wrap) |
time | +43.3% |
stencil/dagger/N=256 (block 128)/multi-expr |
time | +42.4% |
stencil/dagger/N=1024 (block 512)/multi-expr |
time | +41.4% |
stencil/dagger/N=1024 (block 128)/neighbors (Reflect) |
time | +39.0% |
stencil/dagger/N=256 (block 256)/neighbors (Pad) |
time | -35.5% |
linalg/dagger/N=256 (block 256)/matmul (A*A) |
time | -36.6% |
array/dagger/N=256 (block 256)/transpose (permutedims) |
time | -38.6% |
stencil/dagger/N=1024 (block 512)/assign (const) |
time | -40.1% |
array/dagger/N=256 (block 128)/norm |
time | -42.8% |
stencil/dagger/N=256 (block 256)/alloc (neighbors Wrap) |
time | -46.6% |
linalg/dagger/N=1024 (block 512)/cholesky |
time | -52.3% |
Inconclusive metric changes
| Benchmark | Metric | Change |
|---|---|---|
stencil/dagger/N=256 (block 128)/neighbors (Pad) |
time | +93.6% |
linalg/dagger/N=1024 (block 128)/cholesky |
time | +63.3% |
stencil/dagger/N=1024 (block 128)/update (+) |
time | +48.3% |
array/dagger/N=1024 (block 512)/map (sin.(X)) |
time | +35.8% |
Full results and plots (download the benchmark-results-* artifacts).
Category 2 (adapted internal functionality), skipping foreign tasks: This changes how a rank of the MPI acceleration plans tasks that another rank runs. It is invisible while it is off, and it is off by default. It adds one hook to core (
elide_task!, defaultfalse) and one explicit switch,Dagger.elide_foreign_tasks!(on).Based on the MPI relay PR (#816), which I open just before this one (and through it on the MPI task start PR).
Decisions for the maintainers, first
fetch, which then broadcasts it). A failing task is announced by its owner to every rank under the task's id, so every rank sees the error when it fetches the task or a task that consumes it. The consequence that differs from today: a rank that never fetches or consumes an elided task does not wait for it and may not notice that it finished or failed;wait(task)on a rank that elided the task returns at once. If that is not acceptable as a default, the switch stays off (it is off in this PR).ExactScope, orDagger.scope(mpi_rank=r)), or it has no scope and the scheduler's own uniform rule names the owner; its return type is concrete; it has no explicit tag (so no Datadeps task); no syncdeps or restore; plain positional arguments; this rank owns none of its arguments (an owner has to send its data); and it is submitted from outside a task, on the world communicator, with uniformity checking off. Everything else takes the ordinary path, nothing is skipped silently.Dagger.elide_foreign_tasks!(on::Bool=true)sets a plainRefread at submission, off by default. Every rank must call it with the same value at the same point of the program. Whether a task reports only failures is decided when it runs, so changing the value first waits until the tasks already submitted have finished, and the call throws if made from inside a task. No environment variable is read. AScopedValuewas not used because the value must be the same on every rank and is read for every task.Problem. Under SPMD every rank plans every task, including tasks it neither runs nor owns data for. Planning such a task costs about 170 us on our cluster, only to stamp an empty result. In one of our applications every task that read a
DArrayblock was planned in full by every rank (181 us on a rank that neither runs the task nor owns the block, against 28 us for a chunk without a scope restriction).Change. A rank that qualifies skips thunk creation, scheduling, dispatch and the placeholder execution. It only takes the task id, so ids and tags stay equal on every rank, and builds the same placeholder chunk the real execution would have (same ref id, type, memory space, and the processor the owner picks inside its rank). The core hook is
elide_task!(accel, spec, task), called fromeager_launch!. The MPI method:DArrayblock has one) as fine when the scope chain of the task and its chunks is satisfiable, and records where the blocks of an array live (DTask.placed,note_chunk_placement!) so consumers of a block are elided on the other ranks;constrain(::UnionScope, ::AnyScope)returning the union itself (core, with a test), which the scheduler hit for every task of a rank scope.Effect (our cluster, 2 ranks x 32 threads, a rank plans a task the other rank runs, us per task): rank scope 60.1 to 22.2 (ExactScope 18-24), plain task with an argument owned by the other rank 61.2 to 36.0. Not re-measured on upstream master.
Testing (macOS arm64, Julia 1.13, MPICH through the test environment, machine shared with other jobs)
test/mpi/elide.jl(new, also included fromcpu.jl) alone: 2 ranks x 1 thread, 2x2, 2x4, 3x2, 4x2, repeated at 2x2 and 4x2, all pass (145 assertions per rank at 2x2, 236 at 4x2). It covers pinned and rank-scoped tasks (results, placeholders, uniform ids, chunk identity, processors stamped on a spectator agree with the owner's), dependent chains, tasks that must not be elided, failing tasks (every rank sees the error, none hangs, consumers on every rank fail too),DArrayblock placement, chunk scope restrictions, the scope cache, a switch-off test, and the new test that changing the switch waits for the tasks in flight. Withelide_foreign_tasks!a no-op the tests fail without hanging; without the wait in the switch the new in-flight test fails (the owner's task is still running when the call returns).test/mpi/cpu.jlat 2 ranks x 2 threads with the switch at its default (off): 1337 and 1343 passed per rank, 0 failed (run on a local merge of all four PRs).cpu.jlagain with the switch on for every rank (uniformity checking off, the elide tests left out because they set the switch themselves): 1176 and 1172 passed, 0 failed. I did not count how many tasks that run elided.scheduler,thunk,scopes,datadepswith-p 1at-t 1,-t 2,-t 4: no failures (Scheduler 269 pass / 5 broken, Thunk 131 / 1, Scopes 125, Datadeps 1257 at-t 1and 1865-1866 at-t 2/4/ 2 broken).AI disclosure: I prepared this change with the help of Claude (Anthropic) and reviewed it myself.
🤖 Generated with Claude Code