dfdx/Umlaut.jl

Tests fail on 1.11

Opened this issue · 2 comments

tape: Test Failed at /home/pkgeval/.julia/packages/Umlaut/wNZyO/test/test_tape.jl:111
  Expression: length(tape) == 5
   Evaluated: 7 == 5

Stacktrace:
 [1] macro expansion
   @ /opt/julia/share/julia/stdlib/v1.11/Test/src/Test.jl:679 [inlined]
 [2] macro expansion
   @ ~/.julia/packages/Umlaut/wNZyO/test/test_tape.jl:111 [inlined]
 [3] macro expansion
   @ /opt/julia/share/julia/stdlib/v1.11/Test/src/Test.jl:1700 [inlined]
 [4] top-level scope
   @ ~/.julia/packages/Umlaut/wNZyO/test/test_tape.jl:6
tape: Error During Test at /home/pkgeval/.julia/packages/Umlaut/wNZyO/test/test_tape.jl:112
  Test threw exception
  Expression: (tape[V(3)]).fn == (*)
  type Constant has no field fn
  Stacktrace:
   [1] getproperty(op::Umlaut.AbstractOp, f::Symbol)
     @ Umlaut ~/.julia/packages/Umlaut/wNZyO/src/tape.jl:96
   [2] macro expansion
     @ /opt/julia/share/julia/stdlib/v1.11/Test/src/Test.jl:676 [inlined]
   [3] macro expansion
     @ ~/.julia/packages/Umlaut/wNZyO/test/test_tape.jl:112 [inlined]
   [4] macro expansion
     @ /opt/julia/share/julia/stdlib/v1.11/Test/src/Test.jl:1700 [inlined]
   [5] top-level scope
     @ ~/.julia/packages/Umlaut/wNZyO/test/test_tape.jl:6
tape: Error During Test at /home/pkgeval/.julia/packages/Umlaut/wNZyO/test/test_tape.jl:113
  Test threw exception
  Expression: (tape[V(4)]).fn == (-)
  type Constant has no field fn
  Stacktrace:
   [1] getproperty(op::Umlaut.AbstractOp, f::Symbol)
     @ Umlaut ~/.julia/packages/Umlaut/wNZyO/src/tape.jl:96
   [2] macro expansion
     @ /opt/julia/share/julia/stdlib/v1.11/Test/src/Test.jl:676 [inlined]
   [3] macro expansion
     @ ~/.julia/packages/Umlaut/wNZyO/test/test_tape.jl:113 [inlined]
   [4] macro expansion
     @ /opt/julia/share/julia/stdlib/v1.11/Test/src/Test.jl:1700 [inlined]
   [5] top-level scope
     @ ~/.julia/packages/Umlaut/wNZyO/test/test_tape.jl:6
Test Summary: | Pass  Fail  Error  Total   Time
tape          |   30     1      2     33  14.6s
ERROR: LoadError: Some tests did not pass: 30 passed, 1 failed, 2 errored, 0 broken.
in expression starting at /home/pkgeval/.julia/packages/Umlaut/wNZyO/test/test_tape.jl:4
in expression starting at /home/pkgeval/.julia/packages/Umlaut/wNZyO/test/runtests.jl:6
dfdx commented

TLDR: you can safely ignore this test, I will fix it once Julia 1.11 is officially released.

Thanks for reporting. These tests, as well as some tests in test_trace.jl, are sensitive to the structure of the generated tape, which in turn to the structure of the IR code generated by Julia. In specific case, I see that the IR for the tested function g() in Julia 1.11 is:

1 1%1 = Main.:+::Core.Const(+)                                                                 │
  │   %2 = Main.f(_2)::Any                                                                        │
  │   %3 = (%1)(%2, 5)::Any                                                                       │
  └──      return %3 

Note %1 = Main.:+::Core.Const(+) line. In earlier versions, Julia would not add a separate constant node for +, but instead use it in the method invocation directly. In fact, I don't really understand the logic behind this constant node, but I see that it's reproducible in other similar examples:

julia> getcode(x -> 2x % 1, (Float64,))
1 1%1 = Main.:%::Core.Const(rem)                                                               │
  │   %2 = (2 * _2)::Float64                                                                      │
  │   %3 = (%1)(%2, 1)::Float64                                                                   │
  └──      return %3                                                                              │
                                                                                                   

julia> getcode(x -> 2x + 3x, (Float64,))
1 1%1 = Main.:+::Core.Const(+)                                                                 │
  │   %2 = (2 * _2)::Float64                                                                      │
  │   %3 = (3 * _2)::Float64                                                                      │
  │   %4 = (%1)(%2, %3)::Float64                                                                  │
  └──      return %4                                                                              │
                                                                                                   

julia> getcode(x -> 2x * 3x, (Float64,))
1 1%1 = Main.:*::Core.Const(*)                                                                 │
  │   %2 = (2 * _2)::Float64                                                                      │
  │   %3 = (3 * _2)::Float64                                                                      │
  │   %4 = (%1)(%2, %3)::Float64                                                                  │
  └──      return %4  

Good news is that the generated tape is still valid. So the simplest fix is to adapt the tests to account for the difference between v1.10 and v1.11. The problem is that v1.11 is still marked as beta and may change its internal implementation in the nearest time, as it already happened in the past. Thus if it's not something that breaks your workflow, I'd prefer to postpone refactoring of the tests until the release.

dfdx commented

(Although you may be more informed about the possible changes, in which case don't hesitate to propose a better action plan)