pub struct CompileOptions {Show 23 fields
pub precision: Precision,
pub policy: Option<PrecisionPolicy>,
pub scaled_quant: Option<ScaledQuantConfig>,
pub rng: RngOptions,
pub dce: bool,
pub constant_folding: bool,
pub verbose: bool,
pub fusion_target: Option<FusionTarget>,
pub fusion_opts: FusionOptions,
pub arena_alignment: usize,
pub assert_fusion_clean: bool,
pub supported_ops: Option<&'static [OpKind]>,
pub dim_binding: Option<DimBinding>,
pub param_bindings: Option<HashMap<String, Vec<f32>>>,
pub quant_param_bindings: Option<HashMap<String, Vec<u8>>>,
pub kernel_dispatch: KernelDispatchConfig,
pub disable_mpsgraph: bool,
pub scan_unroll_max_length: u32,
pub cache_param_invariant: bool,
pub lint_numerics: bool,
pub fusion_report: bool,
pub disable_conv_bias_act_fusion: bool,
pub no_io_peaks_output: bool,
}Expand description
All knobs the compile pipeline understands. Add new fields here rather than introducing new compile entry points.
Fields§
§precision: PrecisionTarget numeric precision for execution. Default: F32.
policy: Option<PrecisionPolicy>Optional per-op precision policy (mixed precision rewrite).
scaled_quant: Option<ScaledQuantConfig>Opt-in native low-precision GEMM. When set, every 2-D Op::MatMul is
rewritten to a ScaledMatMul whose operands are dynamically quantized to
this element format + scale layout — any ScaledFormat, including a
parameterized Custom (e.g. f4e3m0). Off by default; changes numerics.
rng: RngOptionsRNG policy for in-graph Op::RngNormal / Op::RngUniform nodes.
dce: boolRun dead-code elimination as part of compile. Default: true.
constant_folding: boolRun constant folding. Default: true (cheap, only helps).
verbose: boolVerbose pass logging. Equivalent to RLX_VERBOSE=1 or
[rlx_ir::env::set("RLX_VERBOSE", "1")].
fusion_target: Option<FusionTarget>Override fusion pipeline target (default: inferred from device).
fusion_opts: FusionOptionsPer-target fusion toggles (Metal env overrides, skip fusion, …).
arena_alignment: usizeArena alignment for buffer planning. Default: 64.
assert_fusion_clean: boolPanic at compile time if fusion diagnostics report missed patterns.
supported_ops: Option<&'static [OpKind]>Backend op claim set for backend-aware fusion + post-fusion
legalization. Set by Backend::compile implementations.
dim_binding: Option<DimBinding>When set, specialize symbolic dims before backend lowering.
param_bindings: Option<HashMap<String, Vec<f32>>>Bake fixed param tensors into constants before DCE / constant folding.
quant_param_bindings: Option<HashMap<String, Vec<u8>>>Packed U8 GGUF weights for Op::Param nodes in DequantMatMul (TPU HLO bake).
kernel_dispatch: KernelDispatchConfigNative vs common IR lowering (KernelDispatchConfig, RLX_KERNEL_DISPATCH=common).
disable_mpsgraph: boolPrevent Metal from lowering the graph through MPSGraph.
This keeps the regular Metal thunk schedule while retaining all other compile options. Off by default.
scan_unroll_max_length: u32On backends that list OpKind::Scan (host-fallback), Scans with
length <= scan_unroll_max_length are IR-unrolled into body replicas so
they run as ordinary device ops. Longer Scans keep ScanHost.
Default: 64. 0 disables unroll on claiming backends; u32::MAX
prefers unroll for every eligible Scan.
cache_param_invariant: boolHoist the param-invariant subgraph (compute that depends only on weights,
never on Op::Input) into a separate “prepare” graph run ONCE, feeding
its outputs into the main graph across forwards. Complements
param_bindings (which folds such compute away at compile when weight
VALUES are known); this handles run-time-only weights. Opt-in; default
off (also settable via RLX_CACHE_PARAM_INVARIANT=1).
lint_numerics: boolStatic provable NaN/Inf lint during compile (RLX_LINT_NUMERICS).
fusion_report: boolPrint fusion before/after report (RLX_FUSION_REPORT).
disable_conv_bias_act_fusion: boolSkip Conv+Bias+Act fusion (RLX_DISABLE_CONV_BIAS_ACT_FUSION).
no_io_peaks_output: boolDisable IO-gated peaks-only fusion (RLX_NO_IO_PEAKS_OUTPUT).
Implementations§
Source§impl CompileOptions
impl CompileOptions
Sourcepub fn apply_env(&mut self)
pub fn apply_env(&mut self)
Overlay compile-layer env keys (idempotent). Uses rlx_ir::env_registry
so aliases resolve.
pub fn new() -> Self
pub fn precision(self, p: Precision) -> Self
pub fn policy(self, p: PrecisionPolicy) -> Self
Sourcepub fn scaled_quant(self, cfg: ScaledQuantConfig) -> Self
pub fn scaled_quant(self, cfg: ScaledQuantConfig) -> Self
Enable native low-precision GEMM for every 2-D matmul in the graph, in
the given element format + scale layout. Accepts any ScaledFormat via
ScaledQuantConfig — e.g. ScaledQuantConfig::fp8_e4m3(), or a
parameterized ScaledFormat::custom(3, 0) (f4e3m0).
pub fn rng(self, rng: RngOptions) -> Self
pub fn rng_backend(self, backend: RngBackend) -> Self
pub fn rng_seed(self, seed: u64) -> Self
pub fn no_policy(self) -> Self
pub fn with_dce(self, on: bool) -> Self
pub fn with_constant_folding(self, on: bool) -> Self
pub fn with_verbose(self, on: bool) -> Self
pub fn fusion_target(self, target: FusionTarget) -> Self
pub fn fusion_opts(self, opts: FusionOptions) -> Self
pub fn arena_alignment(self, bytes: usize) -> Self
pub fn supported_ops(self, ops: &'static [OpKind]) -> Self
pub fn assert_fusion_clean(self, on: bool) -> Self
pub fn dim_binding(self, binding: DimBinding) -> Self
pub fn param_bindings(self, bindings: HashMap<String, Vec<f32>>) -> Self
Sourcepub fn quant_param_bindings(self, bindings: HashMap<String, Vec<u8>>) -> Self
pub fn quant_param_bindings(self, bindings: HashMap<String, Vec<u8>>) -> Self
Packed U8 weights for TPU GGUF DequantMatMul param bake at compile time.
pub fn kernel_dispatch(self, policy: KernelDispatchPolicy) -> Self
pub fn kernel_dispatch_config(self, config: KernelDispatchConfig) -> Self
Sourcepub fn scan_unroll_max_length(self, max: u32) -> Self
pub fn scan_unroll_max_length(self, max: u32) -> Self
Prefer IR-unrolling Scans with length <= max on Scan-claiming backends.
Sourcepub fn force_common_kinds(self, kinds: &'static [OpKind]) -> Self
pub fn force_common_kinds(self, kinds: &'static [OpKind]) -> Self
Force listed logical kernels to use common IR even when native is in supported_ops.
Sourcepub fn force_native_kinds(self, kinds: &'static [OpKind]) -> Self
pub fn force_native_kinds(self, kinds: &'static [OpKind]) -> Self
Keep listed logical kernels native even under ForceCommon / missing from supported_ops.
pub fn with_lint_numerics(self, on: bool) -> Self
pub fn with_fusion_report(self, on: bool) -> Self
pub fn with_disable_mpsgraph(self, on: bool) -> Self
pub fn with_cache_param_invariant(self, on: bool) -> Self
pub fn with_no_io_peaks_output(self, on: bool) -> Self
pub fn with_disable_conv_bias_act_fusion(self, on: bool) -> Self
Trait Implementations§
Source§impl Clone for CompileOptions
impl Clone for CompileOptions
Source§impl Debug for CompileOptions
impl Debug for CompileOptions
Auto Trait Implementations§
impl Freeze for CompileOptions
impl RefUnwindSafe for CompileOptions
impl Send for CompileOptions
impl Sync for CompileOptions
impl Unpin for CompileOptions
impl UnsafeUnpin for CompileOptions
impl UnwindSafe for CompileOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more