pytorch-geometric
Use PyTorch Geometric to build graph data, loaders, GNN models, heterogeneous workflows, explainers, scalable/distributed jobs, and GraphGym experiments.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- pytorch-geometric
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Use PyTorch Geometric to build graph data, loaders, GNN models, heterogeneous workflows, explainers, scalable/distributed jobs, and GraphGym experiments.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/install-and-optional-dependencies.md3.0 KB
- 参考文档references/repo-provenance.md1.7 KB
- 参考文档references/repo-routing-metadata.json526 B
- 参考文档references/troubleshooting.md3.4 KB
- 脚本scripts/check_pyg_environment.py4.0 KB
03 SKILL.md 正文
PyTorch Geometric
Use this repo skill when a task involves PyTorch Geometric (PyG), the torch_geometric Python package, graph neural networks, graph data containers, mini-batch/neighbor loaders, heterogeneous graphs, explainability, distributed graph learning, or GraphGym experiment configs.
First Checks
- Read repo provenance before deciding whether this skill matches a local PyG checkout or should be refreshed.
- Read install and optional dependencies when setting up PyG, choosing CPU/GPU wheels, or deciding which extras/extensions are needed.
- Read cross-cutting troubleshooting for import failures, missing
torch, optional extension issues, dataset downloads, CUDA/backend mismatches, or stale generated skill concerns. - Run check_pyg_environment.py for a safe import/backend diagnostic that does not download data, allocate GPUs by default, or write files.
Minimal Install Pattern
PyG imports torch, so install a compatible PyTorch build first, then install PyG:
python -m pip install torch
python -m pip install torch-geometric
python - <<'PY'
import torch
import torch_geometric
print(torch.__version__)
print(torch_geometric.__version__)
PY
For CUDA, ROCm, Apple Silicon, or extension-heavy sampling workflows, choose the PyTorch wheel and optional PyG extension wheels that match the target backend. Do not mix CPU PyTorch with CUDA-only extension wheels.
Route by Task
- Use data-and-datasets for
Data,HeteroData,Batch, customDataset/InMemoryDataset, transforms, dataset splitting, and local graph validation. - Use loaders-and-sampling for
DataLoader,NeighborLoader,LinkNeighborLoader, mini-batching, sampler parameters, temporal/link sampling, and optional sampler backend errors. - Use gnn-modeling for
MessagePassing, common convolution layers, pooling, metrics, training loops,torch.compile, TorchScript/JIT, and tiny model smoke tests. - Use heterogeneous-graphs for typed graph metadata,
HeteroData,HeteroConv,to_hetero, hetero loaders, bipartite relations, and hetero link prediction. - Use explainability for
Explainer,GNNExplainer, masks, thresholds, explanation metrics, and model-config recovery. - Use scalable-distributed for large-graph scaling, remote
FeatureStore/GraphStore, distributed PyG, multi-GPU/multi-node planning, CPU affinity, profiling, and backend diagnostics. - Use graphgym-experiments for GraphGym YAML configs, custom registry hooks, run-single/run-batch concepts, and safe config validation.
Shared Decision Rules
- Prefer tiny synthetic
DataorHeteroDatafixtures for smoke checks before running dataset-download or benchmark examples. - Validate graph tensors early:
edge_indexistorch.longwith shape[2, num_edges], node features align withnum_nodes, masks index the right supervision target, and hetero edge types are(src, relation, dst)triplets. - Treat optional packages as workflow-specific:
pyg-lib,torch-sparse,torch-scatter, and related extension wheels are often needed for fast sampling or sparse operations, while GraphGym and RAG workflows need their own extras. - Keep training, explainability, GraphGym, distributed, and multi-GPU runs small unless the user explicitly accepts downloads, long runtime, result writes, credentials, or hardware use.
- When a task spans routes, start with the data/schema owner, then move to loaders/modeling/explainability/scaling as needed.
Safe Shared Command
python scripts/check_pyg_environment.py --json
Use --require-torch, --require-pyg, or --require-neighbor-backend when the user needs a hard pass/fail diagnostic for a specific workflow.
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).