mixle.inference.fusion_policy module¶
Cost-model policy: when should a default-engine fit switch to the single-pass fused numba kernel?
This lives apart from estimation.py on purpose. The high-level fitting machinery is required (by the
compute_metadata architectural guard) to depend only on abstract compute protocols, not on a concrete
kernel implementation like mixle.stats.compute.fused_codegen. This module is the one place that is
allowed to know about fusion, so it owns the fusibility query and the workload threshold.
Below _FUSION_MIN_WORKLOAD (observations x iterations) the fused kernel’s one-time numba compile
(~0.1s, then disk-cached per model structure) is not amortized, so the fit stays on the host path.
Measured crossover: fusion only breaks even on a cold compile around 2-6e6 obs-iters, and wins (~1.7x)
once warm/cached – so this conservative gate never slows a small/medium fit while auto-using fusion for
large or repeated workloads. Parity (fused == host) is guaranteed by the fused_codegen / fused_em tests.
- has_fusion_benefit(model)[source]
A multi-factor model where single-pass fusion eliminates real per-leaf dispatch (a mixture of >1 component, or a composite/record of >1 field). A bare leaf has nothing to fuse, so it stays on host.