Skip to content

Matrix ODE gradient tests fail with all reverse-mode AD backends #1330

@ChrisRackauckas-Claude

Description

@ChrisRackauckas-Claude

Description

The Matrix Multiplication ODE gradient tests fail with all reverse-mode AD backends (ReverseDiff, Tracker, Zygote) on all Julia versions.

Test Location

test/concrete_solve_derivatives.jl - "Matrix Multiplication ODE" testset

Current Status

Tests are marked as @test_broken in the test suite.

Test Code

@testset "Matrix Multiplication ODE" begin
    solvealg_test = Tsit5()
    sensealg_test = InterpolatingAdjoint()
    tspan = (0.0, 1.0)
    u0_mat = rand(4, 8)
    p0 = rand(16)
    f_aug(u, p, t) = reshape(p, 4, 4) * u

    function loss_mat(p)
        prob = ODEProblem(f_aug, u0_mat, tspan, p; alg = solvealg_test, sensealg = sensealg_test)
        sol = solve(prob)
        return sum(sol[:, :, end])
    end

    # These tests fail for ReverseDiff, Tracker, and Zygote
    res2 = grad_fn(loss_mat, p0)
    res4 = grad_fn(loss_mat2, p0)
    @test res2  res4 atol = 1.0e-10
    @test res2  ForwardDiff.gradient(loss_mat, p0) atol = 1.0e-10
end

Related

This issue was identified during the AD backend test refactoring in PR #1322.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions