[GraphBolt][CUDA] Refactor overlap_graph_fetch, simplify gb.DataLoader. (#7681)
这个提交包含在:
@@ -115,7 +115,10 @@ def create_dataloader(
|
||||
else {}
|
||||
)
|
||||
datapipe = getattr(datapipe, args.sample_mode)(
|
||||
graph, fanout if job != "infer" else [-1], **kwargs
|
||||
graph,
|
||||
fanout if job != "infer" else [-1],
|
||||
overlap_fetch=args.overlap_graph_fetch,
|
||||
**kwargs,
|
||||
)
|
||||
# Copy the data to the specified device.
|
||||
if args.feature_device != "cpu":
|
||||
@@ -130,11 +133,7 @@ def create_dataloader(
|
||||
if args.feature_device == "cpu":
|
||||
datapipe = datapipe.copy_to(device=device)
|
||||
# Create and return a DataLoader to handle data loading.
|
||||
return gb.DataLoader(
|
||||
datapipe,
|
||||
num_workers=args.num_workers,
|
||||
overlap_graph_fetch=args.overlap_graph_fetch,
|
||||
)
|
||||
return gb.DataLoader(datapipe, num_workers=args.num_workers)
|
||||
|
||||
|
||||
def train_step(minibatch, optimizer, model, loss_fn):
|
||||
|
||||
@@ -117,7 +117,9 @@ def create_dataloader(
|
||||
# Initialize a neighbor sampler for sampling the neighborhoods of nodes.
|
||||
############################################################################
|
||||
datapipe = getattr(datapipe, args.sample_mode)(
|
||||
graph, fanout if job != "infer" else [-1]
|
||||
graph,
|
||||
fanout if job != "infer" else [-1],
|
||||
overlap_fetch=args.storage_device == "pinned",
|
||||
)
|
||||
|
||||
############################################################################
|
||||
@@ -156,11 +158,7 @@ def create_dataloader(
|
||||
# [Role]:
|
||||
# Initialize a multi-process dataloader to load the data in parallel.
|
||||
############################################################################
|
||||
dataloader = gb.DataLoader(
|
||||
datapipe,
|
||||
num_workers=num_workers,
|
||||
overlap_graph_fetch=args.storage_device == "pinned",
|
||||
)
|
||||
dataloader = gb.DataLoader(datapipe, num_workers=num_workers)
|
||||
|
||||
# Return the fully-initialized DataLoader object.
|
||||
return dataloader
|
||||
|
||||
@@ -147,7 +147,10 @@ def create_dataloader(
|
||||
else {}
|
||||
)
|
||||
datapipe = getattr(datapipe, args.sample_mode)(
|
||||
graph, fanout if job != "infer" else [-1], **kwargs
|
||||
graph,
|
||||
fanout if job != "infer" else [-1],
|
||||
overlap_fetch=args.overlap_graph_fetch,
|
||||
**kwargs,
|
||||
)
|
||||
# Copy the data to the specified device.
|
||||
if args.feature_device != "cpu" and need_copy:
|
||||
@@ -163,11 +166,7 @@ def create_dataloader(
|
||||
if need_copy:
|
||||
datapipe = datapipe.copy_to(device=device)
|
||||
# Create and return a DataLoader to handle data loading.
|
||||
return gb.DataLoader(
|
||||
datapipe,
|
||||
num_workers=args.num_workers,
|
||||
overlap_graph_fetch=args.overlap_graph_fetch,
|
||||
)
|
||||
return gb.DataLoader(datapipe, num_workers=args.num_workers)
|
||||
|
||||
|
||||
@torch.compile
|
||||
|
||||
@@ -195,7 +195,11 @@ def create_dataloader(
|
||||
need_copy = False
|
||||
# Sample neighbors for each node in the mini-batch.
|
||||
datapipe = getattr(datapipe, args.sample_mode)(
|
||||
graph, fanout if job != "infer" else [-1]
|
||||
graph,
|
||||
fanout if job != "infer" else [-1],
|
||||
overlap_fetch=args.overlap_graph_fetch,
|
||||
num_gpu_cached_edges=args.num_gpu_cached_edges,
|
||||
gpu_cache_threshold=args.gpu_graph_caching_threshold,
|
||||
)
|
||||
# Copy the data to the specified device.
|
||||
if args.feature_device != "cpu" and need_copy:
|
||||
@@ -211,13 +215,7 @@ def create_dataloader(
|
||||
if need_copy:
|
||||
datapipe = datapipe.copy_to(device=device)
|
||||
# Create and return a DataLoader to handle data loading.
|
||||
return gb.DataLoader(
|
||||
datapipe,
|
||||
num_workers=args.num_workers,
|
||||
overlap_graph_fetch=args.overlap_graph_fetch,
|
||||
num_gpu_cached_edges=args.num_gpu_cached_edges,
|
||||
gpu_cache_threshold=args.gpu_graph_caching_threshold,
|
||||
)
|
||||
return gb.DataLoader(datapipe, num_workers=args.num_workers)
|
||||
|
||||
|
||||
@torch.compile
|
||||
|
||||
@@ -124,7 +124,9 @@ def create_dataloader(
|
||||
# The graph(FusedCSCSamplingGraph) from which to sample neighbors.
|
||||
# `fanouts`:
|
||||
# The number of neighbors to sample for each node in each layer.
|
||||
datapipe = datapipe.sample_neighbor(graph, fanouts=fanouts)
|
||||
datapipe = datapipe.sample_neighbor(
|
||||
graph, fanouts=fanouts, overlap_fetch=args.overlap_graph_fetch
|
||||
)
|
||||
|
||||
# Fetch the features for each node in the mini-batch.
|
||||
# `features`:
|
||||
@@ -141,11 +143,7 @@ def create_dataloader(
|
||||
# Create a DataLoader from the datapipe.
|
||||
# `num_workers`:
|
||||
# The number of worker processes to use for data loading.
|
||||
return gb.DataLoader(
|
||||
datapipe,
|
||||
num_workers=num_workers,
|
||||
overlap_graph_fetch=args.overlap_graph_fetch,
|
||||
)
|
||||
return gb.DataLoader(datapipe, num_workers=num_workers)
|
||||
|
||||
|
||||
def extract_embed(node_embed, input_nodes):
|
||||
|
||||
@@ -134,16 +134,14 @@ def create_dataloader(
|
||||
############################################################################
|
||||
if args.storage_device != "cpu":
|
||||
datapipe = datapipe.copy_to(device)
|
||||
datapipe = datapipe.sample_neighbor(graph, args.fanout)
|
||||
datapipe = datapipe.sample_neighbor(
|
||||
graph, args.fanout, overlap_fetch=args.storage_device == "pinned"
|
||||
)
|
||||
datapipe = datapipe.fetch_feature(features, node_feature_keys=["feat"])
|
||||
if args.storage_device == "cpu":
|
||||
datapipe = datapipe.copy_to(device)
|
||||
|
||||
dataloader = gb.DataLoader(
|
||||
datapipe,
|
||||
args.num_workers,
|
||||
overlap_graph_fetch=args.storage_device == "pinned",
|
||||
)
|
||||
dataloader = gb.DataLoader(datapipe, args.num_workers)
|
||||
|
||||
# Return the fully-initialized DataLoader object.
|
||||
return dataloader
|
||||
|
||||
在新工单中引用