lmlib.statespace.backend¶
Selection tool to switch between Python interpreter (default) and JIT (Just-in-Time) compilation execution for time-critical routines in the statespace package.
Functions:
-
set_backend–Selects one out of multiple available backends (to optimize execution performance).
-
set_gpu_dtype–Set the on-device compute precision of the
cupyGPU backend. -
get_gpu_dtype–Return the active
cupy-backend device compute dtype (numpy scalar type). -
is_backend_available–Checks if the backend
backendis available on this system. -
get_backend–Returns the name of the currently selected backend.
Attributes:
-
BACKEND_TYPES–tuple of str : All backend names known to lmlib (
'jit','numpy','lfilter','cupy'), whether or not they are installed on this system. -
available_backends–tuple of str : Backend names actually available on this system.
'jit'is appended at import time when the optionalnumbapackage is installed;'cupy'is appended when the optionalcupypackage is installed and a CUDA device is visible.
Attributes¶
BACKEND_TYPES
module-attribute
¶
tuple of str : All backend names known to lmlib ('jit', 'numpy', 'lfilter', 'cupy'), whether or not they are installed on this system.
available_backends
module-attribute
¶
tuple of str : Backend names actually available on this system. 'jit' is appended at import time when the optional numba package is installed; 'cupy' is appended when the optional cupy package is installed and a CUDA device is visible.
Functions¶
set_backend
¶
Selects one out of multiple available backends (to optimize execution performance).
Parameters:
-
backend(str(jit, py, python, numpy, lfilter)) –- "numpy" : for State Space Backend in Python (default)
- "lfilter" : for Transfer Function Backend in Python
- "jit": Just-in-Time compilation (if available)
- "cupy": GPU Transfer Function Backend using CuPy / cupyx (if available)
- "python" or "py" : Deprecated. (same as numpy)
-
If– -
Use–
Source code in lmlib/statespace/backend.py
set_gpu_dtype
¶
Set the on-device compute precision of the cupy GPU backend.
Parameters:
-
dtype((float32, float64), default:'float32') –'float64'(default) gives ~1e-13 parity with thelfilterbackend.'float32'is much faster on GPUs with reduced FP64 throughput (most consumer / laptop cards) at ~1e-6 relative accuracy (the error grows with ALSSM order).
Notes
Host buffers (xi / kappa / W) stay float64; only device math
changes. The steady-state W is computed on the host and is unaffected.
Requires the cupy backend to be available.
Source code in lmlib/statespace/backend.py
get_gpu_dtype
¶
Return the active cupy-backend device compute dtype (numpy scalar type).
Source code in lmlib/statespace/backend.py
is_backend_available
¶
Checks if the backend backend is available on this system.
Parameters:
-
backend(str) –or a list of valid backends, see [`set_backend`][lmlib.statespace.backend.set_backend]
Returns:
-
output(bool) –TrueorFalse
Source code in lmlib/statespace/backend.py
get_backend
¶
Returns the name of the currently selected backend.
Returns:
-
output(str) –for a list of valid backends, see
set_backend