get_precision#
- class brainstate.environ.get_precision(*, env=None)[source]#
Get the current numerical precision as an integer.
- Parameters:
env (
EnvironmentState|None) – The environment state to query. If None, uses the global environment.- Returns:
Precision in bits (8, 16, 32, or 64).
- Return type:
Examples
>>> import brainstate.environ as env >>> >>> env.set_precision(32) >>> bits = env.get_precision() >>> print(f"Using {bits}-bit precision") # Using 32-bit precision >>> >>> # Special handling for bfloat16 >>> env.set_precision('bf16') >>> print(env.get_precision()) # 16
Using custom environment:
>>> import brainstate.environ as env >>> >>> custom_env = env.EnvironmentState() >>> env.set_precision(64, env=custom_env) >>> print(env.get_precision(env=custom_env)) # 64
Notes
‘bf16’ (bfloat16) is reported as 16-bit precision.