OptimalControl.jl icon indicating copy to clipboard operation
OptimalControl.jl copied to clipboard

[Dev] Add ExaModels unit tests

Open ocots opened this issue 7 months ago • 7 comments

@PierreMartinon There are no unit tests with ExaModels.

[!NOTE] Maybe update the direct unit tests.

ocots avatar Jun 27 '25 15:06 ocots

@ocots @jbcaillau More related maybe to the GPU case, but we can use different test sets by passing arguments to the runtest action in the workflow yaml file (here Moonshot.yml):

- uses: julia-actions/julia-runtest@v1
        with:
          test_args: 'GPU'

and recover them in runtest.jl

@testset verbose = true showtiming = true "Test CTDirect" begin
    if "GPU" in ARGS
        # GPU tests only (moonshot workflow)
        include("test_gpu.jl")
    else
        # CPU: run all scripts in subfolder suite/
        include.(filter(contains(r".jl$"), readdir("./suite"; join=true)))
    end
end

PierreMartinon avatar Jul 01 '25 08:07 PierreMartinon

@ocots just to be sure: what do you mean by "unit tests"?

jbcaillau avatar Jul 02 '25 22:07 jbcaillau

I mean tests, not really unit tests. I don't really know but we need to add tests in: https://github.com/control-toolbox/OptimalControl.jl/tree/main/test/ctdirect/suite.

ocots avatar Jul 03 '25 06:07 ocots

We can import to OptimalControl the tests in https://github.com/control-toolbox/CTDirect.jl/blob/main/test/suite/test_exa.jl These are CPU, not GPU, and can run normally with the other tests, provided the correct dependencies are added.

There are currently only 2 simple tests, solve with MadNLP and initial guess check. We could add Ipopt for instance. @jbcaillau , which discretizations do we have for ExaModels ?

PierreMartinon avatar Jul 03 '25 12:07 PierreMartinon

I have added some simple tests, thanks to @PierreMartinon. See https://github.com/control-toolbox/OptimalControl.jl/pull/577.

ocots avatar Jul 04 '25 20:07 ocots

@PierreMartinon

We can import to OptimalControl the tests in https://github.com/control-toolbox/CTDirect.jl/blob/main/test/suite/test_exa.jl These are CPU, not GPU, and can run normally with the other tests, provided the correct dependencies are added.

i've also almost added quadrotor2 (needs to be tested, though). these tests must also be run on GPU when available (moonshot)

There are currently only 2 simple tests, solve with MadNLP and initial guess check. We could add Ipopt for instance. @jbcaillau , which discretizations do we have for ExaModels ?

:trapeze, :euler, ~~:euler_b (need to alias that name wrt. what is done in CTDirect)~~; :midpoint on its way https://github.com/control-toolbox/CTParser.jl/pull/94

NB. :euler_b now aliased to :implicit https://github.com/control-toolbox/CTParser.jl/issues/172

jbcaillau avatar Jul 04 '25 21:07 jbcaillau

@ocots @PierreMartinon this can probably now be tested using problems from OptimalControlProblems and / or CTBenchmarks (+ breakages)

right now: adding in https://github.com/control-toolbox/OptimalControl.jl/issues/677 a test extracted from CTParser on goddard (= rich enough case) for

  • exa + ipopt and exa + madnlp on CPU
  • exa + madnlp on GPU

for all four numerical schemes

jbcaillau avatar Nov 22 '25 22:11 jbcaillau