Skip to content

Fix EnsembleGPUArray continuous callback event detection on GPU arrays - #503

Merged
ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:fix-ensemblegpuarray-callback-events
Aug 28, 2026
Merged

ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:fix-ensemblegpuarray-callback-events

Conversation

@ChrisRackauckas-Claude

@ChrisRackauckas-Claude ChrisRackauckas-Claude commented Aug 26, 2026 •

Copy link
Copy Markdown
Member

What changed and why

Preserve the positive/negative direction mask when EnsembleGPUArray turns a scalar ContinuousCallback into a VectorContinuousCallback, and dispatch affect! for +1 and affect_neg! for -1. The branch now depends on the public generic DiffEqBase.findall_events! fallback added by SciML/OrdinaryDiffEq.jl#4398 instead of extending a non-public dependency API inside DiffEqGPU.

The callback mask is copied to the device before the kernel launches, so the generated callback works with device-backed ensemble state without scalar indexing.

This PR should be ignored until reviewed by @ChrisRackauckas.

Failing before

On the unfixed callback kernel, the direction regression expected [11, -8, 3] after applying positive, negative, and inactive events but observed [-9, 12, 3]: the positive and negative hooks were reversed (0 passed, 1 failed).

The prerequisite's focused generic-array regression also failed before SciML/OrdinaryDiffEq.jl#4398 with a MethodError from findall_events! (0 passed, 1 failed, 1 errored).

Passing after

After rebasing over current DiffEqGPU master (a07991d, release 3.19.0), the project manifest resolved the locally developed DiffEqBase prerequisite and these exact commands passed:

GROUP=JLArrays julia +release --project -e 'using Pkg; Pkg.test()'

GPU Kernelized DAE Mass Matrix                 30/30
GPU Kernelized Non Stiff ODE Regression       48/48
GPU Kernelized Non Stiff ODE DiscreteCallback 78/78
GPU Kernelized Stiff ODE Regression           75/75
GPU Kernelized Stiff ODE DiscreteCallback     46/46
GPU Kernelized FiniteDiff tests                 5/5
GPU Kernelized Auto-Conversion tests            6/6
GPU callback event detection                    1/1
Testing DiffEqGPU tests passed
GROUP=QA julia +release --project -e 'using Pkg; Pkg.test()'

Quality Assurance 27/27
JET static analysis 75/75
Testing DiffEqGPU tests passed

The following also exited with code 0 and no output:

julia +release -m Runic --check src/ensemblegpuarray/callbacks.jl src/ensemblegpuarray/kernels.jl test/callback_event_detection.jl test/runtests.jl
typos --force-exclude --format brief Project.toml src/ensemblegpuarray/callbacks.jl src/ensemblegpuarray/kernels.jl test/callback_event_detection.jl test/runtests.jl
git diff --check upstream/master...HEAD

Not verified locally

CUDA execution was not run because this machine has no usable CUDA device. The CPU-backed JLArrays group exercises the callback generation and kernel direction dispatch; the CUDA workflow must verify real device execution.

Dependency

🤖 Generated with Codex CLI 0.150.1 (model: unknown; session: local session ID 01a0441e-3d2f-7170-ab6e-58ef72975a9f).

Use DiffEqBase's public generic event-detection fallback for device-backed sign caches and require the release that provides it. Preserve positive and negative continuous-callback directions separately when generating and dispatching EnsembleGPUArray callbacks.

Add a JLArrays regression that exercises both event directions through the generated vector callback.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Codex <[email protected]>
Agent-Harness: Codex CLI 0.150.1
Agent-Model: unknown
Agent-Session: local session ID 01a0441e-3d2f-7170-ab6e-58ef72975a9f
@ChrisRackauckas-Claude
ChrisRackauckas-Claude force-pushed the fix-ensemblegpuarray-callback-events branch from ff781cb to 8ae7724 Compare August 27, 2026 21:37
@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review August 28, 2026 01:48
@ChrisRackauckas
ChrisRackauckas merged commit 1afc6a8 into SciML:master Aug 28, 2026
7 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants