Repository navigation
[extended] Fixes from Tactics' default pipeline on HPCAgent-Bench (weekend of 2026-11-28) - #2811
nicolasribeiro2028 wants to merge 8 commits into
Conversation
A device argument a host library connector writes (ScatterConflictCheck's flag and scratch) is computed in its host twin. When the argument is also written in full before any read, it is in _no_copy_in_needed, and insert_copies dropped every host-to-device copy of it. That set exists to spare a host array the fill of its device twin; for an argument whose home is the device the same direction is the copy back of its result. Without it the argument was never written, the body was dead code, and CPF rendered an empty entry whose empty state struct nvcc rejects (`too many initializer values` on `__cpf_state`). Keep the copy when the argument is stored on the device. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An inner access node that carries only empty memlets orders two nodes and reads nothing, so read_and_write_sets leaves its container out and the connector was pruned. apply then tried to remove the descriptor while the node still named it, and raised (npbench nbody's `softening` in CPF's prepare: `Cannot remove data descriptor softening: it is accessed by node softening`). Leave such a connector in place. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A GPU thread-block map tiled by 16 and clipped at a ceiling-valued bound has the extent -g + ceiling(Min(g + 15, ceiling(R**k) - 1)) + 1. The ceiling around the Min kept it from the Min(a, b) + c rule, so the extent stayed symbolic and conflicted with the kernel's gpu_block_size of 16 (npbench stockham_fft on GPU: "Both the gpu_block_size property and internal thread-block maps were defined with conflicting sizes"). ceiling is monotonic, so ceiling(Min(x, y)) is Min(ceiling(x), ceiling(y)); an argument that is a polynomial with integer coefficients in integer DaCe symbols is already an integer and keeps no ceiling. Rewritten that way, the extent bounds to 16. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The entry brace-initialized its state with the context pointer, which assumes gpu_context is the struct's first field. A unit with no device code has no such field, and nvcc rejected the empty struct's initializer as `too many initializer values` (Tactics' GPU ScatterConflictCheck kernels before fix 1). Value-initialize the state, then assign the gpu_context field by name, and only when the struct declares it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CUB deduces a scan's accumulator from op(init, input). An int8_t scan into int64_t with an int64_t initial value calls the operator on two types, which the one-type template operator() of cpf_cub_plus cannot deduce, and CUB's DispatchScan instantiated with AccumT=<error-type> (dbcsr on the GPU target). Each of the four functors gains an overload over two types that works in their common type. The one-type template is more specialized and still wins on equal types, so a same-type scan or reduction is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A megakernel's map spans threads (its range is nblk * block_size), and each thread runs its own grid-stride iterations. A thread-block map that appeared below it later (the default schedule of a map in a GPU_Device scope, or a library node expanded as a block collective) stopped AddThreadBlockMaps from tiling the kernel, so the launch took the thread range for the grid: 256 times more blocks than a cooperative launch holds (qe_vexx_k on the GPU target: "too many blocks in cooperative launch", grid 67584), or a block-size conflict. - SequentialMegakernelBodies, after ExpandLibraryNodes and before AddThreadBlockMaps, runs every thread-block map below an explicit_sync kernel sequentially in its thread. - in_kernel_block_implementation offers no block collective below an explicit_sync kernel (runs_per_thread), so a library node there takes a per-thread lowering instead of code that indexes the block's threads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dace-extended 1.0.6 (released 2026-11-29) shifts a loop such as range(1, T) to start at 0. With it, 7 unit tests and 1 integration test fail on this branch's parent 8d5a24e as well (split_doall, tree_view, comm_subsets, durbin costing, the middle loop value, quickstart's jacobi loops), and all of them pass on 1.0.5. There is no lock file, so CI took 1.0.6. The pin keeps this PR on the version its runs use (1.0.5 with spcl/dace#2811 applied) until Tactics is adapted to 1.0.6. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A Scope-lifetime array used in one state of a loop is placed at the SDFG entry so the loop does not reallocate it. The placement checked only that the size symbols are free in the SDFG. A free symbol can still be assigned inside the loop (read before written, `n = n + 8`), and then the entry allocation keeps the first size while later iterations use a larger one. QE cegterg hit this through Tactics: np.linalg.inv's `_pivots` scratch, `int[nbase_iter]`, was allocated once at kernel entry with nbase_iter = nvec, while the Davidson loop grows nbase_iter to 4 * nvec and LAPACKE_zgetrf writes that many pivots. The program aborted with `free(): invalid size`. The hoist now also requires that no size symbol is assigned on an interstate edge or iterated by a loop anywhere in the SDFG's tree. That scan moves from persistent_size_symbols into reassigned_symbols, so both placements use the same rule. Tests: tests/codegen/scope_allocation_hoisting_test.py gains test_size_reassigned_in_the_loop_is_not_hoisted (fails before: buf at loop depth 0) and test_size_reassigned_in_the_loop_numerics (corrupted the heap before). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A conditional without an else is placed for its one real arm, since the fall-through arm added for the missing else uses nothing. When that arm is the conditional's own sequential fallback (a branch holding a pinned loop), it is host code that copies in and out inside itself, so its host use is no entry location. Taken as one, the device-to-host copy sat before the conditional and the copy back after it, and every execution paid both, the arm taken or not. qe_vexx_k's `if okvan and tqr` scatter into `rhoc` moved 1.77 MB to the host and back once per band pair this way: about 0.9 GB per call at the norm-conserving configuration, which never takes the arm. The check is narrower than in_sequential_specialization_arm, which is also true for blocks nested in the arm: applied to the conditional inside the fallback loop's body, the loop lost its host locations and copied once per iteration. The new test covers both shapes (copies only inside the arm, none inside the loop) and, on a GPU, both flag values against NumPy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Problem. Fix. New Test. Results (Daint GH200, job 5511888, via Tactics on HPCAgent-Bench
|
Summary
This PR collects the DaCe
extendedfixes found while running Tactics' default pipeline on HPCAgent-Bench kernels over the weekend of 2026-11-28. Each fix is a separate commit with its own regression test and gets a section below. They were checked on top ofdace-extended1.0.5, the release Tactics pins, so they reach Tactics through the next release after 1.0.5.Fixes so far:
58d8cf7] OffloadToAccelerator drops the copy-back of a host-written device argument.a27570d] PruneConnectors prunes a connector that an ordering node still names, then cannot remove its descriptor.e9a7ca6]overapproximatedoes not bound a tile clipped inside aceiling, so a GPU thread-block size conflicts withgpu_block_size.9fe03b5] CPF's device entry binds the GPU context as the state's first initializer.3935704] CPF's CUB functors cannot deduce an accumulator over two operand types (int8_tscan intoint64_t).1702bed] A thread-block map below a megakernel leaves it untiled, and the cooperative launch takes its thread range for the grid.774047f] Scope allocation hoisting moves a buffer to the SDFG entry although its size symbol is assigned in the loop (QE cegterg heap overrun).1. OffloadToAccelerator drops the copy-back of a host-written device argument
Symptom. On the GPU target, every program whose kernels hold a
ScatterConflictCheckfails to build. nvcc rejects the CPF unit:too many initializer valueson<name>_state_t __cpf_state{&__cpf_context};. The programs are sparse_cholesky, qe_vexx_k, ilu0 and lulesh, ondace-extended1.0.4 and 1.0.5.Cause.
ScatterConflictCheckdeclares its flag and its scratch array ashost_connectors. When the node's operands are device arguments, which happens to a body offloaded with every argument in device memory, the pass computes those two in host twins. Both are also written in full before any read, so they are in_no_copy_in_needed.insert_copiesdropped every host-to-device copy of a name in that set. That filter is meant for the dead fill of a host array's device twin, but for an argument whose home is the device, the same direction is the copy back of its result. The arguments were never written, so the body became dead code, and CPF rendered an empty entry with an empty state struct.Fix. Keep the copy when the argument is stored on the device (
offload_to_accelerator.py,insert_copies).Tests.
tests/passes/offload_to_accelerator_test.py::test_a_host_pinned_result_is_copied_back_into_its_device_argument. It fails before the fix and passes after.tests/passes/offload_to_accelerator_test.pyandtests/transformations/gpu_transform_test.py: with and without the fix, the same 12 tests fail on a machine without a GPU,cupyor a CUDA compiler. Nothing else changes.4c639ab,dace-extended1.0.5 with this commit applied), the rendered units now carrygpu_contextand a body that runs the check and copies both results back: ilu0 (1 kernel), sparse_cholesky (2), qe_vexx_k (2). The nvcc build has not been run yet.Not in this commit. The pass still copies the two arguments device-to-host before the call. The copy is dead traffic but harmless.
2. PruneConnectors prunes a connector that an ordering node still names
Symptom. npbench nbody fails in CPF's
prepare, on both targets:ValueError: Cannot remove data descriptor softening: it is accessed by node softening in state state120(cpf.py:1135→prune_connectors.py:182→sdfg.remove_data).Cause. Inside the nested SDFG, the access node of
softeningcarries only empty memlets: it orders two nodes and reads nothing.read_and_write_setstherefore leaves the container out, so_get_prune_setspruned the connector, andapplythen could not remove the descriptor while the node still named it.Fix.
_get_prune_setskeeps a connector whose container has an access node in the body but is neither read nor written there. Every other pruning is unchanged: a container the body reads or writes is already inread_and_write_sets.Tests.
tests/transformations/prune_connectors_test.py::test_prune_connectors_keeps_a_connector_an_ordering_node_names. It fails before the fix (the sameValueError) and passes after.prune_connectors_test.pyandprune_connectors_subset_container_test.py: with and without the fix, the same 9 tests fail on a machine that cannot compile DaCe programs (CompilerConfigurationError). Nothing else changes.extcall_for0):apply_transformations_repeated(PruneConnectors)raises before the fix and validates after.4c639abondace-extended1.0.5 with fixes 1 and 2 applied: nbody on the CPU target builds all 8 kernels, each passes its own check, and the whole program is correct against the NumPy reference. On the GPU target,extcall_for0now renders; the GPU build has not been run.3.
overapproximatedoes not bound a tile clipped inside aceilingSymptom. npbench stockham_fft on the GPU target:
InferGPUGridAndBlockSizerefuses kernelsdoall16anddoall27withBoth the gpu_block_size property and internal thread-block maps were defined with conflicting sizes. The sizes it detects are[16, 16, 1]against[-g + ceiling(Min(g + 15, ceiling(R**k) - 1)) + 1, 16, 1], and similarly[16, 4, 8]fordoall27.Cause. The thread-block map is a 16-wide tile clipped at a ceiling-valued bound.
overapproximateboundsMin(a, b) + cbut not aMinwrapped in aceiling, so the extent stayed symbolic and compared unequal to the block size. The schedule itself is consistent: the bounded extent is exactly the block size.Fix.
ceilingis monotonic, soceiling(Min(x, y))equalsMin(ceiling(x), ceiling(y))._overapproximaterewrites it that way before theMinrule. An argument that is a polynomial with integer coefficients in integer-typed DaCe symbols (g + 15) is already an integer and keeps noceiling.Tests.
tests/symbolic_test.py::test_a_tile_clipped_by_a_ceiling_bound_overapproximates_to_its_full_tile. It fails before the fix and passes after; it also checks that a fractional argument still rounds up.tests/symbolic_test.py: 42 passed.4c639abondace-extended1.0.5 with fixes 1-3 applied: stockham_fft renders all 8 kernels on the GPU target.doall16launchesdim3(16, 16, 1)anddoall27launchesdim3(16, 4, 8), each matching itsgpu_block_size. The GPU build has not been run.4. CPF's device entry binds the GPU context as the state's first initializer
Symptom. This is the error fix 1 surfaced. nvcc reports
too many initializer valueson<name>_state_t __cpf_state{&__cpf_context};whenever a unit's state struct has no field at all.Cause.
device_entry_prologuebrace-initializes the state with the context pointer, which assumesgpu_contextis the struct's first field. A unit with no device code has no such field. The same assumption also breaks if another field comes first.Fix. Value-initialize the state (
__cpf_state{}), then assign__cpf_state.gpu_context = &__cpf_context;by name, and only when the struct declares the field.framecodepasseshas_contextfrom the state struct's fields.Tests.
tests/codegen/cpf/test_emission_cuda.py::test_a_device_entry_binds_its_context_by_nameand::test_a_device_entry_with_no_context_field_binds_none. Both fail before the change and pass after.tests/codegen/cpf: with and without the change, the same tests fail on a machine without a CUDA toolchain. The only other difference,test_loop_comment_fixes_2.py::test_a_gpu_fallback_arm_says_it_runs_on_the_host_and_what_it_copies, depends on the hash seed: it fails on the same seeds (2, 3, 4, 7 of 0-7) with and without the PR.5. CPF's CUB functors cannot deduce an accumulator over two operand types
Symptom. dbcsr on the GPU target: nvcc fails inside CUB's
DispatchScan<const int8_t*, int64_t*, cpf_cub_plus, ...>withAccumT=<error-type>.Cause. The unit calls
DeviceScan::ExclusiveScan(in: int8_t*, out: int64_t*, cpf_cub_plus(), init: int64_t). CUB deduces the accumulator fromop(init, input), which here isop(int64_t, int8_t).cpf_cub_plus::operator()istemplate <typename T> T (const T&, const T&), andTcannot be deduced from two different types.Fix.
cub_functorbuilds all four functors (plus,multiplies,minimum,maximum). Each one gains an overload over two types that works instd::common_type_t<T, U>. The one-type template is more specialized and still wins on equal types, so a same-type scan or reduction is unchanged.Tests.
tests/codegen/cpf/test_emission_cuda.py::test_a_cub_functor_deduces_an_accumulator_over_two_types, for each of the four functors. It compiles the emitted functor with the host C++ compiler and asserts the deduction CUB makes:invoke_result_t<f, int64_t, int8_t>isint64_t,(int8_t, int8_t)staysint8_t, and(float, double)isdouble. Before the fix the host compiler reports the same deduction failure; after it, all four pass.tests/codegen/cpfandtests/passes/offload_to_accelerator_test.py: with and without the fix, the same tests fail on a machine without a GPU toolchain, apart from the new tests and the hash-seed-dependent comment test noted in fix 4.4c639abondace-extended1.0.5 with fixes 1-5 applied: dbcsr renders all 12 GPU kernels, and both scan units carry the mixed overload. The nvcc build has not been run yet.6. A thread-block map below a megakernel leaves it untiled, and the launch takes its thread range for the grid
Symptom. qe_vexx_k on the GPU target: the whole program aborts with
extcall_doall129_..._megakernel_0 launch failed (grid 67584,1,1 block 256,1,1): too many blocks in cooperative launch. A smaller program with aTransposeper iteration in one of two merged kernels fails instead atInferGPUGridAndBlockSizewithconflicting sizes ([256, 1, 1], [16, 4, 8]). Both happen on baseef3ad61too; they are not caused by fixes 1-5.Cause.
launch_cooperativelygives the megakernel map a range in threads,0:nblk*256, and each thread runs its own grid-stride iterations.ComputePersistentKernelRangesizesnblkas the resident blocks (264 on a GH200). NormallyAddThreadBlockMapstiles that map and the grid isnblk. But a thread-block map can appear below the megakernel later: a map's default schedule in aGPU_Devicescope isGPU_ThreadBlock, and a library node inside may expand as a block collective (qe_vexx_k'scopy_psi_to_tgbecamecopy_psi_to_tg_lanes, 0:256). With such a map below it,AddThreadBlockMapsleaves the megakernel untiled, andInferGPUGridAndBlockSizetakes the thread range for the grid:256 * nblk= 67584 blocks. DaCe's owntest_a_cooperative_kernel_launches_cooperatively_and_sizes_its_gridpasses only because its body has no such map.Fix. A megakernel (
explicit_sync: its grid is final) has no thread-block level, so nothing below it may take one.SequentialMegakernelBodies, placed afterExpandLibraryNodesand beforeAddThreadBlockMaps, runs every thread-block map below anexplicit_synckernel sequentially in its thread.in_kernel_block_implementationoffers no block collective below such a kernel (runs_per_thread), so a library node there takes a per-thread lowering instead of code that indexes the block's threads.Tests.
tests/transformations/megakernel_test.py::test_a_megakernel_body_keeps_no_thread_block_map_and_launches_its_resident_blocks. It renders the two-kernelTransposeprogram and asserts one cooperative launch with block 256 and gridnblk. Without the pass it fails with the block-size conflict.::test_a_library_node_in_a_megakernel_takes_no_block_collective.tests/codegen/cpf, offload, the GPU specialization pass tests, and the in-kernel block collective library tests), with and without this commit on the same branch: no test fails only with the commit. The only difference is the hash-seed-dependent comment test of fix 4. The GPU-run tests in these files were not run (no GPU).extcall_doall129, and Tactics8d5a24eon dace-extended 1.0.5 with fixes 1-6: the cooperative launch isdim3(tmp1)withtmp1= the resident blocks. The run on a GPU has not happened yet.7. Scope allocation hoisting keeps the first size of a buffer the loop resizes
Symptom. QE cegterg (
qe_cegterg) through Tactics aborts in its whole-program run on both targets:free(): invalid size(CPU) andfree(): invalid next size (fast)(GPU target, whose Davidson kernel stays on the CPU). Reproduced in a Linux container on Tactics v0.1.4 withdace-extended1.0.5. Under gdb the abort is thedelete[]ofpivotsat the end of the kernelextcall_for42.Cause.
np.linalg.inv's expansion sizes its_pivotsscratchint[nbase_iter], Scope lifetime. Its only use is one state inside the Davidson loop, sodetermine_allocation_lifetimeplaces the allocation at the SDFG entry so the loop does not reallocate it (framecode.py, the branch that keepsdesc.lifetimeScope and moves only the placement). The placement checked only that the size symbols are free in the SDFG.nbase_iteris free, a kernel argument, but the loop also assigns it (nbase_iter = nbase_iter + notcnv_iter, growing fromnvecto4 * nvec). So the buffer got the entry size, andLAPACKE_zgetrf/zgetriwrote up to four times as many pivots into it. Builds whose heap layout differs run past the overrun silently.Fix. The hoist also requires that no size symbol is assigned on an interstate edge, or iterated by a loop, anywhere in the SDFG's tree. That scan moves out of
persistent_size_symbolsintoreassigned_symbols(transformation/passes/persistent_transients.py), so the Persistent and the hoisted-Scope placements use one rule.Tests.
tests/codegen/scope_allocation_hoisting_test.py::test_size_reassigned_in_the_loop_is_not_hoisted(a heap buffer sized by a freenthat an interstate edge in the loop grows). It fails before the fix (the buffer is allocated at loop depth 0) and passes after.::test_size_reassigned_in_the_loop_numerics. Before the fix it corrupts the heap (corrupted double-linked listat exit); after, it passes cleanly.tests/codegen(*alloc*,*transient*,scope_allocation_hoisting,symbol_dependent_alloc_in_conditional,view_allocation*),tests/codegen/cpf,tests/passes/persistent_transients_test.py, and the LAPACK andlinalglibrary tests, with and without this commit, on CPU in a Linux arm64 container: the same 11 tests fail on both (8 need MKL, 3 CPF scan emission tests), and 2 more pass with the commit, which are the new tests.qe_cegterg(CPU target, preset S, container):pivotsis now allocated inside the loop after the subspace size is set and freed in the same iteration. On v0.1.4 with this commit the whole program runs to the end without the abort; on Working PR from 2026-11-28: fixes from the default pipeline and agent runs (base for the next experiments) tactics#1237a40c72too, also under gdb. The output was not graded: the container cannot run the bench's reference.Checked on a GPU (CSCS Daint, GH200)
Tactics
8d5a24edrivesdace-extended1.0.5 with this PR's commits applied, at preset S. The bench graded each program against its own reference.yis still wrong, under investigation and not attributed to this PR yetBefore these fixes, none of these programs built on the GPU target.
ef3ad61. The same 15 tests failed on both, all for want of CuPy in that environment, and 9 more passed on this branch, which are the new tests.🤖 Generated with Claude Code