Precision policy
jax_lab.core.precision_policy.Precision
Bases: Enum
Scalar precision levels with JAX dtype accessors.
Source code in jax_lab/core/precision_policy.py
jax_lab.core.precision_policy.PrecisionPolicy
Bases: Enum
Mixed-precision policy pairing a compute precision (used during arithmetic) with a store/output precision (used in memory).
The naming convention is
Source code in jax_lab/core/precision_policy.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
cast_to_compute
Casts floating-point leaves of a pytree to the compute dtype.
Parameters
tree (pytree): A pytree of JAX or NumPy arrays.
Returns
A pytree with floating-point leaves cast to the compute dtype.
Source code in jax_lab/core/precision_policy.py
cast_to_output
Casts floating-point leaves of a pytree to the store/output dtype.
Parameters
tree (pytree): A pytree of JAX or NumPy arrays.
Returns
A pytree with floating-point leaves cast to the output dtype.
Source code in jax_lab/core/precision_policy.py
from_string
classmethod
Constructs a PrecisionPolicy from a “computation/storage” string.
Parameters
precision (str): A string in the format “computation/storage” where each side is one of “f64”, “f32” or “f16”. Unrecognized values (including None) default to FP32FP32.
Returns
PrecisionPolicy: The corresponding policy.