gigl.distributed.utils.sampling_errors#

Wire format for forwarding a sampling-worker exception to the training loop.

A GLT SampleMessage is a dict[str, torch.Tensor]. We reserve one #-prefixed key (matching GLT’s #IS_HETERO / #META. convention) to carry a UTF-8 traceback encoded as a uint8 tensor, so a failed sampling coroutine can surface as a fast, explained error on the consumer instead of a silent hang.

Attributes#

Functions#

encode_sampling_error(traceback_str)

Encode a traceback string as a writable 1-D uint8 tensor.

raise_if_sampling_error(msg)

Raise RuntimeError with the embedded traceback if msg is a poison pill.

Module Contents#

gigl.distributed.utils.sampling_errors.encode_sampling_error(traceback_str)[source]#

Encode a traceback string as a writable 1-D uint8 tensor.

Uses bytearray so the backing buffer is writable (torch.frombuffer warns on read-only buffers and raises on empty ones); a single sentinel byte represents the empty string so the tensor is never zero-length.

Parameters:

traceback_str (str) – The traceback text to transport.

Returns:

A 1-D torch.uint8 tensor holding the UTF-8 bytes.

Return type:

torch.Tensor

gigl.distributed.utils.sampling_errors.raise_if_sampling_error(msg)[source]#

Raise RuntimeError with the embedded traceback if msg is a poison pill.

No-op when the reserved key is absent.

Parameters:

msg (graphlearn_torch.channel.SampleMessage) – A received SampleMessage.

Raises:

RuntimeError – If msg carries a sampling-error payload.

Return type:

None

gigl.distributed.utils.sampling_errors.SAMPLING_ERROR_KEY: Final[str] = '#SAMPLING_ERROR'[source]#