You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 3d96eae
Browse filesBrowse the repository at this point in the historyBrowse files
Fix GPU scalar indexing in remove_edges and getgraph (#691)
* Fix GPU scalar indexing in remove_edges and getgraph
remove_edges (#668): the follow-up to #672 built the keep-mask with
`fill_like(edges_to_remove, true)`, which produced a mask of the wrong
length (that of `edges_to_remove`, not the number of edges) and wrong
eltype (Int instead of Bool) — breaking even the existing CPU tests.
Build the mask from `s` with `fill_like(s, true, Bool, length(s))` so it
lives on the graph's device and does logical indexing correctly.
getgraph (#161): the subgraph extraction uses scalar Dict lookups and
comprehensions that can't run on the GPU. Detect a non-CPU device, run
the extraction on the CPU, and move the result back to the original
device.
Also restores the indentation of the commented add_snapshot!/
remove_snapshot! exports mangled by #672, and adds :gpu-tagged
regression tests for both functions.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Reference PR #691 in the changelog entries
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Make getgraph GPU-native for COO graphs instead of CPU round-trip
The first cut fixed getgraph on the GPU by moving the graph to the CPU
and back. That works but forces a full device<->host sync and its cost
grows with the graph size.
Instead, express the COO path (the common case, which has a dense
graph_indicator) entirely with scatter/gather/cumsum, which run natively
on the GPU: build the node keep-mask from a per-graph boolean lookup,
relabel nodes via cumsum and graphs via a scatter, and select edges with
`node_mask[s]`. Indexing goes through the integer vectors
`kept_nodes`/`kept_edges` (one `findall` each) rather than repeated
boolean masks, to keep the number of GPU synchronizations low.
Adjacency-matrix graphs still fall back to the CPU: they need submatrix
indexing and store `graph_indicator` as a `SparseVector`, neither of
which is GPU-friendly.
The result stays on the original device and, on real hardware, avoids the
host transfer entirely; on large batches it is dramatically faster than
the round-trip. The GPU test now covers all graph types (COO native +
sparse/dense fallback), node/edge features, weights, and `nmap`.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* docs(AGENTS): document running and reproducing GPU tests
Add a local CUDA test command and note the cuDNN / allowscalar(false)
setup needed to reproduce a :gpu test item in the REPL — the gotcha being
that gpu_device() silently falls back to the CPU when cuDNN isn't loaded.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: AGENTS.md
+7-1Lines changed: 7 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,6 +31,11 @@ Julia ≥ 1.10 is required (some tests, e.g. Mooncake, need ≥ 1.12). Thanks to
31
31
julia --project=GraphNeuralNetworks -e 'using Pkg; Pkg.test("GraphNeuralNetworks")'
32
32
julia --project=GNNGraphs -e 'using Pkg; Pkg.test("GNNGraphs")'
33
33
34
+
# Run only the :gpu-tagged items on CUDA (works locally on a CUDA machine, not
35
+
# just in CI). The test harness auto-installs the backend (CUDA + cuDNN) and sets
36
+
# allowscalar(false); swap in GNN_TEST_AMDGPU / GNN_TEST_Metal for other backends.
37
+
GNN_TEST_CPU=false GNN_TEST_CUDA=true julia --project=GNNGraphs -e 'using Pkg; Pkg.test("GNNGraphs")'
38
+
34
39
# Build docs for one package
35
40
julia --project=GNNGraphs/docs GNNGraphs/docs/make.jl
36
41
@@ -42,7 +47,8 @@ julia -e 'using JuliaFormatter; format(".")'
42
47
Test files define independent `@testitem "..." setup=[TestModule] begin ... end` blocks. `runtests.jl` in each package just calls `@run_package_tests` with a tag filter. Shared fixtures and exports live in each package's `test/test_module.jl` (`TestModule`).
43
48
44
49
-**Run a single test item**: use the VS Code Julia extension's test-item UI, or filter in `runtests.jl`. Test items are self-contained, so you can also copy one into a REPL after `include("test/test_module.jl")`.
45
-
-**GPU tests** are tagged `:gpu`; untagged items are CPU tests. Backend selection is via env vars read in `runtests.jl` and `test_module.jl`: `GNN_TEST_CPU` (default `"true"`), `GNN_TEST_CUDA`, `GNN_TEST_AMDGPU`, `GNN_TEST_Metal`. CPU CI runs untagged items; GPU CI (Buildkite, `.buildkite/pipeline.yml`) sets `GNN_TEST_CPU=false` and a backend var to `true`.
50
+
-**GPU tests** are tagged `:gpu`; untagged items are CPU tests. Backend selection is via env vars read in `runtests.jl` and `test_module.jl`: `GNN_TEST_CPU` (default `"true"`), `GNN_TEST_CUDA`, `GNN_TEST_AMDGPU`, `GNN_TEST_Metal`. CPU CI runs untagged items; GPU CI (Buildkite, `.buildkite/pipeline.yml`) sets `GNN_TEST_CPU=false` and a backend var to `true`. `test_module.jl``Pkg.add`s the backend on demand, so it need not be in `test/Project.toml`.
51
+
-**Exercise a `:gpu` item in the REPL**: inside a `@testitem`, `dev = gpu_device(force=true)` and helpers like `AbstractGPUDevice` come from the package's test-module setup (`GraphsTestModule` in GNNGraphs). To reproduce the same environment interactively, load the backend the way the harness does — for CUDA that means `using CUDA, cuDNN` (**cuDNN is required**; without it `gpu_device()` reports "no functional GPU backend" and silently falls back to the CPU) — then set `CUDA.allowscalar(false)` so any accidental scalar indexing errors instead of running slowly (this is what catches most GPU regressions, e.g. graph ops that materialize a CPU mask).
0 commit comments