Repository navigation
perf(structure): renumbering degrees from sort run lengths; symmetric minor degrees from offsets - #4
Merged
Conversation
`sort_and_compress_edgelist` sorted `(major, minor)` through a zip iterator of two columns. A tuple key makes Thrust use its comparison merge sort. After renumbering both endpoints are offsets into their vertex ranges, so `(major - major_range_first) << minor_bits | (minor - minor_range_first)` is one unsigned 64-bit key whenever the two widths sum to at most 64 bits, and Thrust sorts it with a radix sort. Both sorts are stable, so parallel edges and their values keep their input order. With 8-byte vertex IDs the key overwrites the minor column in place and the major column is freed before the sort. The unweighted overload then needs no quarter partitioning: the keys and the radix copy fit in the two input columns' 16 bytes per edge, where the memory-frugal path held 20. The weighted overload keeps the quarter partitions of 5fddb4f and moves each value with its key (30 to 24 bytes per edge with 8-byte weights). With 4-byte IDs the key needs its own buffer. Outside the memory-frugal path the per-edge peak is unchanged and the radix sort adds a fixed scratch of at most 57 MiB. Inside it a packed quarter would hold more than the merge sort does, so that path keeps the merge sort. Ranges that do not fit 64 bits keep the existing code. On a 96 GB GPU, constructing an unweighted graph with 1,740,318,538 edges and 88,180,447 vertices from Int64 IDs: the graph algorithm task of a whole-table PageRank drops from 5.864 s to 4.880 s with identical scores. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…engths compute_renumber_map sorted a copy of the edge majors to find the unique vertices, dropped the multiplicities, and then recovered each vertex's degree with a binary search over the sorted vertex list and an atomic increment for every edge. On a graph of 1.74 billion edges and 88 million vertices that single for_each takes 0.58 s. The single-GPU path now keeps the run lengths of the sorted majors (find_uniques_and_counts). The memory-frugal split counts each half, adds the second half's count of a shared vertex into the first half's, and unions the two key lists. The degrees are then placed with one search per vertex. A caller-supplied vertex list takes the same path. The multi-GPU branch, which sums degrees across ranks, is unchanged. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…or offsets compute_out_degrees on a transposed graph, and compute_in_degrees on a non-transposed one, ran a pass over every edge (compute_minor_degrees). In a symmetric graph each vertex's in-degree equals its out-degree, which adjacent major offsets give directly. Unweighted PageRank on an undirected graph calls compute_out_degrees once; on 1.74 billion edges that pass takes 0.13 s. The shortcut applies when the graph is symmetric and has no edge mask. An attached mask is not guaranteed to keep the graph symmetric. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This was referenced Nov 20, 2026
Merged
Merged
Draft
morristai
added a commit
to algeon-dev/algeon
that referenced
this pull request
Nov 20, 2026
…t-degrees from offsets (cuGraph fork) (#91) Moves the cuGraph fork to algeon-dev/cugraph#4 (7d56328a2), stacked on the packed edge sort. Single-GPU renumbering sorted the edge majors to find the vertex set and then recovered every vertex's degree with a binary search and an atomic increment per edge: 0.58 s for the MerRec graph of 1.74 billion edges. The degrees now come from the run lengths of that sort. Unweighted PageRank on an undirected graph called compute_out_degrees, a pass over every edge of the transposed graph (0.13 s). A symmetric graph without an edge mask reads those degrees from the major offsets. Two tests cover the new paths through the C API: internal vertex order and degrees with and without the memory-frugal split, and degrees and PageRank on symmetric and directed graphs against a host computation. Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two changes to single-GPU graph construction and degree computation, stacked on #3. Upstream
main(62199a7e8) has the same code in both places.Measured with Nsight Systems on an undirected graph of
1,740,318,538edges and88,180,447vertices with Int64 ids, on an RTX PRO 6000 Blackwell (96 GB).Renumbering degrees from the major sort's run lengths (
renumber_edgelist_impl.cuh)compute_renumber_mapsorted a copy of the edge majors to find the unique vertices, discarded the multiplicities withunique, and then recovered each vertex's degree with athrust::for_eachover every edge: alower_boundover the sorted vertex list and an atomic increment. That kernel takes0.582 s, the largest single kernel in renumbering.find_uniques_and_countsreturns the sorted unique majors with their run lengths. The memory-frugal split counts each half, adds the second half's count of a shared vertex into the first half's (each vertex occurs once per half, so no atomics), and unions the two key lists.find_uniques_mem_frugal_thresholdholds the 3% rule that was written out twice.compute_sorted_local_major_degrees_without_atomicsstays for it.Peak temporary memory rises by the count array of the unique vertices (
U * sizeof(edge_t)), which now lives until the degrees are placed. With a caller-supplied vertex list the majors are now sorted, under the same memory-frugal rule; that path did not sort them before.Minor degrees of a symmetric graph from the major offsets (
graph_view_impl.cuh)compute_out_degreeson a transposed graph andcompute_in_degreeson a non-transposed one rancompute_minor_degrees, a pass over every edge. In a symmetric graph each vertex's in-degree equals its out-degree, which adjacent major offsets give. Unweighted PageRank on an undirected graph callscompute_out_degreesonce; that pass takes0.131 s.The shortcut applies when
is_symmetric()holds and no edge mask is attached (a mask is not guaranteed to keep the graph symmetric). It is applied to the single-GPU and multi-GPU specializations; the multi-GPU one is compiled and not exercised by a test here.Tests
In the Algeon repository (
components/cugraph/algeon-cugraph/src/graph/tests.rs), through the C API:test_renumbering_orders_vertices_by_major_degree_with_and_without_frugal_uniques: out-degrees against a host count and non-increasing internal order, for 4-byte and 8-byte ids, a cap that reaches the memory-frugal split and one that does not, vertices that appear only as destinations, skewed multigraphs, and a supplied vertex list with isolated vertices.test_transposed_out_degrees_and_pagerank_match_host_for_symmetric_and_directed_graphs: degrees and unweighted PageRank against a host power iteration on a symmetric and a directed graph.Mutations that fail them: the frugal merge dropping the second half's counts, each vertex taking its neighbor's count, the shortcut applied to a directed graph.
Not timed after the change.