Skip to content

Preserve timestamp precision in prediction artifacts - #122

Closed
alan-kumo wants to merge 2 commits into
NVIDIA:mainfrom
alan-kumo:fix/preserve-prediction-timestamp-precision
Closed

alan-kumo wants to merge 2 commits into
NVIDIA:mainfrom
alan-kumo:fix/preserve-prediction-timestamp-precision

Conversation

@alan-kumo

@alan-kumo alan-kumo commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Prediction artifacts silently truncate timestamps finer than one microsecond. Distinct anchors such as 01:02:03.123456001 and 01:02:03.123456999 become identical after export.

Preserve typed timestamp columns through pandas and Arrow output, including link-prediction chunk construction. Require lossless timestamp conversion when later batches differ from the stream's fixed schema; abort publication if that conversion would discard precision.

Change map

File-by-file change map.

Testing Done

  • The timestamp round-trip regression fails against the unchanged output writer.
  • Output writer, artifact-statistics and scalability tests: 74 passed.
  • Native forecast/classification/link-prediction output-column integration suite: 25 passed (CPU).
  • Post-review compatibility: pandas 1.5.3/NumPy 1.26.4 passed 23 targeted tests; 11 fixtures requiring pandas microsecond dtypes skipped. Arrow precision checks remained active.
  • Package-owned Pyflakes checks and git diff --check passed.
  • CodeRabbit final review completed on f0d4e08; the pandas compatibility finding is fixed and the final server-side audit found zero unresolved review threads.
  • NVIDIA-hosted CI awaits the upstream fork-vetting gate.
  • Python 3.11.15, PyArrow 24.0.0 and Torch 2.12.0; native integration ran on CPU.
cd packages/kumo-core
python -m pytest tests/test_train_output.py tests/test_prediction_artifact_stats.py tests/test_prediction_output_scalability.py
cd ../kumo-engine
python -m pytest test/test_prediction_output_columns.py

Compatibility

Prediction Parquet files can now retain nanosecond timestamps and source time zones. Readers must support those timestamp types. Microsecond inputs retain their values. Native table generation and sampling still use whole-second timestamps; this change preserves the values supplied to the output writer and does not add native subsecond sampling support.

Checklist

  • Timestamp schema compatibility changes are described above.
  • Regression tests cover exact values, nulls, time zones, streaming schema changes, pandas, Arrow tables, and record batches.

@copy-pr-bot

copy-pr-bot Bot commented Oct 26, 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.

@alan-kumo
alan-kumo had a problem deploying to gha-kumo-workflow-tests October 26, 2026 23:29 — with GitHub Actions Failure
@coderabbitai

coderabbitai Bot commented Oct 26, 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 0c548f9 and f0d4e08.

Files selected for processing: 1
  • packages/kumo-core/tests/test_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.

Walkthrough

Prediction writers no longer normalize timestamps to microseconds. Streaming output safely casts timestamp columns to the fixed schema type. TT-NG link-prediction output now constructs timestamp arrays without an explicit microsecond cast. Tests cover timestamp precision, round trips, and schema changes.

Priority: Normal

Merge Risk: Minimal · up to f0d4e

No outstanding merge-blocking issue is identified for this change; it is ready to merge after normal checks.

Pre-merge checks: Passed 2 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Change Map Design Review Warning (previously flagged, unaddressed) The production design is appropriate: the diff removes the lossy microsecond conversions from StreamingPredOutputWriter and TT-NG output, and moves lossless timestamp compatibility checks into `Stre… Guard the as_unit call. When as_unit is unavailable, retain the native nanosecond index for the ns cases and skip the us cases, or raise the package minimum pandas version to a version that provides as_unit. Rerun the focused time…
Passed Passed checks: 2 passed
Check name Status Explanation
Pr Size Passed The pull request changes 4 files. The threshold is 40 files, so the PR size check passes.
Public Resource Access Passed The pull request adds or modifies no external resource reference. The changed lines contain only code and test data, with no URL, repository location, or package source location requiring public acces…
Full details: Public Resource Access

Explanation

The pull request adds or modifies no external resource reference. The changed lines contain only code and test data, with no URL, repository location, or package source location requiring public access.

Full details: Change Map Design Review

Explanation

The production design is appropriate: the diff removes the lossy microsecond conversions from StreamingPredOutputWriter and TT-NG output, and moves lossless timestamp compatibility checks into StreamingFrameWriter._to_table. The new tests cover exact and lossy schema changes. However, the focused verification is not valid for the declared dependency range. packages/kumo-core/pyproject.toml:39 allows pandas>=1.5,<3, while the added parameterized test unconditionally calls DatetimeIndex.as_unit at tests/test_train_output.py:83; pandas 1.5 does not provide that API. Therefore all new round-trip cases fail before exercising the writer on a supported pandas version.

Resolution

Guard the as_unit call. When as_unit is unavailable, retain the native nanosecond index for the ns cases and skip the us cases, or raise the package minimum pandas version to a version that provides as_unit. Rerun the focused timestamp suite after the compatibility fix.

Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@alan-kumo

Copy link
Copy Markdown
Collaborator Author

Change map

Observed failure: prediction export truncates timestamp fractions and can collapse distinct anchors. Pandas output converts timestamps through Python datetimes; Arrow output and link chunks explicitly cast to microseconds. This change preserves typed values and rejects timestamp schema conversions that would lose precision. Verification covers exact Parquet round-trips and existing output consumers. Scope ends at artifact serialization; native temporal resolution is a separate concern.

File Function / scope What changed Why
packages/kumo-core/src/kumo_core/train/output.py StreamingPredOutputWriter.write, _finalize_arrow_schema, timestamp normalization helpers Remove conversion through Python datetimes and forced microsecond Arrow casts. Preserve timestamp values and time zones during prediction publication.
packages/kumo-core/src/kumo_core/train/diskgraph_nested_trainer.py _build_ttng_lp_chunk_output Construct timestamp arrays directly from typed values. Preserve link-prediction event and job timestamp precision before writer publication.
packages/kumo-core/src/kumo_core/train/io.py StreamingFrameWriter._to_table Validate timestamp-to-timestamp casts with Arrow's safe conversion before applying the fixed stream schema. Reject later batches that would silently lose timestamp precision.
packages/kumo-core/tests/test_train_output.py Timestamp round-trip, schema-change and link-output tests Assert exact values, nulls, time zones, source units, and distinct anchors across pandas, Arrow table and record-batch streams; check safe and lossy schema conversions. Catch truncation and anchor collisions in actual Parquet artifacts.

@alan-kumo

alan-kumo commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator Author

Change map

Observed failure: prediction export truncates timestamp fractions and can collapse distinct anchors. Pandas output converts timestamps through Python datetimes; Arrow output and link chunks explicitly cast to microseconds. This change preserves typed values and rejects timestamp schema conversions that would lose precision. Verification covers exact Parquet round-trips and existing output consumers. Scope ends at artifact serialization; native temporal resolution is a separate concern.

File Function / scope What changed Why
packages/kumo-core/src/kumo_core/train/output.py StreamingPredOutputWriter.write, _finalize_arrow_schema, timestamp normalization helpers Remove conversion through Python datetimes and forced microsecond Arrow casts. Preserve timestamp values and time zones during prediction publication.
packages/kumo-core/src/kumo_core/train/diskgraph_nested_trainer.py _build_ttng_lp_chunk_output Construct timestamp arrays directly from typed values. Preserve link-prediction event and job timestamp precision before writer publication.
packages/kumo-core/src/kumo_core/train/io.py StreamingFrameWriter._to_table Validate timestamp-to-timestamp casts with Arrow's safe conversion before applying the fixed stream schema. Reject later batches that would silently lose timestamp precision.
packages/kumo-core/tests/test_train_output.py Timestamp round-trip, schema-change and link-output tests Assert exact values, nulls, time zones, source units, and distinct anchors across pandas, Arrow table and record-batch streams; check safe and lossy schema conversions, including on pandas 1.5. Catch truncation and anchor collisions in actual Parquet artifacts.

@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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.

Actionable comments posted: 1


Review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 3961984 and 0c548f9.

Files selected for processing: 4
  • packages/kumo-core/src/kumo_core/train/diskgraph_nested_trainer.py
  • packages/kumo-core/src/kumo_core/train/io.py
  • packages/kumo-core/src/kumo_core/train/output.py
  • packages/kumo-core/tests/test_train_output.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; 11 remain after this review.

@alan-kumo
alan-kumo had a problem deploying to gha-kumo-workflow-tests October 26, 2026 23:41 — with GitHub Actions Failure
@alan-kumo
alan-kumo marked this pull request as ready for review October 26, 2026 23:44
@Vedaant-J

Copy link
Copy Markdown
Contributor

Superseded by #123, which includes these commits and keeps prediction parquet in µs for warehouse compatibility.

This branch had an error being deployed

1 failed deployment
gha-kumo-workflow-tests — f0d4e08e Deployed Oct 26, 2026 by alan-kumo via import #804
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