Skip to content

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 # False
specux.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 for istft and the training backward: ordered gather instead of atomics, at the cost of a larger intermediate buffer. torch’s use_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; 0 means auto (the physical cores).
  • specux.clear_cache(): drop cached plans, filterbanks, twiddle tables, and idle memory-pool blocks. Compiled kernels stay cached.

Environment variables

variableeffect
SPECUX_DETERMINISTICinitial value of specux.deterministic
SPECUX_BENCHMARKinitial value of specux.benchmark
SPECUX_CACHE_DIRtuning + kernel cache location (default {tmp}/specux_{user})
SPECUX_CUDA_HOMECUDA toolkit root (build and runtime discovery)
SPECUX_CPU_ONLY1 builds CPU-only; 0 makes a missing toolkit a build error