gigl.distributed.base_sampler#

Attributes#

Classes#

BaseDistNeighborSampler

Base class for GiGL distributed samplers.

SampleLoopInputs

Inputs prepared for the neighbor sampling loop in _sample_from_nodes.

Module Contents#

class gigl.distributed.base_sampler.BaseDistNeighborSampler(*args, **kwargs)[source]#

Bases: graphlearn_torch.distributed.DistNeighborSampler

Base class for GiGL distributed samplers.

Extends GLT’s DistNeighborSampler with shared utilities for preparing sampling inputs, including ABLP (anchor-based link prediction) support.

Subclasses must override _sample_from_nodes with their specific sampling strategy (e.g., k-hop neighbor sampling, PPR-based sampling).

Initialize the sampler and the one-time sampling-error guard.

GLTDistNeighborSampler has no GiGL-owned state; we only add _sampling_error_sent so _send_adapter can forward at most one poison pill per sampler instance. Initializing it here (rather than lazily) guarantees the failure handler never raises AttributeError, which GLT’s event loop would swallow the same way it swallows the original sampling exception.

class gigl.distributed.base_sampler.SampleLoopInputs[source]#

Inputs prepared for the neighbor sampling loop in _sample_from_nodes.

This dataclass holds the processed inputs that are passed to the core sampling loop. It allows _prepare_sample_loop_inputs to customize what nodes are sampled from and what metadata is attached to the output, without duplicating the sampling loop logic.

nodes_to_sample[source]#

For homogeneous graphs, a tensor of node IDs. For heterogeneous graphs, a dict mapping node types to tensors. For ABLP, this also includes supervision nodes (positive/negative labels).

metadata[source]#

Metadata dict to attach to the sampler output (e.g., label tensors).

metadata: dict[str, torch.Tensor][source]#
nodes_to_sample: torch.Tensor | dict[graphlearn_torch.typing.NodeType, torch.Tensor][source]#
gigl.distributed.base_sampler.logger[source]#