Hardware & Backends
The Backends module handles hardware detection, memory management, and caching.
Hardware Detection
These flags are set automatically upon import based on your system’s capabilities.
- HeteroSymNN.Backend.hardware.GPU_ENABLED = bool
Trueif a CUDA-capable GPU is detected and CuPy is installed.
- HeteroSymNN.Backend.hardware.CPP_JIT_ENABLED = bool
Trueif a compatible C++ compiler (g++, clang, or cl.exe) is found in the system PATH.
- HeteroSymNN.Backend.hardware.NUM_GPUS = int
The number of available CUDA devices.
Configuration Flags
These variables control the framework’s behavior and can be modified by the user at runtime.
- HeteroSymNN.Backend.hardware.USE_KERNEL_CACHE = bool (Default: True)
If
True, compiled JIT kernels are saved to disk/memory to speed up future runs. Set toFalseto force re-compilation on every run (useful for debugging compiler changes).
- HeteroSymNN.Backend.hardware.WARNINGS_STRICT_MODE = bool (Default: False)
If
True, the framework raises errors instead of warnings when hardware fallbacks occur (e.g., trying to use GPU mode without a GPU).
Internal State
These variables are for debugging and inspection purposes. They show how the framework has configured itself.
- HeteroSymNN.Backend.hardware.DEFAULT_COMPUTE_METHOD = str
The default backend selected based on available hardware.
"GPU_CUDA": Best performance."CPU_CPP": Good performance (OpenMP accelerated)."CPU_PYTHON": Slowest (Fallback).
- HeteroSymNN.Backend.hardware.CPP_INSTALLED_COMPILER = str
The name of the C++ compiler found on the system (e.g.,
"g++","cl.exe", or"clang"). ReturnsNoneif no compiler was found.
Utilities
- HeteroSymNN.Backend.hardware.clear_kernel_cache(cache_type: Literal['ALL', 'CPU', 'GPU'] = 'ALL') None[source]
Clears the cache used by HeteroSymNN.
- Parameters:
cache_type (Literal["ALL","CPU","GPU"], optional) – Type of cache to clear. Options are: - “ALL”: Clears both CPU and GPU caches. - “CPU”: Clears only the CPU cache. - “GPU”: Clears only the GPU cache. The default is ‘ALL’.