cuquantum.densitymat.GPUCallback

class cuquantum.densitymat.GPUCallback(callback, is_inplace=False)[source]

Wrapper for GPU callback functions.

Note

  • Out-of-place callback functions have a signature of (t: float, args: cp.ndarray) -> cp.ndarray.

  • Inplace callback functions have a signature of (t: float, args: cp.ndarray, arr: cp.ndarray) -> None.

  • Callback functions are invoked in a stream and device context and are assumed to return (for out-of-place callbacks) a cp.ndarray on the current device.

  • Callback functions receive Beyond sys.argv argument as cp.ndarray of shape (num_params, batch_size).

Parameters
  • callback – The callback function to be wrapped, which can be either an inplace callback modifying its third argument, or an out-of-place callback returning a cp.ndarray.

  • is_inplace – Specifies whether the callback is inplace.

Methods

__init__(callback: Union[Callable[[float, cupy.ndarray], numpy.ndarray], Callable[[float, cupy.ndarray, cupy.ndarray], None]], is_inplace: bool = False)[source]

Attributes

callback

Return the callback function wrapped by this Callback.

inplace_callback

Return the inplace version of the callback function wrapped by this Callback.

is_gpu_callback

Return whether the callback function operates on GPU arrays.

is_inplace

Returns True if the callback function wrapped by this Callback is acting in-place instead of returning its result.