Preferences for Lux.jl
How to set Preferences
PreferenceTools.jl provides an interactive way to set preferences. First run the following command:
using PreferenceToolsThen in the pkg mode (press ] in the REPL), run the following command:
pkg> preference add Lux <preference-name>=<value>
pkg> preference add LuxLib <preference-name>=<value>
pkg> preference add LuxCore <preference-name>=<value>Lux.jl relies on several preferences to make decision on how to run your code. Here is an exhaustive list of preferences that Lux.jl uses.
Nested Automatic Differentiation
automatic_nested_ad_switching- Set this tofalseto disable automatic switching of backends for nested automatic differentiation. See the manual section on nested automatic differentiation for more details.
Training with Reactant
precision_config- Set this to"auto"to use selectHIGHprecision for CUDA andDEFAULTprecision for other backends. The choice made here can change across versions of Lux.jl and is generally recommended for best performance. Alternatively, you can set this to"default"to useDEFAULTprecision or"high"to useHIGHprecision or"highest"to useHIGHESTprecision.
GPU-Aware MPI Support
If you are using a custom MPI build that supports CUDA or ROCM, you can use the following preferences with Preferences.jl:
cuda_aware_mpi- Set this totrueif your MPI build is CUDA aware.rocm_aware_mpi- Set this totrueif your MPI build is ROCM aware.
By default, both of these preferences are set to false.
GPU Backend Selection
gpu_backend- Set this to bypass the automatic backend selection and use a specific gpu backend. Valid options are "cuda", "rocm", "metal", and "oneapi". This preference needs to be set forMLDataDevicespackage. It is recommended to useMLDataDevices.gpu_backend!to set this preference.
Automatic Eltype Conversion
eltype_mismatch_handling- Preference controlling what happens when layers get different eltypes as input. See the documentation onmatch_eltypefor more details.
Dispatch Doctor
instability_check- Preference controlling the dispatch doctor. See the documentation onLux.set_dispatch_doctor_preferences!for more details. The preferences need to be set forLuxCoreandLuxLibpackages. Both of them default todisable.
Setting the
LuxCorepreference sets the check at the level ofLuxCore.apply. This essentially activates the dispatch doctor for all Lux layers.Setting the
LuxLibpreference sets the check at the level of functional layer of Lux, for example,fused_dense_bias_activation. These functions are supposed to be type stable for common input types and can be used to guarantee type stability.
Disabling Loop Vectorization / Octavian
LoopVectorization.jl and Octavian.jl are optional dependencies that are used to accelerate certain CPU operations. However, these packages are tightly coupled with julia and might not work with all julia versions and systems. If these packages are loaded in any form LuxLib will use the optimized versions of the functions. But it might be desirable to disable these packages and use the default implementations instead. This can be done by setting the disable_loop_vectorization preference to true for LuxLib.