Runtime options
Two runtime options follow one pattern: read the state via .value, set it
by calling, scope it as a context manager. Both initialize from their
environment variable.
specux.deterministic.value # Falsespecux.deterministic(True) # set globally
x = np.random.randn(8, 32768).astype(np.float32)Z = specux.stft(x, n_fft=1024)with specux.deterministic(True): # or scoped: restores on exit y = specux.istft(Z, n_fft=1024, length=x.shape[-1])specux.deterministic: bitwise-reproducible overlap-add foristftand the training backward: ordered gather instead of atomics, at the cost of a larger intermediate buffer. torch’suse_deterministic_algorithms(True)enables it automatically.specux.benchmark: autotune-and-cache every configuration on first use: the first call for a new (GPU, plan configuration) problem measures the candidate kernels and persists the winner. The tuning results survive across processes in the cache directory.
specux.set_deterministic(flag) and specux.set_benchmark(on=True) are
plain-function synonyms for calling the options (a set with no scoping).
Threads and caches
specux.set_num_threads(n)/get_num_threads(): CPU backend thread count;0means auto (the physical cores).specux.clear_cache(): drop cached plans, filterbanks, twiddle tables, and idle memory-pool blocks. Compiled kernels stay cached.
Environment variables
| variable | effect |
|---|---|
SPECUX_DETERMINISTIC | initial value of specux.deterministic |
SPECUX_BENCHMARK | initial value of specux.benchmark |
SPECUX_CACHE_DIR | tuning + kernel cache location (default {tmp}/specux_{user}) |
SPECUX_CUDA_HOME | CUDA toolkit root (build and runtime discovery) |
SPECUX_CPU_ONLY | 1 builds CPU-only; 0 makes a missing toolkit a build error |