Skip to content

Support tables without primary keys in kumo.pytorch - #267

Merged
bberger62 merged 1 commit into
mainfrom
feat/pytorch-keyless-tables
Nov 12, 2026
Merged

bberger62 merged 1 commit into
mainfrom
feat/pytorch-keyless-tables

Conversation

@bberger62

@bberger62 bberger62 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Allow non-entity tables without primary keys in kumo.pytorch, following DiskGraph's existing row identity. For example, events(owner FK → users.id, at, amount) can supply histories, aggregates and graph neighbors without an artificial event key. Entity/root and candidate entity declarations still require a PK.

This ports rdl-platform#139 into the API's new home at packages/experimental/kumo-pytorch, introduced by #244. The API implementation, tests and agreed examples are retained under the kumo.pytorch namespace. The standalone dependency-pin changes are omitted: this package already uses the workspace DiskGraph, including merged native support from #184.

Where support is missing

The current TableSpec constructor rejects primary_key=None with table name and primary key must be non-empty, before the table reaches ingestion. Downstream API paths also assume every table has a PK: native ingestion configuration always declares one, temporal sequences project it, graph output reads it for identity, and serving requires it for row uniqueness and fetching.

DiskGraph already stores and traverses rows without PKs. Ingestion assigns native node IDs; graph sampling and temporal queries use those IDs to address individual occurrences. External PK lookup is a separate requirement for choosing entities. This change carries that existing distinction through the API.

Implementation and intended behavior

  • Accept TableSpec(..., primary_key=None) and build.Table(..., key=None). A shared declaration check rejects PK-less sample/candidate entities before binding, type inference or source access.
  • Omit absent PK metadata and projections in the DiskGraph adapter. Use returned native node IDs for temporal and graph identity. Constant-only sequences project their existing clock to satisfy the native sequence API.
  • Use private source-occurrence ordinals in the in-memory test/serving paths. Keep separate source occurrences distinct, including equal-valued rows and aliases of the same input mapping. Repeated visits reuse an occurrence; distinct=True removes repeated visits rather than collapsing equal values.
  • Validate key presence/uniqueness and request PK columns in rows_spec only for keyed tables. Update authored documentation and regenerate the public API reference.

No source key generation, additional identity column or persistent identity inventory is introduced. Existing keyed ordering, entity lookup, source cleanup and unsupported-operation checks retain their behavior. Native source, workspace packaging and dependencies are unchanged by this PR.

The new G-KEYLESS-001 guarantee has two hand-calculated examples:

Case Input Required answer
C-KEYLESS-001 Identical amount-2 events at time 9, amount 3 at 10, and future amount 100 at 11. Cutoff 9: count 2, sum 4. Cutoff 10: count 3, sum 7. Recent (9,10] count 1. Empty history: count/sum 0.
C-KEYLESS-002 Two links revisit the same two identical eligible facts. Distinct count 2 / sum 4; repeated count 4 / sum 8. Future facts excluded.

Keyless IDs remain opaque and local to an index or prepared serving dataset. Reordering, repartitioning or serving subsets can change tied selections and floating reduction rounding. Occurrence multiplicity and integer reductions remain exact; stable cross-preparation identity requires a declared PK.

Testing Done

  • Full CPU suite: 1,926 passed, 3 GPU skips and 47 opt-in end-to-end/notebook checks deselected.
  • Complete conformance: 705 passed, with no skipped or deselected obligations, including DiskGraph and the in-memory differential checks.
  • Installed wheels: 41 passed for keyless/entity behavior and the README quick start, followed by all 3 example notebooks passing with exact committed-file comparisons.
  • Fresh independent adversarial review: 26 focused keyless tests, four case/engine golden checks, and additional alias, NULL-FK, repeated-visit, multi-file/shard, graph and serving probes passed.
  • Source/wheel builds, Ruff 0.17.3 lint/format, generated API/limitations freshness, whitespace checks and the repository-wide SPDX check passed.

Validation uses Python 3.12 on CPU, with DiskGraph built from this branch's in-tree source. The editable package is kumo.pytorch; the old rdl-pytorch editable install was removed. Installed-wheel checks use a separate environment and staged tests/docs/examples without src/; both API and engine imports were verified to come from the installed wheels.

From packages/experimental/kumo-pytorch:

CUDA_VISIBLE_DEVICES='' python -m pytest -q --require-imports
CUDA_VISIBLE_DEVICES='' python -m conformance --engine all
python -m tests.api_reference
python -m tests.limitations_reference
python -m ruff check .
python -m ruff format --check .

Both the source distribution and its wheel build successfully. The installed-wheel gate also exercises the README, keyless/entity tests and example notebooks. Ruff uses the CI pin, 0.17.3. Native compilation used the existing Rust 1.98 compiler; CI uses the repository's pinned toolchain. No GPU or live-service validation is claimed.

Earlier standalone benchmarks measured roughly 4% additional in-memory test-engine time and 6.3% retained source heap. Those historical measurements were not repeated for this monorepo port.

Migration and review

All 26 existing touched files matched the imported base after namespace conversion; the four new guarantee/test files had no collisions. This is the same RDL feature moved into the monorepo, with no additional behavior or altered golden answers. The new package's existing CPU, DiskGraph, notebooks and installed-wheel workflows cover the changed paths.

Independent adversarial review found no actionable issues. It executed all 26 focused keyless cases and four golden case/engine combinations, plus multi-file/shard, NULL-FK, aliased-row, repeated-visit, graph and serving probes. It also checked namespace coexistence and verified that all 67 Python modules in the built wheel match source byte-for-byte.

Change map

File-by-file change map.

Reviewed at: e7a75e6

@copy-pr-bot

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

@bberger62
bberger62 temporarily deployed to gha-kumo-workflow-tests November 9, 2026 16:29 — with GitHub Actions Inactive
@coderabbitai

coderabbitai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change allows non-entity tables to omit a primary key. Keyless rows remain separate occurrences in the in-memory and diskgraph engines, and serving preserves those occurrences. Entity and candidate samples that reference keyless tables are rejected during validation. New documentation, guarantees, conformance cases, and tests cover keyless table behavior, including identity and ordering limits.

Merge Risk: Minimal · up to e7a75

This change lets non-entity tables omit a primary key while keeping identical rows as separate occurrences. Entity and candidate tables still require keys. No concrete merge-blocking risk was identified in the supplied evidence.

Security architecture risk: Low · up to e7a75

The inspected changes preserve keyed entity lookup, declared relation traversal and per-call serving isolation. No introduced security issue was established. Keyless identifiers are deliberately local to each preparation and must not be treated as stable external identities. Review coverage remains incomplete.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated scope is non-entity row identity within caller-supplied serving tables or a bound prepared index. The inspected flows do not establish an expansion into another service, credential authority or environment; this is a scoped conclusion, not complete security coverage.

Trust Boundaries and Controls

  • observed — Caller-controlled schema and rows remain constrained by declared tables, columns and relations. Temporal compilation verifies relation connectivity and destination columns; graph feature reads retain explicit table context. These are data-scoping controls, not evidence of tenant authorization.

Resilience and Maintainability Implications

  • observed — Serving normalizes rows into fresh per-call containers, creates a new in-memory source and binds it to a copied prepared plan. The source is closed in finally. This contains partial batch failures and avoids retaining keyless occurrence state on the shared serving plan across repeated calls.
Pre-merge checks: Passed 2 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Change Map Design Review Inconclusive The marked change-map comment is not available for review. The supplied context contains only a summary and a link to the comment, not its text. The diff confirms changes to schema validation, entity … Provide the full <!-- kumo-pr-change-map --> conversation comment and the linked problem context so the proposed design and its stated rationale can be assessed against the code.
Passed Passed checks: 2 passed

Check name Status Explanation
Pr Size Passed The PR changes 30 files, which does not exceed the limit of 40.
Public Resource Access Passed The PR adds no external resource references. The added documentation links point to files in this repository.
Full details: Change Map Design Review

Explanation

The marked change-map comment is not available for review. The supplied context contains only a summary and a link to the comment, not its text. The diff confirms changes to schema validation, entity checks, and materialization, but it cannot establish the comment’s rationale, stopping condition, or treatment of optional refinements. The PR has 1,465 additions and deletions, so file-level descriptions are permitted.

Resolution

Provide the full &lt;!-- kumo-pr-change-map --&gt; conversation comment and the linked problem context so the proposed design and its stated rationale can be assessed against the code.

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

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 9bbc23d and e7a75e6.

Files selected for processing: 30

  • packages/experimental/kumo-pytorch/conformance/cases.py
  • packages/experimental/kumo-pytorch/conformance/expectations.json
  • packages/experimental/kumo-pytorch/conformance/spec/guarantees/G-ENTITY-001/guarantee.md
  • packages/experimental/kumo-pytorch/conformance/spec/guarantees/G-GRAPH-001/guarantee.md
  • packages/experimental/kumo-pytorch/conformance/spec/guarantees/G-KEYLESS-001/golden/C-KEYLESS-001.json
  • packages/experimental/kumo-pytorch/conformance/spec/guarantees/G-KEYLESS-001/golden/C-KEYLESS-002.json
  • packages/experimental/kumo-pytorch/conformance/spec/guarantees/G-KEYLESS-001/guarantee.md
  • packages/experimental/kumo-pytorch/conformance/spec/guarantees/G-SERVING-001/guarantee.md
  • packages/experimental/kumo-pytorch/docs/02-contracts.md
  • packages/experimental/kumo-pytorch/docs/06-inference-and-serving.md
  • packages/experimental/kumo-pytorch/docs/api/authoring.md
  • packages/experimental/kumo-pytorch/docs/api/engines.md
  • packages/experimental/kumo-pytorch/docs/api/samples.md
  • packages/experimental/kumo-pytorch/docs/api/schema.md
  • packages/experimental/kumo-pytorch/docs/limitations.md
  • packages/experimental/kumo-pytorch/src/kumo/pytorch/build.py
  • packages/experimental/kumo-pytorch/src/kumo/pytorch/contract/sample.py
  • packages/experimental/kumo-pytorch/src/kumo/pytorch/contract/schema.py
  • packages/experimental/kumo-pytorch/src/kumo/pytorch/engines/diskgraph.py
  • packages/experimental/kumo-pytorch/src/kumo/pytorch/engines/in_memory/engine.py
  • packages/experimental/kumo-pytorch/src/kumo/pytorch/engines/in_memory/graph.py
  • packages/experimental/kumo-pytorch/src/kumo/pytorch/engines/in_memory/samples.py
  • packages/experimental/kumo-pytorch/src/kumo/pytorch/materialization.py
  • packages/experimental/kumo-pytorch/src/kumo/pytorch/preparation.py
  • packages/experimental/kumo-pytorch/src/kumo/pytorch/serving.py
  • packages/experimental/kumo-pytorch/src/kumo/pytorch/serving_rows.py
  • packages/experimental/kumo-pytorch/src/kumo/pytorch/spec.py
  • packages/experimental/kumo-pytorch/tests/serving_fetch.py
  • packages/experimental/kumo-pytorch/tests/test_entity_identity.py
  • packages/experimental/kumo-pytorch/tests/test_keyless_tables.py

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

@bberger62

Copy link
Copy Markdown
Contributor Author

Change map

Observed failure: kumo.pytorch rejects an FK-only event table at TableSpec construction even though the workspace DiskGraph already supports it. Make the PK optional only for non-entity tables, preserve native/source-occurrence identity through existing paths, and keep entity lookup keyed. Completion means histories, reductions, graph sampling and serving preserve occurrence multiplicity without generated keys; keyed behavior remains intact. The old standalone dependency-pin changes are omitted because both packages now share this workspace. Verification passed: 1,926 CPU tests, 705 complete conformance checks, 41 installed-wheel checks, all three example notebooks, and independent adversarial review.

File Function / scope What changed Why
packages/experimental/kumo-pytorch/conformance/cases.py load_case Skip only absent PK validation for keyless fixtures; retain exact columns and keyed uniqueness. Let the real conformance loader exercise keyless declarations.
packages/experimental/kumo-pytorch/conformance/expectations.json C-KEYLESS-001 / C-KEYLESS-002 Require both new golden answers on DiskGraph and the in-memory test engine. Execute the new behavior without skips or changed old answers.
packages/experimental/kumo-pytorch/conformance/spec/guarantees/G-ENTITY-001/guarantee.md Entity identity Keep PKs mandatory for external entity selection while allowing non-entity keyless tables. Preserve schema-owned entity lookup.
packages/experimental/kumo-pytorch/conformance/spec/guarantees/G-GRAPH-001/guarantee.md Occurrence identity and tied sampling Specify separate nodes and index-local identity for keyless occurrences. Match DiskGraph native identity without promising stable IDs across rebuilds.
packages/experimental/kumo-pytorch/conformance/spec/guarantees/G-KEYLESS-001/golden/C-KEYLESS-001.json Hand-calculated temporal fixture Identical events, cutoff equality, recent window, future exclusion and empty history. Require exact counts and integer sums from separate occurrences.
packages/experimental/kumo-pytorch/conformance/spec/guarantees/G-KEYLESS-001/golden/C-KEYLESS-002.json Hand-calculated repeated traversal fixture Two paths revisit identical facts with distinct and non-distinct selection. Distinguish repeated visits from separate equal-valued rows.
packages/experimental/kumo-pytorch/conformance/spec/guarantees/G-KEYLESS-001/guarantee.md Optional PK and occurrence semantics Define non-entity keyless support, distinctness, time boundaries and local-ID limits. State the behavior independently of either implementation.
packages/experimental/kumo-pytorch/conformance/spec/guarantees/G-SERVING-001/guarantee.md Key validation and local identities Only declared keys require uniqueness; document keyless serving identity/order boundaries. Preserve duplicate occurrences and avoid claiming cross-preparation stable IDs.
packages/experimental/kumo-pytorch/docs/02-contracts.md Schema authoring Explain primary_key=None for non-entity tables. Make the new declaration discoverable.
packages/experimental/kumo-pytorch/docs/06-inference-and-serving.md Caller-supplied rows Explain duplicates and local identities for keyless tables. Describe what callers must supply and what ordering can vary.
packages/experimental/kumo-pytorch/docs/api/authoring.md Generated public API reference Regenerate optional-key, distinctness and tie-order documentation from source docstrings. Keep the reference current for the migrated namespace.
packages/experimental/kumo-pytorch/docs/api/engines.md Generated public API reference Regenerate optional-key, distinctness and tie-order documentation from source docstrings. Keep the reference current for the migrated namespace.
packages/experimental/kumo-pytorch/docs/api/samples.md Generated public API reference Regenerate optional-key, distinctness and tie-order documentation from source docstrings. Keep the reference current for the migrated namespace.
packages/experimental/kumo-pytorch/docs/api/schema.md Generated public API reference Regenerate optional-key, distinctness and tie-order documentation from source docstrings. Keep the reference current for the migrated namespace.
packages/experimental/kumo-pytorch/docs/limitations.md Entity keys and event ordering Separate required entity PKs from optional non-entity PKs. Keep supported behavior and remaining limits clear.
packages/experimental/kumo-pytorch/src/kumo/pytorch/build.py Table and reduction descriptions Accept key=None and document occurrence distinctness. Expose the same declaration through the authoring API.
packages/experimental/kumo-pytorch/src/kumo/pytorch/contract/sample.py Rows.distinct and SampleSpec.events descriptions Describe row occurrence identity when a destination has no PK. Keep authored API docs aligned with runtime behavior.
packages/experimental/kumo-pytorch/src/kumo/pytorch/contract/schema.py TableSpec Permit primary_key=None while validating any declared key. Remove the universal PK requirement at declaration time.
packages/experimental/kumo-pytorch/src/kumo/pytorch/engines/diskgraph.py Temporal compiler/output and graph identity Omit absent PK projections; use returned native node IDs. Follow DiskGraph identity instead of fabricating source keys.
packages/experimental/kumo-pytorch/src/kumo/pytorch/engines/in_memory/engine.py Engine description Condition key validation and tie descriptions on declared keys. Keep test-engine documentation accurate.
packages/experimental/kumo-pytorch/src/kumo/pytorch/engines/in_memory/graph.py Identity, sampling, deduplication and output Use local occurrence ordinals for keyless nodes and revisits. Retain distinct identical rows while reusing repeatedly visited nodes.
packages/experimental/kumo-pytorch/src/kumo/pytorch/engines/in_memory/samples.py _Row, identity and distinct selection Store occurrence ordinals and skip PK validation only when no PK is declared. Preserve multiplicity in histories and reductions.
packages/experimental/kumo-pytorch/src/kumo/pytorch/materialization.py _compile_diskgraph_config Omit the primary_key setting when absent. Use existing native ingestion support unchanged.
packages/experimental/kumo-pytorch/src/kumo/pytorch/preparation.py _check Reject keyless entity declarations before binding or schema resolution. Refuse invalid entity identity before source access.
packages/experimental/kumo-pytorch/src/kumo/pytorch/serving.py Row checks and entity presence Enforce key checks only on keyed tables. Accept separate identical keyless records while retaining entity checks.
packages/experimental/kumo-pytorch/src/kumo/pytorch/serving_rows.py Route columns and limits Do not request a nonexistent PK; describe occurrence tie identity. Make the serving fetch specification sufficient for keyless tables.
packages/experimental/kumo-pytorch/src/kumo/pytorch/spec.py validate and _entity_key_issues Require declared PKs for sample and candidate entities. Keep entity validation shared and early.
packages/experimental/kumo-pytorch/tests/serving_fetch.py Reference fetch helper Preserve occurrence identity across aliases and repeated routes. Exercise serving without collapsing equal-valued records.
packages/experimental/kumo-pytorch/tests/test_entity_identity.py Malformed PK declaration case Replace the formerly invalid None case with a truly invalid key name. Retain negative validation coverage for the expanded API.
packages/experimental/kumo-pytorch/tests/test_keyless_tables.py End-to-end keyless cases Cover entity refusal, both output formats, graphs, targets, constant fields, serving and inference. Test public APIs and keyed compatibility at the new package home.

@bberger62
bberger62 marked this pull request as ready for review November 9, 2026 16:30
@bberger62
bberger62 requested a review from lambyqq November 9, 2026 16:34
@bberger62

Copy link
Copy Markdown
Contributor Author

/ok to test e7a75e6

@lambyqq lambyqq left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approving. Two non-blocking test comments:

  1. test_keyless_tie_order_survives_an_ordered_serving_subset pins in-memory ordinal behavior that G-KEYLESS-001 / G-SERVING-001 deliberately don't promise, and DiskGraph doesn't have it. Suggest dropping it.
  2. Consider a DiskGraph test that a relation between two keyless tables (or a keyless column and a non-PK column) is refused by check() with DG-RELATION-KEYS. Today the only relation-shape test is in-memory-only (test_keyless_non_primary_key_relation_remains_valid_on_reference).

@lambyqq

lambyqq commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

@bberger62 once this merges, could you close kumo-ai/rdl-platform#139 and #59 (superseded by this port)?

@bberger62
bberger62 merged commit b0da9fa into main Nov 12, 2026
126 checks passed
@bberger62
bberger62 deleted the feat/pytorch-keyless-tables branch November 12, 2026 21:09
bberger62 added a commit that referenced this pull request Nov 24, 2026
## Summary

Follow-up to [Siyang's review of
#267](#267 (review)),
addressing both non-blocking test comments.

The serving-subset test asserted that an equal-timestamp, limited
keyless history must choose the same row before and after rebuilding
from a subset. G-KEYLESS-001 and G-SERVING-001 deliberately leave
keyless IDs and equal-time tie ordering local to each preparation.
Remove this test so the suite does not promise behavior the API and
DiskGraph do not guarantee. Existing occurrence-preservation and serving
graph checks remain.

Add parameterized DiskGraph coverage for relations joining two keyless
tables and relations joining a keyless column to a keyed table's non-PK
column. Both shapes lack the one primary-key side DiskGraph requires.
Assert that public `check()` reports `DG-RELATION-KEYS` at the offending
relation and `prepare()` refuses the contract before opening the engine.
The in-memory positive test remains because its reference joins support
these relation columns.

This changes one test file; runtime behavior and published guarantees
are unchanged.

## Change map

[File-by-file change map and
scope](#314 (comment)).

## Testing Done

From `packages/experimental/kumo-pytorch`, using the workspace
environment and `PYTHONPATH=src CUDA_VISIBLE_DEVICES=''`:

- `python -m pytest -q tests/test_keyless_tables.py
tests/test_diskgraph_unsupported.py --require-imports` — **56 passed**,
including DiskGraph coverage.
- `ruff check tests/test_keyless_tables.py` and `ruff format --check
tests/test_keyless_tables.py` — passed.
- `git diff --check` — passed.

## Checklist

- [x] Reviewed breaking changes: none.
- [x] Reviewed examples and documentation: no updates needed.
- [x] Updated focused test coverage.

Co-authored-by: Codex <[email protected]>

This branch was previously deployed

1 inactive deployment
gha-kumo-workflow-tests — e7a75e61 Deployed Nov 9, 2026 by bberger62 via import #1849
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.

3 participants