Skip to content

perf(kumo-pytorch): skip projecting materialized entity columns - #381

Merged
Vedaant-J merged 1 commit into
mainfrom
perf/skip-materialized-projections
Nov 18, 2026
Merged

Vedaant-J merged 1 commit into
mainfrom
perf/skip-materialized-projections

Conversation

@Vedaant-J

Copy link
Copy Markdown
Contributor

Summary

On the native DiskGraph batch path, entity value Field columns that are already materialized into the enriched anchors are no longer added to the entity table's projections. Batches read those values from the anchor columns, and _direct_entity_arrays already skips them, so decoding them for every seed was unused work.

  • NativeAnchors.batches computes the list of non-materialized entity Field columns once and reuses it for the graph projections and for the typed-batch projections.
  • Entity value columns that are not materialized are still projected. Graph node_fields on the entity table are unchanged.
  • No output changes: on the benchmark below, a hash of every batch's output matched with and without this change.

Change map: see the kumo-pr-change-map comment on this PR.

Testing Done

Environment: Linux x86_64, Python 3.12, diskgraph built from this tree, kumo-pytorch installed editable from this tree.

  • New regression test: pytest packages/experimental/kumo-pytorch/tests/test_native_anchor_handoff.py -k test_materialized_entity_fields_skip_projection_and_keep_graph_reuse. It checks that a materialized entity Field is absent from every projection passed to the native iterator, and that graph topology is reused rather than sampled again. It fails on main and passes here.
  • pytest packages/experimental/kumo-pytorch/tests/test_native_anchor_handoff.py packages/experimental/kumo-pytorch/tests/test_materialized_native_batches.py: 48 passed.
  • Broader native/materialization run across 12 kumo-pytorch test files: 380 passed, 1 skipped.
  • ruff check and ruff format --check (0.17.3) on the touched files: clean.

Benchmark (synthetic 200k-entity table with 8 static columns, native model batches):

Per batch Per epoch
main ~5.3–5.5 ms baseline
This PR ~4.5 ms ~15% faster

Output hash was identical across both runs.

Not tested: GPU training, multi-process (world_size > 1) runs on real hardware, and the kumo-engine wheel smoke suite. The change only removes columns that no consumer reads, and the unchanged _feature_arrays path falls back to a direct fetch if a projected column is ever missing.

Checklist

  • I listed all the breaking changes introduced by the PR (none)
  • I made sure to update examples and documentation with my changes (if necessary) (not needed)
  • I have added and modified unit tests required to cover changes made by this PR.

🤖 Generated with Claude Code

Native batches read materialized entity values from the enriched anchor
columns, so decoding the same entity-table columns for every seed was
unused work. Project an entity value column only when it is not
materialized.

Co-Authored-By: Claude <[email protected]>
@Vedaant-J

Copy link
Copy Markdown
Contributor Author

Change map

File Function / scope What changed Why
packages/experimental/kumo-pytorch/src/kumo/pytorch/engines/native_anchors.py NativeAnchors.batches Computes the non-materialized entity Field columns once (entity_columns) and extends the entity table projections with that list in both the graph-projection and typed-batch branches, instead of appending every entity Field column. Columns already in _materialized_values.features are read from the enriched anchors, so projecting them decoded unused data for every batch.
packages/experimental/kumo-pytorch/tests/test_native_anchor_handoff.py test_materialized_entity_fields_skip_projection_and_keep_graph_reuse New test: one materialized entity Field with a graph input, spies on the native iterator projections and forbids graph resampling. Checks the materialized column is never projected and that native graph reuse (_anchor_neighborhood) still holds.
  • Problem: with materialized entity values, every native batch decoded entity-table columns that no consumer reads (~15% of epoch time on a synthetic 200k-entity, 8-column table).
  • Existing behavior: _direct_entity_arrays and the temporal plan already skip materialized entity values, but NativeAnchors.batches still added their columns to the projections.
  • Smallest change: filter the projected entity columns by the same materialized-feature keys. Non-materialized entity values and graph node_fields are projected as before.
  • Focused check: the new test fails on main and passes here. test_native_anchor_handoff.py and test_materialized_native_batches.py pass, and the benchmark output hash is unchanged.
  • Stop: projection selection only. Batch assembly, sampling plans and the fallback request path are unchanged.

@copy-pr-bot

copy-pr-bot Bot commented Nov 17, 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.

@Vedaant-J
Vedaant-J temporarily deployed to gha-kumo-workflow-tests November 17, 2026 23:30 — with GitHub Actions Inactive
@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Explain Change →

Walkthrough

Native batching now excludes direct entity fields from entity-table projections when those fields are already present in materialized features. A test checks this behavior for the score field and verifies batching across train and valid.

Merge Risk: Minimal · up to 6709c

This is a narrow performance optimization that skips projecting entity columns already supplied by materialized features. No concrete correctness risk was found. A test could additionally assert the returned score values.

Security architecture risk: Minimal · up to 6709c

The change avoids reading entity columns whose values already come from materialized anchors. Other entity fields, graph features, and graph identity projections remain available. The inspected change establishes no introduced or worsened security or failure-containment risk.

Pre-merge checks: Passed 2 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Change Map Design Review Inconclusive The check reviews the PR conversation comment that starts with <!-- kumo-pr-change-map -->. That comment is not in the supplied context. The review comments section lists no CodeRabbit threads. The … To complete this check, supply the text of the PR conversation comment that begins with <!-- kumo-pr-change-map --> (PR #381). Then re-run the check. The review will test the table's rows against the diff in `native_anch…
Passed Passed checks: 2 passed

Check name Status Explanation
Pr Size Passed The PR changes 2 files, below the threshold of 40. git diff --name-status between the review base and head lists two modified files: `packages/experimental/kumo-pytorch/src/kumo/pytorch/engines/nati…
Public Resource Access Passed The check applies only to external resource references (URLs, repository locations, package source locations) that this PR adds or modifies. The PR changes two files: `packages/experimental/kumo-pytor…
Full details: Pr Size

Explanation

The PR changes 2 files, below the threshold of 40. git diff --name-status between the review base and head lists two modified files: packages/experimental/kumo-pytorch/src/kumo/pytorch/engines/native_anchors.py and packages/experimental/kumo-pytorch/tests/test_native_anchor_handoff.py. No renames or additions appear. Per the check, line counts are ignored, and the file count does not exceed 40, so the check passes.

Full details: Public Resource Access

Explanation

The check applies only to external resource references (URLs, repository locations, package source locations) that this PR adds or modifies. The PR changes two files: packages/experimental/kumo-pytorch/src/kumo/pytorch/engines/native_anchors.py (+8/-6) and packages/experimental/kumo-pytorch/tests/test_native_anchor_handoff.py (+47). I read every added line of the diff against the pre-merge-check base. None contains an http(s):// URL, a git+/git@ source, a GitHub/PyPI reference, an index URL, or a find-links location. The added code consists of Python identifiers, a filtered column list in NativeAnchors.batches, and a regression test that writes a local parquet fixture under tmp_path. Local fixtures are excluded by the check. The PR description contains a reference to a kumo-pr-change-map comment, but that text is in the PR body, not in the changed files, so it is not a changed repository reference. With no added or modified external reference, the check passes.

Full details: Change Map Design Review

Explanation

The check reviews the PR conversation comment that starts with &lt;!-- kumo-pr-change-map --&gt;. That comment is not in the supplied context. The review comments section lists no CodeRabbit threads. The PR description only refers to it as "the kumo-pr-change-map comment on this PR". A search of the checkout found the marker only in docs/development/review.md, which describes the convention and does not contain the comment. Without the comment text, I cannot check its Change map rows, its stated failure or observed problem, its verification, or its stopping condition. Code evidence from the PR diff (context only, not a verdict on the table): - native_anchors.py computes entity_columns once. It keeps direct Field entity values with no path whose key is not in _materialized_values.features. Both projection paths then extend with that list. - diskgraph.py:1037 (_direct_entity_arrays) already skips the same materialized feature names. This supports the PR's claim that the projection was unused work. - The diff does not change the _feature_arrays fallback. Whether a missing projected column is handled safely was not verified here. - The PR adds one regression test, test_native_anchor_handoff.py. I did not read it. I did not confirm any design defect in the code.

Resolution

To complete this check, supply the text of the PR conversation comment that begins with &lt;!-- kumo-pr-change-map --&gt; (PR #381). Then re-run the check. The review will test the table's rows against the diff in native_anchors.py and the test in test_native_anchor_handoff.py. It will also check that diskgraph.py:_direct_entity_arrays and the _feature_arrays fallback match the stated behavior.

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

@Vedaant-J
Vedaant-J marked this pull request as ready for review November 18, 2026 00:58

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick comments: 1

packages/experimental/kumo-pytorch/tests/test_native_anchor_handoff.py: 1

718-719: Trivial · Maintainability & Code Quality · Quick win

Assert the returned materialized scores.

These assertions check sample count and projection omission, but they do not check the returned score values. The test can pass if batching assigns incorrect scores.

Compare scores by sample ID. Samples a, b, and f must have 0.5; samples c, d, and g must have 1.5. This directly checks that removing the projection preserves entity values.

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 9637e9c and 6709c28.

Files selected for processing: 2

  • packages/experimental/kumo-pytorch/src/kumo/pytorch/engines/native_anchors.py
  • packages/experimental/kumo-pytorch/tests/test_native_anchor_handoff.py

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

@Victsm Victsm left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removes unused entity-column decoding while retaining columns needed by graph features. Independently verified exact materialized scores and shared-column graph features; focused suite passed. No correctness blockers found.

@Vedaant-J
Vedaant-J merged commit 4597363 into main Nov 18, 2026
119 checks passed
@Vedaant-J
Vedaant-J deleted the perf/skip-materialized-projections branch November 18, 2026 19:06

This branch was previously deployed

1 inactive deployment
gha-kumo-workflow-tests — 6709c281 Deployed Nov 17, 2026 by Vedaant-J via import #2537
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