PTDAlgorithmsConfig
phasic.PTDAlgorithmsConfig(
jax=True,
jit=True,
ffi=True,
openmp=True,
strict=True,
platform='cpu',
backend='jax',
verbose=False,
force_high_precision=False,
mpfr_precision_bits=0,
condition_threshold=1000000000000.0,
enable_condition_warnings=True,
)Global configuration for phasic behavior.
All optional features must be explicitly enabled/disabled. No silent fallbacks.
Parameters
jax :bool= True-
Require JAX functionality. If True and JAX not installed, raises error.
jit :bool= True-
Enable JIT compilation. Requires jax=True.
ffi :bool= True-
Enable FFI backend for zero-copy C++ computation. Provides 5-10x speedup over pure_callback. Requires XLA headers during build. Set to False only if FFI cannot be built on your system.
openmp :bool= True-
Enable OpenMP multi-threading in FFI handlers. Provides ~8x additional speedup on 8-core systems (800% CPU vs 100%). Requires ffi=True. Set to False only if OpenMP unavailable on your system.
strict :bool= True-
If True, raise errors when features unavailable. If False, print warnings and continue.
platform :Literal['cpu', 'gpu', 'tpu'] = 'cpu'-
JAX platform to use. Requires jax=True.
backend :Literal['jax', 'cpp', 'ffi'] = 'jax'-
Default computation backend for FFI wrappers.
verbose :bool= False-
Print configuration details on startup.
force_high_precision :bool= False-
Force MPFR high-precision arithmetic for all trace evaluations. Raises error if MPFR not available. Auto-activation at condition > 1e20 still occurs.
mpfr_precision_bits :int= 0-
MPFR precision in bits (0 = auto-determine from condition number). Examples: 128 (standard), 256 (high), 512 (very high), 1024 (extreme).
condition_threshold :float= 1e20-
Condition number threshold for auto-activating MPFR. Lower values are more conservative. Set to inf to disable auto-activation.
enable_condition_warnings :bool= True-
Enable/disable warnings about ill-conditioned operations.
Examples
>>> config = PTDAlgorithmsConfig(jax=True, jit=True, ffi=False)
>>> config.validate() # Check if configuration is valid>>> # Or use factory methods
>>> config = PTDAlgorithmsConfig.jax_only() # JAX with JIT
>>> config = PTDAlgorithmsConfig.cpp_only() # Pure C++, no JAXAttributes
| Name | Description |
|---|---|
| backend | str(object=’’) -> str |
| condition_threshold | Convert a string or number to a floating point number, if possible. |
| enable_condition_warnings | bool(x) -> bool |
| ffi | bool(x) -> bool |
| force_high_precision | bool(x) -> bool |
| jax | bool(x) -> bool |
| jit | bool(x) -> bool |
| mpfr_precision_bits | int([x]) -> integer |
| openmp | bool(x) -> bool |
| platform | str(object=’’) -> str |
| strict | bool(x) -> bool |
| verbose | bool(x) -> bool |
Methods
| Name | Description |
|---|---|
| cpp_only | Factory: Pure C++ configuration (no JAX, no JIT). |
| get_available_options | Return dict of available options on this system. |
| jax_only | Factory: JAX-based configuration (JIT enabled, no FFI). |
| permissive | Factory: Permissive configuration (warnings instead of errors). |
| validate | Validate configuration and check feature availability. |
cpp_only
phasic.PTDAlgorithmsConfig.cpp_only()Factory: Pure C++ configuration (no JAX, no JIT).
Useful for environments without JAX or when JIT overhead is not worth it.
Returns
:PTDAlgorithmsConfig-
Config with jax=False, jit=False, backend=‘cpp’
get_available_options
phasic.PTDAlgorithmsConfig.get_available_options()Return dict of available options on this system.
Returns
:dict-
Dictionary with keys: - ‘jax’: bool, whether JAX is installed - ‘jit’: bool, whether JIT is available (same as jax) - ‘ffi’: bool, whether FFI is available (always False now) - ‘backends’: list of available backends - ‘platforms’: list of available JAX platforms - ‘cpp’: bool, whether C++ module is available
Examples
>>> import phasic as ptd
>>> opts = ptd.get_available_options()
>>> print(opts)
{'jax': True, 'jit': True, 'ffi': False,
'backends': ['jax', 'cpp'],
'platforms': ['cpu'],
'cpp': True}jax_only
phasic.PTDAlgorithmsConfig.jax_only()Factory: JAX-based configuration (JIT enabled, no FFI).
Returns
:PTDAlgorithmsConfig-
Config with jax=True, jit=True, backend=‘jax’
permissive
phasic.PTDAlgorithmsConfig.permissive()Factory: Permissive configuration (warnings instead of errors).
Useful for development when you want to test functionality even if some features are missing.
Returns
:PTDAlgorithmsConfig-
Config with strict=False
validate
phasic.PTDAlgorithmsConfig.validate()Validate configuration and check feature availability.
Raises
:PTDConfigError-
If strict=True and requested features are unavailable.
Notes
Logs a warning if strict=False and requested features are unavailable.