02a GPU Acceleration
The GUI can use optional PyTorch backends for selected NNMF and NNLS paths. If PyTorch or CUDA is not available, the analysis falls back to CPU implementations where supported.
For installation instructions, environment files, and platform-specific notes, see Installation – GPU notes.
What Can Use The GPU
GPU acceleration is currently relevant for:
- NNMF with the multiplicative-update solver (
mu, the default iteration scheme in the Analysis panel) through the PyTorch backend; - batched fixed-H NNLS through the PyTorch/CUDA NNLS backend.
The alternative coordinate-descent solver (cd in the NNMF solver dropdown) always runs on the CPU through scikit-learn, so the Backend setting does not affect it. The two solvers are compared in 02 Analysis modes and NNMF and NNLS modes.
Backend Selection
The analysis panel exposes a Backend dropdown for the PyTorch multiplicative-update NNMF path with two options (since v0.9.4):
- Prefer GPU (default): tries the first available accelerator in priority order CUDA (NVIDIA) > MPS (Apple Silicon) > XPU (Intel) > DirectML (AMD Radeon on Windows, or any other DirectX-12 GPU). If no GPU is detected, falls back to CPU torch and logs the fallback. The entry names the device it found, e.g. Prefer GPU (DirectML: AMD Radeon(TM) Graphics) or Prefer GPU (none detected: torch CPU), so you can tell at a glance whether the GPU is in use.
- CPU only: skips the PyTorch MU path entirely and runs the scikit-learn MU NMF on CPU (not torch CPU). Useful for benchmarking, reproducibility against the scikit-learn reference, or when the GPU is busy with another job.
If PyTorch is not installed, the Backend dropdown is locked to CPU only — there is no torch/GPU path to choose, so the multiplicative-update NMF runs on scikit-learn. A machine that has PyTorch but no GPU keeps the dropdown enabled: Prefer GPU then runs a torch-CPU fit.
The Coordinate Descent (cd) solver always runs on the scikit-learn CPU backend regardless of the Backend setting.
The legacy Automatic item from v0.9.3 was removed in v0.9.4 because it had identical behavior to Prefer GPU. Presets saved as "auto" load as Prefer GPU automatically.

AMD Radeon On Windows (DirectML)
AMD GPUs — dedicated Radeon cards and the integrated Radeon graphics of Ryzen APUs — are supported on Windows through Microsoft's DirectML plugin for PyTorch. Install pip install "hs-mosaic[directml]" into a fresh virtual environment (the plugin brings its own pinned torch build), or run setup_windows_directml.ps1 from a source checkout. The fit summary then reports torch-dml. Expect a moderate speedup on integrated graphics (they share the CPU's memory bandwidth) and a larger one on discrete cards; torch.compile is not available on this backend. Details, measured numbers and troubleshooting: Installation → AMD Radeon on Windows (DirectML).
Forcing A Device
Set the environment variable HS_MOSAIC_TORCH_DEVICE to cpu, cuda, mps, xpu or dml before starting the GUI to override the automatic priority order — for example cpu to benchmark the torch-CPU path against your GPU on the same machine. Requesting a device that is not available logs a warning and falls back to the automatic choice.
CUDA Requirements
For NVIDIA GPU acceleration, the important requirement is a CUDA-enabled PyTorch installation. In most cases, the full CUDA Toolkit is not required just to run the GUI. A compatible NVIDIA driver and CUDA-enabled PyTorch wheel/conda package are usually sufficient.
Check CUDA availability with:
python -c "import torch; print(torch.cuda.is_available()); print(torch.version.cuda)"
If this prints True, the PyTorch CUDA paths should be available to the GUI.
What To Report In A Paper Or Tutorial
When documenting an analysis, report:
- solver,
- backend,
- maximum iterations,
- whether fixed-H NNLS was used,
- whether GPU acceleration was available,
- final error or iteration summary when relevant.
This makes runtime and reproducibility easier to interpret.