hyri.interface.imager#
Configure and run imaging workflows.
This module assembles the measurement operator, regulariser, and optimiser from user-provided parameter dictionaries, then optionally runs the imaging loop.
Functions
Prepare the imaging components and optionally run reconstruction. |
|
Set the rank-local accelerator device for this process. |
- hyri.interface.imager.set_rank_device(local_rank: int, backend: str) device | None#
Set the rank-local accelerator device for this process.
This function binds the current CUDA and/or XPU device index before distributed initialisation and before accelerator tensors are created. The launch environment may expose either all local accelerator devices to each process or a single visible device through launcher-controlled visibility variables. When only one accelerator is visible, local device index 0 is selected.
- Parameters:
local_rank (int) – Process rank on the current node.
backend (str) – Distributed backend name passed to
torch.distributed.init_process_group().
- Returns:
Process-group device hint for backends that use one. Returns
torch.device("cuda")for the"nccl"backend after setting the current CUDA device, andNoneotherwise.- Return type:
torch.device | None
Note
The current implementation assumes a one-to-one mapping between local processes and accelerator devices. Users may enforce this mapping before launch with visibility environment variables such as
CUDA_VISIBLE_DEVICES, or expose all local devices and let this function selectlocal_rank % device_count. When only one device is visible, index 0 is selected.The return value is only used for the
device_idargument oftorch.distributed.init_process_group(). It is returned for"nccl"because PyTorch only documents process-group initialisation effects fordevice_idunder NCCL; other backends receiveNoneeven though the current CUDA/XPU device may still be set above.
- hyri.interface.imager.imager(param_optimiser: dict, param_measop: dict, param_proxop: dict) None#
Prepare the imaging components and optionally run reconstruction.
This function loads the input data, instantiates the requested hyperspectral measurement operator, builds the corresponding regulariser and optimiser, and executes the full imaging loop when requested.
- Parameters:
param_optimiser (Dict) – Optimiser configuration dictionary, including the algorithm choice, iteration controls, output paths, and distributed-imaging options.
param_measop (Dict) – Measurement-operator configuration dictionary, including Fourier backend, weighting options, image geometry, and numerical settings.
param_proxop (Dict) – Regulariser configuration dictionary, including denoiser shelf paths, devices, dtypes, and verbosity settings.
- Raises:
ValueError – If the number of distributed processes exceeds the number of effective channels or if the requested NUFFT backend is not supported.
NotImplementedError – If the requested imaging algorithm is not implemented.