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:
MappingImmutable tensor configuration holder.
This class bundles
device,dtype, and memory-transfer options into a single immutable mapping. It is used throughoutexperimentsto ensure every created or moved tensor uses the same configuration.- Parameters:
device (str, torch.device, or None, optional) – Target device.
Nonedefaults to"cuda"when available, otherwise"cpu". Strings such as"cuda:0"are resolved automatically.dtype (torch.dtype or None, optional) – Tensor datatype.
Noneuses 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'¶