hqs_distiller.state_io
Module providing input / output (IO) functionality for states.
With these functions we want to address states, which are so huge in memory that the costs of loading and storing them on (ssd) hard disk are worth not keeping them in memory and instead representing them by State objects.
NOTE: Here we use a simple pattern detecting the availability of GPUs to decide whether to use cupy (for GPUs) or numpy (for CPUs).
Copyright © 2024-2025 HQS Quantum Simulations GmbH. All Rights Reserved.
Write a state file for numpy array.
"Converts" a numpy array into its representation as a state file (simply UUID defining the file name for now).
Arguments:
- data (xp.ndarray): Array to be stored.
Raises:
- FileExistsError: If file with name already exists.
Returns:
State: Model for state file.
Reads a state file and extracts numpy / cupy array.
"Converts" a state file into a numpy / cupy array.
Arguments:
- state (State): State from which to retrieve the numpy / cupy array.
Raises:
- FileNotFoundError: If file for State model does not exists.
Returns:
xp.ndarray: Numpy / cupy array loaded from state file.
Delete file corresponding to given State.