Adaptive kernel: ContinuousCallback just before a tstop suppresses the tstop's DiscreteCallback

Aperta
#558 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Ambito
backend

Direzione di ricerca

Run the CPU reproducer and inspect step! together with change_t_via_interpolation! in src/ensemblegpukernel/integrators/integrator_utils.jl. Trace how the tstop index is consumed when the continuous event rewinds time, then add a regression test based on the shown case. Done means the tstop DiscreteCallback fires and each trajectory ends near 11.25.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

In an adaptive EnsembleGPUKernel solve, a DiscreteCallback keyed to a tstop is silently skipped when a ContinuousCallback fires shortly before that stop.

Reproducer (CPU backend, no GPU needed):

using DiffEqGPU, SciMLBase, StaticArrays, KernelAbstractions, Test
cc = ContinuousCallback((u, t, i) -> t - 0.8749f0, i -> (i.u += SVector(1f0, 1f0)); save_positions = (false, false))
dc = DiscreteCallback((u, t, i) -> t == 0.875f0, i -> (i.u += SVector(10f0, 10f0)); save_positions = (false, false))
prob = ODEProblem{false}((u, p, t) -> SVector(1f0, 1f0), SVector(0f0, 0f0), (0.75f0, 1f0))
sol = solve(EnsembleProblem(prob), GPUTsit5(), EnsembleGPUKernel(CPU(), 0.0); trajectories = 2,
    adaptive = true, dt = 0.0625f0, tstops = Float32[0.8125, 0.875, 0.9375],
    callback = CallbackSet(cc, dc), merge_callbacks = true, abstol = 1f-9, reltol = 1f-6,
    save_everystep = false)
@test all(s -> s.u[end] ≈ SVector(11.25f0, 11.25f0), sol.u)   # 0 + 0.25 + 1 (cc) + 10 (dc)

Julia 1.12.7, final state (expected 11.25):

revision final state
b3d6a17 (before https://github.com/SciML/DiffEqGPU.jl/pull/544) 1.2499999
master 8118688 1.25
https://github.com/SciML/DiffEqGPU.jl/pull/556 head 1.25

The continuous event fires, but the tstop callback does not. The review that found this suggests, from reading the source, that the tstop index is consumed in step! before the continuous callback rewinds time to the event (change_t_via_interpolation! in src/ensemblegpukernel/integrators/integrator_utils.jl). The stop at 0.875 is then never revisited. That is not confirmed by a bisect or a fix.

Found during review of https://github.com/SciML/DiffEqGPU.jl/pull/556, which does not change this behaviour.

🤖 Generated with Claude Code (model: claude-opus-5-5[1m])

https://claude.ai/code/session_01SJfy3ez7u4CqvAerKrT5np

Lingua principale
Julia
Stelle
331
Fork
43
Merge medio
1g 20h
PR unite (30g)
10

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di SciML/DiffEqGPU.jl

Tutte le issue di SciML/DiffEqGPU.jl

Issue simili

Altre issue su Julia

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.