StreamGroups
- class cubie.memory.stream_groups.StreamGroups(groups: dict[str, list[int]] | None = NOTHING, streams: dict[str, FakeStream | int] = NOTHING)[source]
Bases:
objectContainer for organizing instances into groups with shared streams.
- Parameters:
groups (dict[str, list[int]] | None) – Dictionary mapping group names to lists of instance identifiers. When omitted, an empty mapping is created and populated with the “default” group.
streams (dict[str, cubie.cuda_simsafe.FakeStream | int]) – Dictionary mapping group names to CUDA streams. When omitted, each group receives a new stream from
numba.cuda.stream()and the “default” group is backed bynumba.cuda.default_stream().
- groups
Dictionary mapping group names to lists of instance identifiers.
- streams
Dictionary mapping group names to CUDA streams.
Notes
Each group has an associated CUDA stream that all instances in the group share for coordinated operations. The “default” group is created automatically.
- add_instance(instance: Any, group: str) None[source]
Add an instance to a stream group.
- Parameters:
instance – Host object or integer identifier to register with a stream group.
group – Name of the destination group.
- Returns:
None.- Return type:
None
- Raises:
ValueError – If the instance is already in a stream group.
Notes
If the group does not exist, it is created with a new CUDA stream.
- change_group(instance: Any, new_group: str) None[source]
Move an instance to another stream group.
- Parameters:
instance – Host object or integer identifier to move.
new_group – Name of the destination group.
- Returns:
None.- Return type:
None
Notes
If the new group does not exist, it is created with a new CUDA stream.
- get_group(instance: Any) str[source]
Get the stream group associated with an instance.
- Parameters:
instance – Host object or integer identifier whose group is requested.
- Returns:
Name of the group containing the instance.
- Return type:
- Raises:
ValueError – If the instance is not in any stream groups.
- get_stream(instance: Any) FakeStream | int[source]
Get the CUDA stream associated with an instance.
- Parameters:
instance – Host object or integer identifier whose stream is requested.
- Returns:
CUDA stream associated with the instance’s group.
- Return type:
Stream or int