index-batching
Guides memory-efficient PyTorch Geometric Temporal index-batching, GPU preprocessing flags, loader return tuples, and optional Dask-DDP training.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- index-batching
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Guides memory-efficient PyTorch Geometric Temporal index-batching, GPU preprocessing flags, loader return tuples, and optional Dask-DDP training.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/distributed-ddp.md6.6 KB
- 参考文档references/troubleshooting.md6.0 KB
- 参考文档references/workflows.md9.4 KB
- 脚本scripts/index_batching_smoke.py8.2 KB
03 SKILL.md 正文
Index Batching
Use this sub-skill when the task asks about PyTorch Geometric Temporal index-batching, memory-efficient temporal mini-batches, get_index_dataset, IndexDataset, allGPU, dask_batching, world_size/ddp_rank, Dask-DDP, or errors caused by missing index=True.
Route here when
- The user wants a
DataLoaderthat yields sequence windows instead of a full temporal signal iterator. - The user is adapting Chickenpox, WindmillLarge, METR-LA, PeMS-Bay, PeMS-All-LA, or full PeMS to index batching.
- The question is about 5-tuple versus 7-tuple
get_index_datasetreturns, normalization statistics, or batch tensor shape. - The user needs to decide between CPU preprocessing (
allGPU=-1), GPU index preprocessing (allGPU=<device_id>), or optional Dask-DDP distributed training. - The error mentions
get_index_dataset requires 'index=True', missingdask/pandas/tables, CUDA not available, orDistributedSamplerrank/replica problems.
Do not handle here
- Ordinary temporal signal iterators such as
StaticGraphTemporalSignal, dynamic graph signals, hetero signals, slicing, ortemporal_signal_split; route those to the temporal-signals sub-skill. - Ordinary
get_dataset()loader workflows, download/cache planning, and non-index dataset catalogs; route those to the dataset-loaders sub-skill. - Model architecture selection and recurrent/attention layer internals beyond the batched output shape needed to connect an index batch to a model loop; route those to the model sub-skills.
- Real multi-node cluster execution or scheduler launch scripts as a required verification step; this sub-skill only provides reference patterns and prerequisites.
First facts to apply
-
IndexDatasetis not exported fromtorch_geometric_temporal.signal; import it explicitly with:from torch_geometric_temporal.signal.index_dataset import IndexDataset -
Loader index batching is opt-in. Instantiate supported loaders with
index=Truebefore callingget_index_dataset(...). -
IndexDataset(indices, data, horizon, lazy=False, gpu=False)stores start indices and returns(X_window, y_window), where both windows have lengthhorizon/lagsalong time. -
Batches yielded by built-in index dataloaders have sequence-to-sequence layout close to
[batch, lags, num_nodes, num_features]before any model-specific permutation. -
Chickenpox returns a 5-tuple; WindmillLarge, METR-LA, PeMS-Bay, PeMS-All-LA, and PeMS return a 7-tuple with normalization statistics.
What to read or run
- Read workflows.md for CPU/GPU index-batching setup, supported loader return formats, tuple unpacking, normalization statistics, ratio/lags behavior, and model-loop shape notes.
- Read distributed-ddp.md only when the user asks for Dask-DDP, multi-GPU, multi-node,
world_size,ddp_rank,DistributedSampler, or scheduler-file behavior. - Read troubleshooting.md when an index-batching call fails or when optional dependencies, CUDA, Dask, ranks, tuple lengths, downloads, or empty splits are involved.
- Run or adapt index_batching_smoke.py for a deterministic no-network synthetic
IndexDatasetsanity check.
Minimal safe workflow
from torch_geometric_temporal.dataset import PemsBayDatasetLoader
loader = PemsBayDatasetLoader(index=True)
train_loader, val_loader, test_loader, edge_index, edge_weight, mean, std = (
loader.get_index_dataset(lags=12, batch_size=64, shuffle=True, allGPU=-1)
)
for X_batch, y_batch in train_loader:
# CPU preprocessing path: move tensors to the model device inside the loop.
# X_batch/y_batch are sequence windows, typically [B, T, N, F].
pass
For Chickenpox, unpack five values instead:
train_loader, val_loader, test_loader, edge_index, edge_weight = (
ChickenpoxDatasetLoader(index=True).get_index_dataset(lags=4, batch_size=4)
)
If the task requires exact loader-specific shapes, DDP behavior, or de-normalization, open the references instead of expanding this router.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).