pub struct PrecisionPolicy {
pub storage: StoragePrecision,
}Expand description
A typed precision request for one training run or scoped region.
Fields§
§storage: StoragePrecisionRequested activation/operand storage precision.
Implementations§
Source§impl PrecisionPolicy
impl PrecisionPolicy
Sourcepub const fn f16_storage() -> Self
pub const fn f16_storage() -> Self
Request FP16 operand storage in lowered matmuls. Requires a gradient scaler companion for training.
Sourcepub fn resolve(&self, runtime: &Runtime) -> Result<EffectivePrecision>
pub fn resolve(&self, runtime: &Runtime) -> Result<EffectivePrecision>
Resolve this request against one runtime’s device contract.
Unlike the environment channel, typed resolution fails closed: an
F16Storage request on a device whose enabled capability surface
lacks shaderFloat16 + 16-bit storage-buffer access is an error
rather than a silent F32 fallback.
§Errors
Returns an error when the requested storage precision is not admitted by the device contract.
Sourcepub fn enter(&self, runtime: &Runtime) -> Result<PrecisionScope>
pub fn enter(&self, runtime: &Runtime) -> Result<PrecisionScope>
Validate and activate this precision policy on runtime until the
returned PrecisionScope is dropped or closed.
Fails closed before changing the runtime’s policy when the device does not admit the requested storage precision. Scopes nest cleanly and never affect other runtimes or process environment variables.
§Errors
Returns an error when Self::resolve rejects the policy on runtime.
Sourcepub fn current(runtime: &Runtime) -> EffectivePrecision
pub fn current(runtime: &Runtime) -> EffectivePrecision
Report the effective precision currently active on runtime.
When a PrecisionScope is active on runtime, reports that scoped
selection; otherwise reports what the process-wide environment channel
(OA_FORCE_PRECISION) resolves to — including silent fallbacks, so
requested and effective precision stay distinguishable in any report.