Cap Integrals compat to 4.5-4.6 to fix Zygote/Cubature CI failures#1020
Cap Integrals compat to 4.5-4.6 to fix Zygote/Cubature CI failures#1020ChrisRackauckas-Claude wants to merge 5 commits intoSciML:masterfrom
Conversation
Integrals.jl versions 4.7.0-4.9.0 have a strict `Zygote = "0.7.10"` compat which forces resolution to Zygote 0.7.10. This triggers a bug in Julia's `Base.Meta.partially_inline!` function when Zygote differentiates through Cubature's `@cfunction` with type parameters, causing `UndefVarError: spvals not defined in Base.Meta` errors. This caps Integrals to 4.6.x which has a broader Zygote compat (`"0.6.69, 0.7"`) allowing the resolver to pick Zygote versions that may avoid the bug. A fix has been merged to Integrals.jl (SciML/Integrals.jl#309) that relaxes the Zygote compat. Once a new Integrals version is released with that fix, this compat can be updated to allow newer versions again. Related: - Integrals.jl fix: SciML/Integrals.jl#309 - Julia bug: typo in base/meta.jl line 412 (spvals should be static_param_values) Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Integrals.jl v4.9.1 has been released with the relaxed Zygote compat (SciML/Integrals.jl#309), so we can now allow that version. Compat now allows: - 4.5.x - 4.6.x (original safe range with broad Zygote compat) - 4.9.1+ (new release with fix) Versions 4.7.0 - 4.9.0 are still excluded as they have strict Zygote = "0.7.10". Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
|
Updated: Integrals.jl v4.9.1 has been released with the fix, so the compat is now |
Investigation UpdateThe Integrals compat cap to 4.9.1 (which has relaxed Zygote compat) does not fix the issue. The Root Cause AnalysisThe bug is a typo in Julia's base/meta.jl line 412: # Bug (line 412):
@assert \!isa(type_signature, UnionAll) || \!isempty(spvals)
# Correct (line 421 shows the right variable):
@assert \!isa(type_signature, UnionAll) || \!isempty(static_param_values)This typo has existed since June 2018 (commit b845695e) and affects all Julia versions from 1.6 to 1.12+. Trigger Conditions
The specific trigger is Fix Options
RecommendationShould I file a bug report/PR to Julia to fix the base/meta.jl typo? This is the proper long-term fix. In the meantime, this PR's compat changes are insufficient to fix CI. We may need to mark the affected tests as broken until Julia is fixed. |
Version Cap Investigation CompleteCapping Zygote does NOT work due to dependency constraints:
There's no valid version combination that avoids both issues. ConclusionThe fix must come from upstream:
I recommend:
|
This allows earlier Zygote 0.7.x versions to be used. The strict 0.7.10 requirement was preventing NeuralPDE from using older Zygote versions to work around a Julia base bug that causes `spvals not defined in Base.Meta` errors when differentiating through Cubature's `integrands` function. See: SciML/NeuralPDE.jl#1020 Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Zygote 0.7.10 triggers a typo bug in Julia's base/meta.jl (line 412) where `spvals` is used instead of `static_param_values`. This causes an "UndefVarError: `spvals` not defined in Base.Meta" error when differentiating through @cfunction with type parameters. The bug is triggered when NeuralPDE uses QuadratureTraining with Cubature.jl, which uses @cfunction with type parameters in its integration routines. This PR caps Zygote to 0.6.71 and 0.7.0-0.7.9 to avoid the buggy version. Related PRs to relax Zygote constraints in upstream packages: - SciMLBase.jl PR #1220 (merged) - RecursiveArrayTools.jl PR SciML#532 (pending) Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Update: Changing approach to cap Zygote directlyI've updated this PR to cap Zygote to Why the change?The root cause is a typo bug in Julia's DependenciesThis PR requires relaxing Zygote constraints in upstream packages:
Once RecursiveArrayTools is updated, this PR should be able to resolve properly with:
🤖 Generated with Claude Code |
- Bump Optimization from "4, 5" to "5.1" - Bump OptimizationOptimisers from "0.3" to "0.3.14" This ensures we get: - OptimizationBase 4.x (with proper SciMLBase compat) - SciMLBase 2.135+ (with relaxed Zygote compat) - RecursiveArrayTools 3.46+ (with relaxed Zygote compat) - Zygote 0.7.9 (avoiding the Julia base bug) Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Update: Resolution now works with capped ZygoteThe RecursiveArrayTools PR #532 has been merged and v3.46.0 released. This PR now resolves correctly with:
I also updated the Optimization/OptimizationOptimisers compat to require newer versions that have proper SciMLBase/Zygote constraints:
NeuralPDE precompiles and loads successfully with this configuration. 🤖 Generated with Claude Code |
The spvals typo bug in Julia's base/meta.jl (line 533) causes test failures when Zygote differentiates through Cubature's @cfunction with type parameters. Since this is a Julia base bug affecting all Zygote 0.7.x versions, switching to HCubatureJL (pure Julia) avoids the problematic code path. Affected tests: - Test Heterogeneous ODE (QuadratureTraining) - PDE II: 2D Poisson (CubatureJLp test) - PDE IV: System of PDEs - PDE V: 2D Wave Equation - NNPDE: Translating from Flux - Neural Adapter: 2D Poisson - ODE Complex Numbers (expected error test) - Empty boundary condition test Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Updated approachThe original approach of capping Zygote/Integrals versions didn't work because the New solutionReplaced
Root causeThe bug is a typo in Julia's base/meta.jl line 533: @assert !isa(type_signature, UnionAll) || !isempty(spvals) # BUG: spvals undefinedShould be: @assert !isa(type_signature, UnionAll) || !isempty(static_param_values)This is triggered when Zygote/IRTools differentiates through code using Changes in this PR
The upstream Julia bug should eventually be reported/fixed, but this workaround allows NeuralPDE tests to pass in the meantime. |
CubatureJLh uses Cubature.jl which has `@cfunction` with type parameters
(`integrands(d::D, ...) where {D}`). When Zygote differentiates through
this code path, it triggers a typo bug in Julia's base/meta.jl where
`spvals` is used instead of `static_param_values`, causing
`UndefVarError: spvals not defined in Base.Meta`.
HCubatureJL uses HCubature.jl (pure Julia) which does not use @cfunction
with type parameters, avoiding the buggy code path entirely.
Changes:
- src/discretize.jl: Use HCubatureJL() for Integral() term evaluation
- src/training_strategies.jl: Default QuadratureTraining to HCubatureJL()
- src/NeuralPDE.jl: Import HCubatureJL instead of CubatureJLh
- Project.toml: Remove Cubature dependency
- test/NNPDE_tests.jl: Replace all CubatureJLh/CubatureJLp with HCubatureJL
- test/additional_loss_tests.jl: Remove unused Cubature import
- docs/: Remove Cubature references
Related: Julia base bug (base/meta.jl line 412, commit b845695e from 2018)
Closes: SciML#1020
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Found by claude-code debugging a random zygote issue: SciML/NeuralPDE.jl#1020 (comment). `spvals` just doesn't exist within this function. This issue has apparently existed since Julia 1.6
Found by claude-code debugging a random zygote issue: SciML/NeuralPDE.jl#1020 (comment). `spvals` just doesn't exist within this function. This issue has apparently existed since Julia 1.6
Found by claude-code debugging a random zygote issue: SciML/NeuralPDE.jl#1020 (comment). `spvals` just doesn't exist within this function. This issue has apparently existed since Julia 1.6
Found by claude-code debugging a random zygote issue: SciML/NeuralPDE.jl#1020 (comment). `spvals` just doesn't exist within this function. This issue has apparently existed since Julia 1.6 (cherry picked from commit 94e72bb)
Summary
Caps Integrals compat from
"4.5"to"4.5 - 4.6"to avoid Integrals versions 4.7.0-4.9.0 which have a strictZygote = "0.7.10"requirement.Problem
Tests using
QuadratureTraining(NeuralAdapter, NNPDE2, IntegroDiff, etc.) fail with:This is caused by:
Zygote = "0.7.10"strictlyintegrands(d::D, ...) where {D}function (which uses@cfunction)Base.Meta.partially_inline!which has a typo bug in Julia (line 412 usesspvalsinstead ofstatic_param_values)Solution
Cap Integrals to 4.6.x which has broader Zygote compat (
"0.6.69, 0.7"), allowing resolution to Zygote versions that may avoid triggering the bug.Follow-up
A fix has been merged to Integrals.jl: SciML/Integrals.jl#309
Once a new Integrals version is released with that fix (4.9.1 or 4.10.0), this compat can be updated to:
Test plan
spvalserror🤖 Generated with Claude Code