Configuration Options
Scoped Values
Warning
Currently options are scattered in the form of global variables and scoped values. We are in the process of migrating all of them into scoped values.
Reactant.with_config Function
with_config(f; kwargs...)Run the function f within a dynamic scope such that all uses of the config within this scope will use the provided values.
Extended Help
Configuration Options
Lowering
lower_partialsort_to_approx_top_k: Whether to lowerpartialsortandpartialsortpermtoOps.approx_top_k. Note that XLA only supports loweringApproxTopKfor TPUs unlessfallback_approx_top_k_loweringis set totrue.fallback_approx_top_k_lowering: Whether to lowerOps.approx_top_ktostablehlo.top_kif the XLA backend doesn't supportApproxTopK. Defaults totrue.
DotGeneral
dot_general_algorithm: Algorithm preset forstablehlo.dot_general. Can benothing,DotGeneralAlgorithmorDotGeneralAlgorithmPreset. Defaults toDotGeneralAlgorithmPreset.DEFAULT.dot_general_precision: Precision forstablehlo.dot_general. Can benothing, orPrecisionConfig. Defaults toPrecisionConfig.DEFAULT.convolution_precision: Precision forstablehlo.convolution. Can benothing, orPrecisionConfig. Defaults toPrecisionConfig.DEFAULT.
Zygote Overlay
overlay_zygote_calls: Whether to overlayZygote.gradientcalls withEnzyme.autodiffcalls. Defaults totrue.
Values
DOT_GENERAL_PRECISION: Controls theprecision_configforstablehlo.dot_general.DOT_GENERAL_ALGORITHM: Controls thealgorithmforstablehlo.dot_general.LOWER_PARTIALSORT_TO_APPROX_TOP_K: Whether to lowerpartialsorttoOps.approx_top_k. Note that XLA only supports loweringApproxTopKfor TPUs unlessFALLBACK_APPROX_TOP_K_LOWERINGis set totrue. Defaults tofalse.FALLBACK_APPROX_TOP_K_LOWERING: Whether to fallback to loweringApproxTopKtostablehlo.top_kif the XLA backend doesn't supportApproxTopK. Defaults totrue.
DotGeneral
Reactant.DotGeneralAlgorithmPreset Module
DotGeneralAlgorithmPresetControls the precision_config for stablehlo.dot_general. Valid values are:
DEFAULTANY_F8_ANY_F8_F32ANY_F8_ANY_F8_F32_FAST_ACCUMANY_F8_ANY_F8_ANYANY_F8_ANY_F8_ANY_FAST_ACCUMF16_F16_F16F16_F16_F32BF16_BF16_BF16BF16_BF16_F32BF16_BF16_F32_X3BF16_BF16_F32_X6BF16_BF16_F32_X9F32_F32_F32F64_F64_F64
The following functions are available:
supported_lhs_eltype(dot_algorithm_preset::DotGeneralAlgorithmPreset.T) supported_rhs_eltype(dot_algorithm_preset::DotGeneralAlgorithmPreset.T) accumulation_eltype(dot_algorithm_preset::DotGeneralAlgorithmPreset.T) supported_output_eltype(dot_algorithm_preset::DotGeneralAlgorithmPreset.T, T1, T2) MLIR.IR.Attribute(dot_algorithm_preset::DotGeneralAlgorithmPreset.T, T1, T2)
Reactant.PrecisionConfig Module
PrecisionConfigControls the precision_config for stablehlo.dot_general. Valid values are:
DEFAULTHIGHHIGHEST
The following functions are available:
MLIR.IR.Attribute(precision::PrecisionConfig.T)
Reactant.DotGeneralAlgorithm Type
DotGeneralAlgorithm(
::Type{lhsT}, ::Type{rhsT}, ::Type{accumT},
rhs_component_count::Int, lhs_component_count::Int, num_primitive_operations::Int,
allow_imprecise_accumulation::Bool
)
DotGeneralAlgorithm{lhsT,rhsT,accumT}(
lhs_component_count::Int, rhs_component_count::Int, num_primitive_operations::Int,
allow_imprecise_accumulation::Bool
)Represents the configuration of the stablehlo.dot_general operation.
Arguments
lhsT: The type of the left-hand side operand.rhsT: The type of the right-hand side operand.accumT: The type of the accumulation operand.lhs_component_count: The number of components in the left-hand side operand.rhs_component_count: The number of components in the right-hand side operand.num_primitive_operations: The number of primitive operations in thestablehlo.dot_generaloperation.
Zygote Overlay
OVERLAY_ZYGOTE_CALLS: Whether to overlayZygote.gradientcalls withEnzyme.autodiffcalls.
Environment Variables
The following environment variables can be used to configure Reactant.
GPU Configuration
XLA_REACTANT_GPU_MEM_FRACTION: The fraction of GPU memory to use for XLA. Defaults to0.75.XLA_REACTANT_GPU_PREALLOCATE: Whether to preallocate GPU memory. Defaults totrue.REACTANT_VISIBLE_GPU_DEVICES: A comma-separated list of GPU device IDs to use. Defaults to all visible GPU devices. Preferably useCUDA_VISIBLE_DEVICESinstead.
TPU Configuration
TPU_LIBRARY_PATH: The path to the libtpu.so library. If not provided, we download and use Scratch.jl to save the library.
Distributed Setup
REACTANT_COORDINATOR_BIND_ADDRESS: The address to bind the coordinator to. If not provided, we try to automatically infer it from the environment.