Skip to content

Tests failing in Julia 1.6 (multithreading and RNGs) #14

@ablaom

Description

@ablaom

A test in test/adaptive.jl is failing in Julia 1.6. I suppose this has something to do with changes in Julia around RNGs for multithreaded computations.

The test involves comparison of best score for adaptive PSO against a RandomSearch baseline for different acceleration options. For every option the test passes under Julia 1.4 and indeed the loss and base-line losses are identical for each option (I've added debug lines to print these below):

best_loss = 0.08947526016044464
baseline_best_loss = 0.09009691034711517
Test Summary:                                               | Pass  Total
EvoTree Tuning with AdaptiveParticleSwarm and CPU1{Nothing} |    1      1
best_loss = 0.08947526016044464
baseline_best_loss = 0.09009691034711517
Test Summary:                                                       | Pass  Total
EvoTree Tuning with AdaptiveParticleSwarm and CPUProcesses{Nothing} |    1      1
best_loss = 0.08947526016044464
baseline_best_loss = 0.09009691034711517
Test Summary:                                                     | Pass  Total
EvoTree Tuning with AdaptiveParticleSwarm and CPUThreads{Nothing} |    1      1
    Testing MLJParticleSwarmOptimization tests passed 

However, in Julia 1.6 (and 1.7?) the output is different for multithreads and the test fails:

best_loss = 0.0893142957928955
baseline_best_loss = 0.09001814389260604
Test Summary:                                               | Pass  Total
EvoTree Tuning with AdaptiveParticleSwarm and CPU1{Nothing} |    1      1
best_loss = 0.0893142957928955
baseline_best_loss = 0.09001814389260604
Test Summary:                                                       | Pass  Total
EvoTree Tuning with AdaptiveParticleSwarm and CPUProcesses{Nothing} |    1      1
best_loss = 0.09106885087618996
baseline_best_loss = 0.09001814389260604
EvoTree Tuning with AdaptiveParticleSwarm and CPUThreads{Nothing}: Test Failed at /Users/anthony/GoogleDrive/Julia/MLJ/MLJParticleSwarmOptimization/test/strategies/adaptive.jl:122
  Expression: best_loss < baseline_best_loss || isapprox(best_loss, baseline_best_loss; atol = 0.001)
Stacktrace:
 [1] macro expansion
   @ ~/GoogleDrive/Julia/MLJ/MLJParticleSwarmOptimization/test/strategies/adaptive.jl:122 [inlined]                                                                                  
 [2] macro expansion
   @ /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:1151 [inlined]
 [3] top-level scope
   @ ~/GoogleDrive/Julia/MLJ/MLJParticleSwarmOptimization/test/strategies/adaptive.jl:80
Test Summary:                                                     | Fail  Total
EvoTree Tuning with AdaptiveParticleSwarm and CPUThreads{Nothing} |    1      1
ERROR: LoadError: LoadError: Some tests did not pass: 0 passed, 1 failed, 0 errored, 0 broken.                           
in expression starting at /Users/anthony/GoogleDrive/Julia/MLJ/MLJParticleSwarmOptimization/test/strategies/adaptive.jl:78
in expression starting at /Users/anthony/GoogleDrive/Julia/MLJ/MLJParticleSwarmOptimization/test/runtests.jl:22
ERROR: Package MLJParticleSwarmOptimization errored during testing

I would say the test itself is flawed, as there is no reason to expect PSO to outperform RandomSearch() in a random case. However, this issue raises some questions that need answering:

  1. Is it possible to run adaptive PSO in acceleration=CPUThreads mode reproducibly?
  2. If so, is it possible to re-implement adaptive PSO so that the acceleration mode makes no difference to the outcome when a user specifies the RNG?
  3. What doc fixes or code changes are needed in response to these questions?

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