Repository navigation
Add index clocks from nanoseconds to days - #123
Conversation
Change map
|
|
@coderabbitai review Please review the native timestamp precision changes and their compatibility with existing second-based indexes. Focused native and SDK integration tests pass; the broader Rust suites are still completing. |
✅ Action performed
|
There was a problem hiding this comment.
Actionable comments posted: 6

Review info
-
Run configuration-
- Source mode: Auto
- Repository: NVIDIA/kumo-engine
- Branch: main
- File: .coderabbit.yaml
- Commit: 3961984
- Layers: Repository YAML
- Review profile: QUIET
- Plan: Enterprise
- Run ID:
12758629-93fe-40a9-a520-9ab9213696c5
Files selected for processing: 44-
packages/diskgraph/diskgraph-core/src/metadata.rspackages/diskgraph/diskgraph-core/src/sortkey.rspackages/diskgraph/diskgraph-core/src/time.rspackages/diskgraph/diskgraph-engine/src/engine.rspackages/diskgraph/diskgraph-index/src/bin/explore.rspackages/diskgraph/diskgraph-index/src/graph.rspackages/diskgraph/diskgraph-ingest/README.mdpackages/diskgraph/diskgraph-ingest/src/col_stats.rspackages/diskgraph/diskgraph-ingest/src/lib.rspackages/diskgraph/diskgraph-ingest/src/stage_extension.rspackages/diskgraph/diskgraph-pybind/python/diskgraph/compiler.pypackages/diskgraph/diskgraph-pybind/python/diskgraph/tt_artifacts.pypackages/diskgraph/diskgraph-pybind/python/tests/test_sampling.pypackages/diskgraph/diskgraph-pybind/python/tests/test_subsecond_time.pypackages/diskgraph/diskgraph-pybind/python/tests/test_tt_artifacts_split_marshalling.pypackages/diskgraph/diskgraph-pybind/src/custom_tt_entry.rspackages/diskgraph/diskgraph-pybind/src/tt_builder.rspackages/diskgraph/diskgraph-pybind/src/tt_executor.rspackages/diskgraph/diskgraph-rowpack/src/access.rspackages/diskgraph/diskgraph-rowpack/src/bin/rowpack_ctx_inspect.rspackages/diskgraph/diskgraph-rowpack/src/lib.rspackages/diskgraph/diskgraph-rowpack/src/parser.rspackages/diskgraph/diskgraph-rowpack/src/tests_timestamp_precision.rspackages/diskgraph/diskgraph-train-table/README.mdpackages/diskgraph/diskgraph-train-table/src/custom_tt_chunk_processor.rspackages/diskgraph/diskgraph-train-table/src/pass_b.rspackages/diskgraph/diskgraph-train-table/src/route.rspackages/diskgraph/diskgraph-train-table/src/split_decider.rspackages/diskgraph/diskgraph-train-table/src/ttgen_executor.rspackages/diskgraph/diskgraph-train-table/src/ttgen_output.rspackages/diskgraph/diskgraph-train-table/src/ttgen_resolve.rspackages/diskgraph/diskgraph-train-table/src/ttgen_stats.rspackages/diskgraph/diskgraph-train-table/src/ttgen_traversal.rspackages/kumo-core/src/kumo_core/diskgraph/ingest.pypackages/kumo-core/src/kumo_core/prediction.pypackages/kumo-core/src/kumo_core/train/diskgraph_nested_trainer.pypackages/kumo-core/src/kumo_core/train/io.pypackages/kumo-core/src/kumo_core/train/output.pypackages/kumo-core/src/kumo_core/training/table.pypackages/kumo-core/tests/test_prediction.pypackages/kumo-core/tests/test_train_output.pypackages/kumo-core/tests/test_train_table.pypackages/kumo-engine/kumo/engine/graph.pypackages/kumo-engine/test/test_prediction_output_columns.py
Files with no reviewable changes: 1-
- packages/kumo-core/src/kumo_core/train/output.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.
-
|
@coderabbitai review |
✅ Action performed
|
There was a problem hiding this comment.
Actionable comments posted: 1
Note
Quiet mode is enabled, so only the most important comments were posted inline. Other review comments are grouped below.

Other comments: 1
packages/diskgraph/diskgraph-rowpack/src/access.rs: 1
2504-2511:Minor · Functional Correctness · Quick win
Date32range check is lost forSecondsprecision.
get_timestamprejectsDate32days outside-106752..=24855. The reason in its comment is that seconds-based sort keys use i32 epoch seconds.
get_timestamp_with_precisionnow handlesDate32before it delegates toget_timestamp. ForSecondsit returnsdays * 86_400with only an overflow check. A date after 2038 now produces a value abovei32::MAX.encode_timestamp_valueclamps it into the last Int32 bucket, so temporal ordering is silently wrong on legacy seconds indexes.Apply the legacy range check in the
Secondsarm. Only the nanosecond arm needs the unrestricted range.Proposed fix
if matches!(array.data_type(), DataType::Date32) { let days = array.as_any().downcast_ref::<arrow_array::Date32Array>().ok_or_else(|| anyhow!("date cast"))?.value(self.row); + if precision == crate::TimestampPrecision::Seconds && !(-106752..=24855).contains(&days) { + return Err(anyhow!("date out of range: day {days}")); + } let factor = match precision {

Review info
-
Run configuration-
- Source mode: Auto
- Repository: NVIDIA/kumo-engine
- Branch: main
- File: .coderabbit.yaml
- Commit: 3961984
- Layers: Repository YAML
- Review profile: QUIET
- Plan: Enterprise
- Run ID:
554a1774-853a-4d2c-a41d-1273cfede30f
Files selected for processing: 24-
packages/diskgraph/diskgraph-core/src/sortkey.rspackages/diskgraph/diskgraph-core/src/tt_builder.rspackages/diskgraph/diskgraph-index/src/graph.rspackages/diskgraph/diskgraph-ingest/src/lib.rspackages/diskgraph/diskgraph-pybind/python/diskgraph/compiler.pypackages/diskgraph/diskgraph-pybind/python/diskgraph/tt_artifacts.pypackages/diskgraph/diskgraph-pybind/python/tests/test_compiler.pypackages/diskgraph/diskgraph-pybind/python/tests/test_subsecond_time.pypackages/diskgraph/diskgraph-pybind/python/tests/test_tt_artifacts_split_marshalling.pypackages/diskgraph/diskgraph-pybind/src/tt_builder.rspackages/diskgraph/diskgraph-rowpack/src/access.rspackages/diskgraph/diskgraph-rowpack/src/parser.rspackages/diskgraph/diskgraph-rowpack/src/tests_timestamp_precision.rspackages/diskgraph/diskgraph-train-table/README.mdpackages/diskgraph/diskgraph-train-table/src/custom_tt_chunk_processor.rspackages/diskgraph/diskgraph-train-table/src/pseudo_time.rspackages/diskgraph/diskgraph-train-table/src/split_decider.rspackages/diskgraph/diskgraph-train-table/src/ttgen_accumulator.rspackages/diskgraph/diskgraph-train-table/src/ttgen_executor.rspackages/diskgraph/diskgraph-train-table/src/ttgen_output.rspackages/diskgraph/diskgraph-train-table/src/ttgen_resolve.rspackages/diskgraph/diskgraph-train-table/src/ttgen_traversal.rspackages/diskgraph/diskgraph-train-table/tests/custom_tt_integration.rspackages/diskgraph/diskgraph-train-table/tests/ttgen_integration.rs
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 10 remain after this review.
-
|
@coderabbitai review |
✅ Action performed
|
There was a problem hiding this comment.
Actionable comments posted: 1

Review info
-
Run configuration-
- Source mode: Auto
- Repository: NVIDIA/kumo-engine
- Branch: main
- File: .coderabbit.yaml
- Commit: 3961984
- Layers: Repository YAML
- Review profile: QUIET
- Plan: Enterprise
- Run ID:
8b570156-4574-40db-9c46-1d5ca746fdb8
Files selected for processing: 3-
packages/diskgraph/diskgraph-ingest/src/lib.rspackages/diskgraph/diskgraph-rowpack/src/access.rspackages/diskgraph/diskgraph-rowpack/src/tests_timestamp_precision.rs
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.
-
|
@coderabbitai review |
✅ Action performed
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

Major · Validate timestamp precision before changing the output. · lib.rs:7114
packages/diskgraph/diskgraph-ingest/src/lib.rs:7114
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winValidate timestamp precision before changing the output.
A fresh ingest removes the local publication marker and deletes the output root before
IngestContext::newvalidates timestamp precision. A precision mismatch can therefore delete an existing index without producing a replacement. Move this validation beforeinvalidate_publication()and the fresh-output wipe. Preserve the existing Encode-marker identity when moving the validation.

Review info
-
Run configuration-
- Source mode: Auto
- Repository: NVIDIA/kumo-engine
- Branch: main
- File: .coderabbit.yaml
- Commit: 3961984
- Layers: Repository YAML
- Review profile: QUIET
- Plan: Enterprise
- Run ID:
2f3a3fd9-67b8-49d5-b7e3-30aa0bd92b05
Files selected for processing: 5-
packages/diskgraph/diskgraph-ingest/src/lib.rspackages/diskgraph/diskgraph-pybind/python/tests/test_subsecond_time.pypackages/diskgraph/diskgraph-rowpack/src/access.rspackages/diskgraph/diskgraph-rowpack/src/lib.rspackages/diskgraph/diskgraph-rowpack/src/tests_timestamp_precision.rs
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 10 remain after this review.
-
|
@coderabbitai review The outside-diff finding about validation order is fixed in a4ee0f3. Precision normalization now runs before publication invalidation, output preparation, or a fresh-output wipe. Encode marker bytes are captured first, preserving the prior identity contract. A native regression asserts that an invalid precision configuration preserves every byte of an existing index, including its publication marker. Focused Rust checks pass; native end-to-end and resume-equivalence checks are running. Please check the complete precision-validation and publication path for any remaining issues. |
✅ Action performed
|
|
@coderabbitai review Commit aed86e2 fixes the hosted native CI findings. The observed-encoding regression now supplies one key buffer for its one-column context, satisfying the debug-build invariant; all five timestamp regressions pass with debug assertions enabled. The timestamp reader uses |
✅ Action performed
|
|
@coderabbitai review |
✅ Action performed
|
A source value beyond the range of the index clock (for example year 9999 on a nanosecond index) now reads as an error, so ingest stores a null cell and drops the row when the column is a required time column, as main does for Date32 values outside its range. Data values are no longer saturated. Ingest logs one warning per column with the number of such values. Every real value fits the seconds clock, so seconds indexes are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Calendar arithmetic returns None instead of panicking, and a row whose window, lag or split shift runs past the clock is dropped rather than wrapped. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Kumo timestamp strings and training-table dates print the fraction a finer clock stores, and nothing extra when it is zero, so seconds output is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
DiskGraphTTBuilder held plan times in nanoseconds, so a seconds or millisecond plan clamped anchors outside 1677-2262. It now keeps each anchor, split bound and offset as given and converts it straight into the plan clock in build(). A window bound or offset shorter than one tick of that clock is a configuration error instead of an empty window, and a sub-second window unit is one instead of a panic. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
check_prediction_precision rejects predicting on a snapshot in another clock than the model was trained on. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Written into the ingest config only when it is not seconds, so seconds configs stay identical to main. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Seconds keeps main's snapshot cache key; every other clock gets its own. The model bundle records the clock it was trained on (seconds when absent), and predict refuses a snapshot built on another. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Training and prediction pass index_path to DiskGraphPlanCompiler, the runtime adapter and NodeRange anchors understand hours and days indexes, and timestamp statistics keep every nanosecond digit of their fraction. A temporal-LP training batch takes its valid RHS items at its earliest anchor, since its anchors share a second rather than a tick. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The clock is sent as a query parameter only when it is not seconds, and the SDK requires the server to echo the clock it built; a missing echo means an older server, which builds seconds. Without a clock, snapshot() keeps the clock of the graph's current snapshot, so the implicit call in fit reuses it. predict snapshots in the clock of the training job's snapshot, also from a new session. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The clock travels from the snapshot request through GraphDataComputeInput, GraphDataVersionInfo and DiskgraphIngestArgs into the ingest config. Seconds keeps main's snapshot identity; other clocks hash their own. The refresh workflow passes the clock to the ingest child only behind the diskgraph-index-clock-v1 patch. Creating or reading a snapshot echoes the clock recorded for it in X-Kumo-Timestamp-Precision. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A batch prediction refuses a pinned snapshot or a reused prediction table in another clock than its model's training snapshot, and an unpinned one refreshes its graph in the model's clock. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Batch-prediction statistics read the clock from the snapshot's index_metadata.json when the snapshot was not built in seconds, falling back to seconds when the file is missing or unreadable. Python sample statistics convert through resolve_temporal in that clock; typed seconds columns keep their vectorized path, which returns the same values. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Six-clock acceptance in kumo-engine and kumoai_studio, the unchanged seconds cache key and hosted identity, the clock echo for old and new SDKs and servers, the patched ingest workflow argument, statistics in the snapshot's clock, and NodeRange and seed times on hours and days indexes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t version Co-Authored-By: Claude Opus 5.5 <[email protected]>
Typed columns take the same vectorized conversion in every clock, which matches resolve_temporal; text statistics truncate into the snapshot clock. Co-Authored-By: Claude Opus 5.5 <[email protected]>
9ee85ab to
99457dc
Compare
|
Updated in
|
|
Thanks, @Vedaant-J fixes LGTM. Non-blocking nit: on hours/days, a window bound that isn't a whole number of ticks still truncates silently (e.g. 90 minutes on an hours index becomes 1 hour). Could reject those the same way as sub-tick ones. OK to follow-up later or defer for now. |
This PR adds index clocks: a DiskGraph index can store its timestamps in nanoseconds, microseconds, milliseconds, seconds, hours or days. Seconds stays the default, and a seconds index stores exactly the same data as one built on
main. The clock changes only the tick that timestamps are stored in and the integer width used to store them; nulls, rounding, truncation, saturation, errors, statistics and prediction output followmain's rules in every clock.Problem
Teams with event data finer or coarser than one second ask:
12:00:00.500. Why can it miss an event from12:00:00.300, or see one from12:00:00.700?Cause
Every index stores time as epoch seconds. Ingest converts each source timestamp to whole seconds (typed timestamps and integer epochs round up, text truncates), so everything finer than a second is gone before sampling or training-table generation sees it.
DatasetMetadata.timestamp_unitexists, but ingest always writes"seconds"and the sampler asserts it.Change
Choose the clock when building a snapshot. The default is seconds.
The index records its clock, and everything that reads it (sampling, training-table generation, statistics, prediction) works in that clock. Kumo calls the setting
timestamp_precision; DiskGraph's own files keep their existingtimestamp_unitkey. A model predicts in the clock it was trained on: kumo-studio'spredictsnapshots in the training snapshot's clock, also from a new session, kumo-engine rejects a snapshot in another clock, and the server rejects a snapshot or a reused prediction table in another clock, with a configuration error.From a millisecond snapshot:
What changes with the clock
mainmainmainRow timestamps are variable-length integers, so their size follows the clock (a 2026 timestamp takes 3 bytes in days, 5 in seconds, 9 in nanoseconds). On a 2M-user × 60M-event fixture a milliseconds index is 11.8% larger than a seconds one (2,856 vs 2,554 MB), 240 MB of it from the 64-bit edge time keys and 62 MB from row timestamps; ingest, sampling and training-table times are within noise of seconds.
What stays as on
main, in every clockmain's accepted rangemaindatetimeis local time, apd.Timestampis UTCtimestamp[ns]/timestamp[us]exactly asmainThree rules are needed only because a clock can now be too narrow or too coarse for a value, which never happens in seconds:
maindoes for out-of-range Date32 values. Ingest logs one warning per column with the count. Only nanoseconds (1677–2262) is this narrow for real data, for example0001-01-01or9999-12-31sentinels, which seconds through microseconds keep.Temporal link-prediction training batches group seeds by second; each batch now takes its valid candidate items at its earliest anchor. On seconds every anchor in a batch is equal, so this matches
main; on finer clocks it keeps a batch from offering items created after a seed's own anchor.Kumo's default prediction anchor comes from the latest timestamp statistic. Statistics now print the stored fraction, and the anchor parser adds the digits beyond microseconds that Python's
datetimedrops, so on a nanosecond index the default anchor equals the latest event.When to opt in
Use a finer clock when the order of events within a second carries signal (clickstreams, trading) and the timestamps are real event times, not load times. A warehouse type such as
TIMESTAMP(9)alone is not a reason: sub-second clocks cost 64-bit edge keys (+11.8% index on the fixture above), and the model's time features are still whole seconds. Use hours or days only when time of day never matters.Back-compat
index_metadata.jsonand statistics byte-identical tomain.diskgraph_config.jsongains one line,"timestamp_unit": "seconds", so its hash iningest_stats.jsonchanges.timestamp_unitmain; see Speed below.DiskGraphPlanCompiler(index_path=...)writes plans in the index clock; every Kumo caller passes it).predictsnapshots in the training snapshot's clock; kumo-engine and the server reject a snapshot or reused prediction table in another clock. Models trained before this PR are seconds and predict as before.diskgraph-index-clock-v1patch.timestamp[us].Known limitations
timestamp[us], so a nanosecond index's exported anchors are truncated to the microsecond.main, so a text event can be visible at an earlier anchor in the same tick. Rounding text up, and keeping user anchors exact in outputs, are separate PRs.Testing Done
main. An index built from a fixture with every source type (fractional text with and without formats, s/ms/µs/ns epochs, decimals, Date32 beyond 2038, typed timestamps, nulls, time-keyed edges) is byte-identical tomain's apart from the addedtimestamp_unitline indiskgraph_config.json(and its hash) and files that also differ between two runs ofmain. Sampled subgraphs and every training-table file match.main's null and rounding rule per source type on messy data.main, medians of 9 interleaved runs on 5M rows: text +0.2%, decimal −3.3%, Arrow −1.7%, integer epochs +3.3% wall time at equal CPU time. Training-table generation on 2M users × 60M events could not be separated from noise on a shared machine: across three interleaved runs, day windows were 4–13% faster thanmainand month windows 0–12% slower.timestamp[us]; the seconds snapshot id equalsmain's.cargo clippy --workspace --all-targets -D warningsclean;cargo test --release --workspace2086 passed; diskgraph Python 294, kumo-api 1126, kumo-core 10690, kumo-engine 700, kumoai_studio 657 passed; roottest/rest2410 andtest/connector,test/data,test/train2276 passed. flake8, isort, pyright,tyfor kumo-api and kumo-sdk, both packages' pre-commit hooks and the change-map check pass. The remaining failures need a GPU, credentials or a compatible local pyarrow, also fail onmain, or pass when rerun alone.🤖 Generated with Claude Code