Configuration

Tensor configuration wrapper.

This module provides the Configuration class, an immutable mapping that bundles device, dtype, and memory-transfer options. It is used throughout experiments to ensure every created or moved tensor uses the same configuration.

Example:

from experiments.configuration import Configuration

config = Configuration(device="cuda:0", dtype=torch.float32)
config["device"]  # device(type='cuda', index=0)
class experiments.configuration.Configuration(device=None, dtype=None, noblock=False, relink=False)

Bases: Mapping

Immutable tensor configuration holder.

This class bundles device, dtype, and memory-transfer options into a single immutable mapping. It is used throughout experiments to ensure every created or moved tensor uses the same configuration.

Parameters:
  • device (str, torch.device, or None, optional) – Target device. None defaults to "cuda" when available, otherwise "cpu". Strings such as "cuda:0" are resolved automatically.

  • dtype (torch.dtype or None, optional) – Tensor datatype. None uses PyTorch’s current default dtype.

  • noblock (bool, optional) – Whether to use non-blocking host-to-device transfers.

  • relink (bool, optional) – Whether to relink instead of copying during parameter assignments.

  • Example

  • -------

  • Configuration (>>> from experiments import)

  • Configuration(device="cpu" (>>> config =)

  • dtype=torch.float32)

  • config["device"] (>>>)

  • device(type='cpu')

default_device = 'cpu'

See also

Used by Model and Dataset to ensure consistent device and dtype placement.