PhasicConfig
phasic.PhasicConfig(
compute='auto',
cpu_threads=None,
parallel_elimination=False,
parallel_elimination_min_subgraph=None,
parallel_elimination_max_concurrent=None,
svgd_strategy='auto',
high_precision_mode='auto',
high_precision_bits=None,
ill_condition_threshold=1000000000000.0,
warn_on_ill_conditioning=True,
reward_compute_cache=False,
graph_cache=True,
cache_dir=None,
strict=True,
verbose=False,
)Public configuration for phasic. All fields describe USER INTENT. Implementation choices (JAX/MPFR/OpenMP/FFI/SCC) are derived.
Conflicting settings raise PTDConfigError; no silent coercion.
Public fields
compute : ‘auto’ | ‘cpu’ | ‘jax-cpu’ | ‘jax-gpu’, default ‘auto’ Single source of truth for the compute backend. - ‘auto’ : JAX if importable, else pure C++. - ‘cpu’ : pure C++ pipeline; no JAX, no JIT, no FFI. - ‘jax-cpu’ : JAX path on the CPU device. - ‘jax-gpu’ : JAX path on a GPU device. Raises if no GPU.
cpu_threads : int or None, default None OpenMP thread count. None = use auto-detected value (SLURM_CPUS_PER_TASK / SLURM_CPUS_ON_NODE / sched_getaffinity / os.cpu_count()). Backs OMP_NUM_THREADS.
parallel_elimination : bool, default False Run Gaussian elimination in parallel across strongly-connected components of the graph. Backs PHASIC_HIERAR_ELIMINATION.
parallel_elimination_min_subgraph : int or None, default None Skip the on-disk cache for SCCs smaller than this many vertices (None = use the C default of 4). Backs PHASIC_MIN_SCC_SIZE_TO_CACHE.
parallel_elimination_max_concurrent : int or None, default None Cap on simultaneous per-SCC eliminations within one level of the SCC condensation. None = no cap (use all OMP threads). Backs PHASIC_MAX_PARALLEL_SCCS.
high_precision_mode : ‘auto’ | ‘always’ | ‘never’, default ‘auto’ When to engage high-precision arithmetic (MPFR). - ‘auto’ : activate when the condition number exceeds ill_condition_threshold. - ‘always’ : force high precision for every moment computation. - ‘never’ : double precision only, even for ill-conditioned problems (warnings still surface). Requires the library to be built with MPFR for ‘always’. Backs PHASIC_FORCE_MPFR.
high_precision_bits : int or None, default None Precision in bits when high-precision mode is active. None = auto-pick based on the condition number. Must be >= 53 if specified. Backs PHASIC_MPFR_BITS.
ill_condition_threshold : float, default 1e12 Condition-number threshold above which high-precision mode is engaged automatically. Backs PHASIC_CONDITION_THRESHOLD.
warn_on_ill_conditioning : bool, default True Emit log warnings when the condition number is high. Backs PHASIC_DISABLE_CONDITION_WARNINGS (inverted).
reward_compute_cache : bool, default False Use the on-disk reward-compute caches at cache_dir/parameterized_reward_compute/ — both the parent <hash>.bin written by ptd_precompute_reward_compute_graph and the per-SCC scc_<hash>.bin written by the hierarchical composer. Backs PHASIC_REWARD_COMPUTE_CACHE (positive: '1' enables, absent = default = off). Default off. The cache uses the rev-3 zero-copy mmap format, so the per-process load is ~as cheap as recompute (it only affects the first call per process — the in-memory Stage-A1 graph amortises later theta updates, the SVGD inner loop). Worth enabling when a model is re-run across processes AND its recompute is expensive (large / stiff); for small or one-shot models leave it off (the load ≈ recompute and the first cold build pays a one-time convert + write). The cache can grow unboundedly across model variants — users own the directory. See CLAUDE.md “Disk caches” and scratch/io_overlap_probe.py.
graph_cache : bool, default True Use the on-disk graph cache at cache_dir/graphs/ for serialised Graph objects (callback-built graphs). Backs PHASIC_DISABLE_GRAPH_CACHE (inverted). Per-graph opt-in via Graph(..., graph_cache=...) overrides this global default.
cache_dir : str or None, default None Override the cache root. None = $HOME/.phasic_cache. Backs PHASIC_CACHE_DIR.
strict : bool, default True Raise on missing-feature warnings (e.g. JAX requested but not installed) instead of logging a warning. Does NOT affect conflict checking — conflicts always raise.
verbose : bool, default False Print configuration details and informational logs.
Attributes
| Name | Description |
|---|---|
| cache_dir | The type of the None singleton. |
| compute | str(object=’’) -> str |
| cpu_threads | The type of the None singleton. |
| ffi | Whether the FFI backend is enabled. Derived from compute. |
| graph_cache | Returns True when the argument is true, False otherwise. |
| high_precision_bits | The type of the None singleton. |
| high_precision_mode | str(object=’’) -> str |
| ill_condition_threshold | Convert a string or number to a floating-point number, if possible. |
| jax | Whether JAX is enabled. Derived from compute. |
| jit | Whether JIT is enabled. Derived from compute. |
| parallel_elimination | Returns True when the argument is true, False otherwise. |
| parallel_elimination_max_concurrent | The type of the None singleton. |
| parallel_elimination_min_subgraph | The type of the None singleton. |
| reward_compute_cache | Returns True when the argument is true, False otherwise. |
| strict | Returns True when the argument is true, False otherwise. |
| svgd_strategy | str(object=’’) -> str |
| verbose | Returns True when the argument is true, False otherwise. |
| warn_on_ill_conditioning | Returns True when the argument is true, False otherwise. |
Methods
| Name | Description |
|---|---|
| effective | Snapshot of current configuration and its environment. |
| validate | Validate the configuration, sync to env vars, raise on conflicts. |
effective
phasic.PhasicConfig.effective()Snapshot of current configuration and its environment.
Returns
:dict-
A dict with three sections: - ‘fields’: every public field and its current value. - ‘environment’: every env var phasic uses, and its current value in os.environ (None if unset). - ‘derived’: useful answers about runtime state: jax_active, mpfr_active, cpu_threads_source, cache_dir_resolved, compute_resolved.
validate
phasic.PhasicConfig.validate()Validate the configuration, sync to env vars, raise on conflicts.
Rules: 1. Env-var single-source-of-truth: each non-default field is written into its env var. 2. No silent rewrites: validate() does not mutate user-set fields. 3. Conflicts raise: incompatible field combinations, or configure() vs pre-existing env var disagreement. 4. strict only governs missing-feature warnings; conflicts always raise regardless of strict.