Skip to content

diskgraph: process each layer's node types in type-id order - #100

Merged
Vedaant-J merged 1 commit into
mainfrom
vedaant/dg-sampler-type-order
Oct 27, 2026
Merged

Vedaant-J merged 1 commit into
mainfrom
vedaant/dg-sampler-type-order

Conversation

@Vedaant-J

@Vedaant-J Vedaant-J commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR makes DiskGraph sampling output reproducible: the same request with the same random_seed now returns the same local node ids and the same edge order every time.

Problem.

  • Two runs of the same sampling request return the same set of nodes and edges but in a different order, with different local ids. A run cannot be compared row by row with an earlier one, and a regression test cannot pin an exact output.
  • At 50B (diskgraph: compute offset chunk positions instead of a per-process directory #93), 2 of 7 sampled tables changed row order between two runs of the same build.

Cause. In each layer, process_layer builds its work queue by iterating SamplingState::type_states, a gxhash map; the fused path's final feature flush iterates the same map. Its hasher is randomly seeded per map instance, so each pooled or fresh SamplingState iterates node types in a different order. When more than one node type is on the frontier, as in every layer after the first in a heterogeneous graph, the type processed first gets the lower local ids for the destinations they share, and its edges are emitted first.

Change. The work queue and the fused path's final feature flush are both processed in node type id order. Nothing else changes.

Back-compat

Situation Behaviour
Same request, same seed, repeated Identical output (previously varied between states).
Output compared with a run of an older build Same nodes and edges per seed; local ids and edge order match one of the orders the older build could already produce.
Single node type on the frontier Unchanged.
Fused feature-fetching path Sampling and the final feature flush in type-id order; fused feature batches arrive in the same order every run.

Testing Done

  • New repeated_runs_give_identical_output: two node types that both reach the same destination type in one hop; 16 fresh states per run, fused and non-fused; edges, node records and fused feature batches must be identical. It fails on main, and also fails if only the flush is left unsorted.
  • On 100M- and 1B-row synthetic indexes, 6 batches of 512 seeds at 2–6 hops gave identical edges, nodes, frontiers and stats across fresh states (part of the stacked PR's real-graph test).
  • cargo test -p diskgraph-engine --lib passes; clippy is clean on the changed code.

Checklist

  • No breaking changes.
  • Unit tests added.

🤖 Generated with Claude Code

@copy-pr-bot

copy-pr-bot Bot commented Oct 22, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between 0c895ce and 3d3504b.

📒 Files selected for processing: 2
  • packages/diskgraph/diskgraph-engine/src/engine.rs
  • packages/diskgraph/diskgraph-engine/src/tests_unit.rs

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 9 remain after this review.

📝 Walkthrough

The engine now orders frontier work and active type states for fused finalization by node type ID. A regression test runs two-seed-type uniform sampling 16 times with fused feature fetching disabled and enabled. It checks that each run emits four edges and verifies identical edges, rhs records, and fused batches across runs.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 3d350

No actionable merge-blocking risk is identified; the change is ready for normal checks.

Pre-merge checks: Passed 2 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Change Map Design Review Inconclusive The required PR conversation comment beginning with <!-- kumo-pr-change-map --> is not available in the supplied review context or repository checkout. The diff is available, but the check requires … Provide the PR conversation comment beginning with <!-- kumo-pr-change-map -->, including its Change map and rationale, then reassess the two changed files against that proposal.
Passed Passed checks: 2 passed
Check name Status Explanation
Pr Size Passed The pull request changes 2 files: engine.rs and tests_unit.rs. The count does not exceed 40.
Public Resource Access Passed The pull request adds no external resource reference. The changed lines only sort node-type IDs and add an in-repository unit test; they add no URL, repository location, or package source location.
Full details: Change Map Design Review

Explanation

The required PR conversation comment beginning with &lt;!-- kumo-pr-change-map --&gt; is not available in the supplied review context or repository checkout. The diff is available, but the check requires assessing the proposed Change map itself, including its stated failure, abstraction choice, verification, and stopping condition. Without that comment, the design assessment cannot be completed.

Resolution

Provide the PR conversation comment beginning with &lt;!-- kumo-pr-change-map --&gt;, including its Change map and rationale, then reassess the two changed files against that proposal.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@Vedaant-J

Vedaant-J commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Change map

File Function / scope What changed Why
packages/diskgraph/diskgraph-engine/src/engine.rs process_layer, sample_with_cutoff fused flush Sorts the layer's work queue and the fused final feature flush by node type id Local ids, edge order and fused batch order no longer depend on the randomly seeded type_states iteration order
packages/diskgraph/diskgraph-engine/src/tests_unit.rs new test repeated_runs_give_identical_output Two node types reaching the same destination type; 16 fresh states, fused and non-fused, must give identical edges, nodes and fused feature batches Pins reproducible output

The sampler built each layer's work queue, and the fused path its final
feature flush, by iterating a hash map whose hasher is randomly seeded
per sampling state, so which node type was committed first, and with it
local node ids, edge order and fused feature batch order, changed from
request to request. Both now go in type-id order, so the output is
reproducible for a fixed random seed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Vedaant-J
Vedaant-J force-pushed the vedaant/dg-sampler-type-order branch from 0c895ce to 3d3504b Compare October 22, 2026 20:32
@Vedaant-J
Vedaant-J temporarily deployed to gha-kumo-workflow-tests October 22, 2026 20:32 — with GitHub Actions Inactive
@Vedaant-J
Vedaant-J merged commit 3af5fde into main Oct 27, 2026
104 of 105 checks passed
@Vedaant-J
Vedaant-J deleted the vedaant/dg-sampler-type-order branch October 27, 2026 21:06

This branch was previously deployed

1 inactive deployment
gha-kumo-workflow-tests — 3d3504b8 Deployed Oct 22, 2026 by Vedaant-J via import #651
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants