Summary
On clean master at bc8e107fb5bc755b45e7cfe6f1a5cf73b544e45c, the OptimizationBase QA group fails its JET typo analysis with two reports at lib/OptimizationBase/src/OptimizationDIExt.jl:112:
local variable `_prep_grad` is not defined: _prep_grad
local variable `_prep_grad` may be undefined: _prep_grad::DifferentiationInterface.PullbackGradientPrep
The failure was introduced by e254f94 from #1283. That commit added _prep_grad_fg = g == true ? _prep_grad : ..., but _prep_grad is assigned only inside the earlier grad = if g == true && f.grad === nothing expression. JET therefore sees an undefined or conditionally defined local.
Reproducer
From a clean checkout of master:
OPTIMIZATION_TEST_GROUP=QA julia +1.12 --project=lib/OptimizationBase -e 'using Pkg; Pkg.test(; allow_reresolve=true)'
Resolved versions included:
OptimizationBase v5.3.0 (local checkout)
JET v0.11.6
SciMLBase v3.45.0
SciMLTesting v2.8.0
The result was:
Test Summary: | Pass Fail Broken Total
QA | 19 1 1 21
ERROR: Some tests did not pass: 19 passed, 1 failed, 0 errored, 1 broken.
A direct JET check confirmed the history boundary with the same dependency set:
98ecd8750c0c4ae8a5c79d278b103a2dc17ae38d (parent of the introducing commit): 0 JET reports.
e254f9466b4bfe622500cc4a20b08e4d8357d7a8: 2 JET reports.
- Current
master bc8e107fb5bc755b45e7cfe6f1a5cf73b544e45c: 2 JET reports.
Narrow fix tested locally
Moving the prepare_gradient call before construction of grad, guarded by whether either generated grad or generated fg! needs it, and then reusing that defined value in both branches removed both JET reports without preparing twice.
Verification on patched current master:
JET report count = 0
Test Summary: | Pass Total Time
AD | 785 785 7m29.5s
Testing OptimizationBase tests passed
The edited Julia source also passed julia +1.12 -m Runic --check lib/OptimizationBase/src/OptimizationDIExt.jl and git diff --check.
Version information
Julia Version 1.12.6
Commit 15346901f00 (2026-04-09 19:20 UTC)
Official https://julialang.org release
OS: Linux (x86_64-linux-gnu)
CPU: AMD EPYC 7502 32-Core Processor
WORD_SIZE: 64
LLVM: libLLVM-18.1.7 (ORCJIT, znver2)
Threads: 1 default, 1 interactive, 1 GC
Summary
On clean
masteratbc8e107fb5bc755b45e7cfe6f1a5cf73b544e45c, the OptimizationBase QA group fails its JET typo analysis with two reports atlib/OptimizationBase/src/OptimizationDIExt.jl:112:The failure was introduced by e254f94 from #1283. That commit added
_prep_grad_fg = g == true ? _prep_grad : ..., but_prep_gradis assigned only inside the earliergrad = if g == true && f.grad === nothingexpression. JET therefore sees an undefined or conditionally defined local.Reproducer
From a clean checkout of
master:OPTIMIZATION_TEST_GROUP=QA julia +1.12 --project=lib/OptimizationBase -e 'using Pkg; Pkg.test(; allow_reresolve=true)'Resolved versions included:
The result was:
A direct JET check confirmed the history boundary with the same dependency set:
98ecd8750c0c4ae8a5c79d278b103a2dc17ae38d(parent of the introducing commit): 0 JET reports.e254f9466b4bfe622500cc4a20b08e4d8357d7a8: 2 JET reports.masterbc8e107fb5bc755b45e7cfe6f1a5cf73b544e45c: 2 JET reports.Narrow fix tested locally
Moving the
prepare_gradientcall before construction ofgrad, guarded by whether either generatedgrador generatedfg!needs it, and then reusing that defined value in both branches removed both JET reports without preparing twice.Verification on patched current
master:The edited Julia source also passed
julia +1.12 -m Runic --check lib/OptimizationBase/src/OptimizationDIExt.jlandgit diff --check.Version information