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
kumo-pytorch: take the in-memory engine out of the serving path - #379
Design discussion or issue: follow-up to kumo-ai/rdl-platform#148 and #149
Summary
Cleanup: online serving no longer goes through the in-memory engine. DiskGraph is the one engine kumo-pytorch ships for real data; InMemoryEngine is a test and demo tool. Serving was never an engine job (the caller fetches the rows rows_spec lists, and the library turns them into batches with the artifact's fitted state), but ServingAssembler built an InMemoryEngine for its contract checks and assembled through InMemorySource.
The row-to-sample code (samples.py, graph.py) moves from engines/in_memory/ to a neutral kumo.pytorch.rows package, with a RowSource that serving uses. The in-memory engine's InMemorySource now subclasses RowSource and adds only what fitting needs (column statistics, text). Dependencies run one way: engines.in_memory imports rows, and serving imports nothing from engines.in_memory.
Times in rows are counted by a small Clock. The in-memory engine keeps whole seconds, and serving uses DiskGraph's clock: the finest timestamp unit the schema declares. The DiskGraph config now takes its timestamp_unit from the same Clock.of, so both share one rule.
ServingAssembler checks the contract without an engine preflight.
Docs, the regenerated API reference and G-SERVING-001 change only where a statement was no longer accurate (serving "uses the in-memory engine"; no test comparing served values with DiskGraph).
None, except one side effect: because serving no longer runs the in-memory engine's checks, a contract with ms/us/ns timestamps is now served in that clock instead of being refused at ServingAssembler construction. The tie rule at a recent fanout limit and graph node order are unchanged.
Testing Done
From packages/experimental/kumo-pytorch, with DiskGraph built from this branch's packages/diskgraph:
New tests in tests/test_serving.py compare ServingAssembler output value for value with DiskGraphEngine batch inference (plan.materialize(..., inference=True)): for the example, bounded-window and event-limit contracts, and for a contract on microsecond and on nanosecond clocks (window, recency and event ages). The existing serving tests against in-memory batch inference are unchanged and pass.
Checklist
I listed all the breaking changes introduced by the PR (none; internal modules moved: kumo.pytorch.engines.in_memory.samples/graph are now kumo.pytorch.rows.samples/graph)
I made sure to update examples and documentation with my changes (if necessary)
I have added and modified unit tests required to cover changes made by this PR.
Row-to-sample assembly moves from engines/in_memory to the neutral
kumo.pytorch.rows package (RowSource, Clock); ServingAssembler and the
in-memory engine both use it, and serving imports nothing from
engines.in_memory. Serving no longer runs the in-memory engine's contract
checks, so it now counts time in DiskGraph's clock instead of refusing
sub-second timestamps. Tie and node order are unchanged.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Requested change: online serving must not depend on the in-memory engine (follow-up to kumo-ai/rdl-platform#148 and #149). Before: ServingAssembler checked contracts with InMemoryEngine and assembled through InMemorySource. Smallest change: move the shared row assembly to a neutral package and point serving at it. Verified by the package suite, conformance on both engines, and new serving-vs-DiskGraph tests. Stopping condition: serving imports nothing from engines.in_memory, with no behavior change beyond the sub-second side effect.
Reviewing files that changed from the base of the PR and between d3b8963 and d3b8963.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
Note
.coderabbit.yaml has unrecognized properties
CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.
Parsing warnings: 1
Validation error: Unrecognized key: "tone_instructions" at "reviews"
If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Walkthrough
The change adds a schema-based clock for timestamp handling in row sampling, graph sampling, DiskGraph configuration, and serving. It introduces RowSource and routes serving batch assembly through it. Serving tests add comparisons with DiskGraph batch inference, including microsecond and nanosecond timestamp cases. Existing sampling tests now use the row-based builders.
Sequence Diagram(s)
sequenceDiagram
participant ServingAssembler
participant Clock
participant RowSource
participant RowSampleBuilder
ServingAssembler->>Clock: Derive clock from contract schema
ServingAssembler->>RowSource: Create source with supplied rows and clock
RowSource->>RowSampleBuilder: Build requested samples
RowSampleBuilder-->>RowSource: Return built samples
RowSource-->>ServingAssembler: Return batch data
Loading
Merge Risk: Moderate · up to d3b89
With sub-second timestamp contracts, candidate samples are evaluated at a much later time than their parent request and can include future events. Passing the original request time to candidate requests fixes this before merge. Second-based contracts are unaffected.
Security architecture risk: Low · up to d3b89
The time-handling change can give candidate features a later prediction cutoff than requested. Exposure is bounded to data already supplied by the caller, and normal training workflows constrain the affected combination. No broader access or privilege expansion was established.
Retained concerns
Low · architecture · inferred: Candidate construction reinterprets normalized ticks as epoch seconds. RowSampleBuilder converts the primary request time into ticks, then passes that integer as the recursive candidate request's as_of_time. For millisecond, microsecond, and nanosecond clocks, the child converts it again. Candidate aggregates with an unbounded historical window can therefore include supplied rows later than the primary prediction time, contrary to CandidateSetSpec's same-time contract. Seconds clocks are unaffected. The new exported row API exposes this combination directly; ordinary serving exposure is constrained by the shipped engines' candidate-set and subsecond-schema restrictions.
Security review details
Security Blast Radius
observed — The inspected serving path processes only caller-supplied tables and requests; it does not fetch additional records. Row builders normalize supplied values and maintain instance-local row collections and indexes. The identified cutoff issue changes selection within those supplied rows, not access to another data store.
Trust Boundaries and Controls
observed — Removing engine preflight does not remove generic contract resolution and validation. Serving still requires complete fitted state belonging to the contract, validates supplied table and column declarations and types, rejects null or duplicate primary keys, and checks requested entity and candidate presence. These controls do not validate recursive clock-unit inheritance.
Resilience and Maintainability Implications
observed — Each assembly call creates its own row source and binds it through a copied plan rather than replacing the reusable plan's source. Batch construction completes inside a finally-protected scope, and the source holds no open resources. These lifecycle properties remain consistent with request-local failure containment.
Pre-merge checks: 2 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Change Map Design Review
Summary: The change-map comment (marker <!-- kumo-pr-change-map -->) is not in the checkout, and no tool here reads PR comments. I could not assess its wording. I assessed the proposed design th…
1. In packages/experimental/kumo-pytorch/src/kumo/pytorch/rows/samples.py, change the candidate request (around line 341) from as_of_time=cutoff to as_of_time=request.as_of_time. The child call then converts the original time once, wi…
Passed checks: 2 passed
Check name
Status
Explanation
Pr Size
The PR size check fails only when the changed-file count exceeds 40. The reviewed range (refs/coderabbit/pre-merge-check/base to refs/coderabbit/pre-merge-check/head) changes 27 files. The `git diff -…
Public Resource Access
The check covers only external resource references whose text this PR adds or modifies. I searched all added diff lines in the reviewed range (refs/coderabbit/pre-merge-check/base to head) for URLs (h…
Full details: Pr Size
Explanation
The PR size check fails only when the changed-file count exceeds 40. The reviewed range (refs/coderabbit/pre-merge-check/base to refs/coderabbit/pre-merge-check/head) changes 27 files. The git diff --name-status output lists 27 entries: 20 modified (M), 3 added (A), and 2 renamed (R098, R096). The git diff --name-only -M count is also 27. Even without rename detection, the count would be 29, which is still under 40. Line counts were ignored, as the check requires. No failure condition applies.
Full details: Public Resource Access
Explanation
The check covers only external resource references whose text this PR adds or modifies. I searched all added diff lines in the reviewed range (refs/coderabbit/pre-merge-check/base to head) for URLs (http/https, www.), git/SSH sources, package install commands, package index options, and Markdown link syntax. The only match was a Python subscript call (CASES[name]()), which is not an external reference. The changed-file list also contains no dependency manifests, lock files, pyproject/requirements files, CI or Docker files, or package.json. The PR description's uvx [email protected] command is contributor prose outside the diff, so it is not an added code or doc reference. The PR adds or changes no external resource reference, so the check passes.
Full details: Change Map Design Review
Explanation
Summary: The change-map comment (marker <!-- kumo-pr-change-map -->) is not in the checkout, and no tool here reads PR comments. I could not assess its wording. I assessed the proposed design through the code instead. The design has a proven defect in the new non-second clock path, and the PR description says there are no user-visible behavior changes except one. That claim is incomplete. Defect (direct code evidence): - rows/samples.py_build_one computes cutoff = self._clock.cutoff(request.as_of_time). That value is a tick count in the schema's clock unit (ms, us, or ns). - For candidate sets, lines 335–346 call self._build_one(..., SampleRequest(as_of_time=cutoff, ...)). The recursive call passes the tick count, not request.as_of_time. - rows/clock.py_epoch_nanos treats any plain int as epoch seconds (int(value) * 10**9). So a millisecond cutoff of 100000 ticks (for as_of_time=100) becomes a cutoff of 100000 seconds in the child call. The later time admits future events into candidate samples. - Second-based clocks are unaffected, because flooring an integer second count returns the same value. The defect only appears for ms, us, and ns contracts. PR causality: Before this PR, ServingAssembler refused ms, us, and ns contracts. The PR removes that refusal (the description says so), and serving now calls RowSource.build → RowSampleBuilder._build_one. So the candidate path is newly reachable for those contracts. The new tests cover microsecond and nanosecond window, recency, and event-age cases. The review thread on this line reports the same defect. I did not find candidate-set coverage for non-second clocks in the test list named in the PR description. Design and explanation gaps: - The description's "Behavior changes for users: None, except…" section omits that candidate samples use the wrong evaluation time for non-second clocks. - The description says tie handling and node order are unchanged. This is not verified for candidate sets under non-second clocks. - The change design is otherwise reasonable: a shared Clock, a rows package, and one-way dependencies. The problem is the recursive time handoff, which mixes tick counts and epoch seconds. Limit: I did not read the change-map comment. The verdict rests on the code and the PR description. A FAIL here does not confirm or refute the comment's table text.
Resolution
In packages/experimental/kumo-pytorch/src/kumo/pytorch/rows/samples.py, change the candidate request (around line 341) from as_of_time=cutoff to as_of_time=request.as_of_time. The child call then converts the original time once, with the same clock. 2. Add a test with a millisecond (and microsecond and nanosecond) contract that includes a candidate set. Assert that a candidate excludes events after the parent as_of_time. 3. Correct the PR description's "Behavior changes for users" section. State the candidate-time fix and any other non-second clock behavior. 4. Update the change-map comment to describe the candidate evaluation-time behavior and its verification. Then re-run this check on that comment.
Finishing Touches
Fix failing CI checks
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Major · Functional Correctness · Quick win
Preserve the original request time when building candidates.
With a millisecond clock, as_of_time=100 becomes cutoff=100000. Line 341 passes that tick count into a candidate's SampleRequest.as_of_time. The recursive call converts it as epoch seconds and produces cutoff=100000000.
Candidate samples therefore use a later evaluation time and can include future events. Microsecond and nanosecond clocks have the same defect.
Pass request.as_of_time, not cutoff, to the recursive candidate request. Each candidate will then receive the parent's evaluation time, and second-based behavior will remain unchanged.
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
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.
Design discussion or issue: follow-up to kumo-ai/rdl-platform#148 and #149
Summary
Cleanup: online serving no longer goes through the in-memory engine. DiskGraph is the one engine kumo-pytorch ships for real data;
InMemoryEngineis a test and demo tool. Serving was never an engine job (the caller fetches the rowsrows_speclists, and the library turns them into batches with the artifact's fitted state), butServingAssemblerbuilt anInMemoryEnginefor its contract checks and assembled throughInMemorySource.samples.py,graph.py) moves fromengines/in_memory/to a neutralkumo.pytorch.rowspackage, with aRowSourcethat serving uses. The in-memory engine'sInMemorySourcenow subclassesRowSourceand adds only what fitting needs (column statistics, text). Dependencies run one way:engines.in_memoryimportsrows, andservingimports nothing fromengines.in_memory.rowsare counted by a smallClock. The in-memory engine keeps whole seconds, and serving uses DiskGraph's clock: the finest timestamp unit the schema declares. The DiskGraph config now takes itstimestamp_unitfrom the sameClock.of, so both share one rule.ServingAssemblerchecks the contract without an engine preflight.Change map: #379 (comment)
Behavior changes for users
None, except one side effect: because serving no longer runs the in-memory engine's checks, a contract with ms/us/ns timestamps is now served in that clock instead of being refused at
ServingAssemblerconstruction. The tie rule at arecentfanout limit and graph node order are unchanged.Testing Done
From
packages/experimental/kumo-pytorch, with DiskGraph built from this branch'spackages/diskgraph:python -m pytest -q --require-imports: 2426 passed, 5 skipped.python -m conformance --engine all: 707 passed.uvx [email protected] check .anduvx [email protected] format --check .: clean.New tests in
tests/test_serving.pycompareServingAssembleroutput value for value withDiskGraphEnginebatch inference (plan.materialize(..., inference=True)): for the example, bounded-window and event-limit contracts, and for a contract on microsecond and on nanosecond clocks (window, recency and event ages). The existing serving tests against in-memory batch inference are unchanged and pass.Checklist
kumo.pytorch.engines.in_memory.samples/graphare nowkumo.pytorch.rows.samples/graph)🤖 Generated with Claude Code