Skip to content

Relax Zygote compat to allow 0.6.69+ and 0.7.x#309

Merged
ChrisRackauckas merged 1 commit intoSciML:masterfrom
ChrisRackauckas-Claude:fix-zygote-compat
Jan 26, 2026
Merged

Relax Zygote compat to allow 0.6.69+ and 0.7.x#309
ChrisRackauckas merged 1 commit intoSciML:masterfrom
ChrisRackauckas-Claude:fix-zygote-compat

Conversation

@ChrisRackauckas-Claude
Copy link
Contributor

Summary

Relaxes the Zygote compat from "0.7.10" (strict) back to "0.6.69, 0.7" (which was the compat in v4.6.1).

Problem

The strict Zygote = "0.7.10" compat is causing issues with downstream packages like NeuralPDE.jl. When NeuralPDE resolves packages, it gets Integrals ≥4.7.0 which forces Zygote 0.7.10, which then triggers a bug in Julia's Base.Meta.partially_inline! function.

Root Cause

There's a typo bug in Julia's base/meta.jl (introduced in commit b845695e from June 2018) where line 412 references spvals instead of static_param_values:

# Line 412 - BUG: spvals is undefined
@assert !isa(type_signature, UnionAll) || !isempty(spvals)

# Compare to line 421 - Correct:  
@assert !isa(type_signature, UnionAll) || !isempty(static_param_values)

This bug gets triggered when Zygote/IRTools calls Base.Meta.partially_inline! on code containing @cfunction with type parameters (like Cubature.jl's integrands(d::D, ...) where {D} function).

Why This Helps

By relaxing the Zygote compat, downstream packages can potentially resolve to older Zygote versions that may use different code paths that don't trigger the Julia bug. Even if it doesn't fully fix the issue, it gives more flexibility for workarounds.

Test plan

  • CI passes
  • Downstream packages (NeuralPDE.jl) can resolve with broader Zygote versions

🤖 Generated with Claude Code

The strict Zygote = "0.7.10" compat was causing issues with downstream
packages like NeuralPDE.jl. There is a bug in Julia's Base.Meta.partially_inline!
function (a typo where `spvals` should be `static_param_values`) that gets
triggered when Zygote differentiates through functions using @cfunction with
type parameters (like Cubature.jl's integrands function).

By relaxing the Zygote compat to allow older versions, downstream packages
can resolve to Zygote versions that may avoid triggering this Julia bug
through different code paths.

This reverts the Zygote compat to what it was in Integrals v4.6.1.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
@ChrisRackauckas ChrisRackauckas merged commit b71e97e into SciML:master Jan 26, 2026
10 checks passed
ChrisRackauckas-Claude pushed a commit to ChrisRackauckas-Claude/NeuralPDE.jl that referenced this pull request Jan 26, 2026
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>
ChrisRackauckas-Claude pushed a commit to ChrisRackauckas-Claude/NeuralPDE.jl that referenced this pull request Jan 26, 2026
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>
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.

3 participants