Skip to content

Return the published model's holdout, independent of explain - #53

Merged
Vedaant-J merged 8 commits into
mainfrom
vedaant/mlops-holdout-fit-mode
Nov 2, 2026
Merged

Vedaant-J merged 8 commits into
mainfrom
vedaant/mlops-holdout-fit-mode

Conversation

@Vedaant-J

@Vedaant-J Vedaant-J commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Series: kumo-engine MLOps series: every snapshot, training table, model and prediction run carries a self-contained _provenance.json; with kumo.mlops(...) stores each artifact under one artifact root, tracks fits and prediction runs in MLflow or Snowflake and registers models; volumes and stages can hold files; prediction runs are monitored for drift and realized performance.
Stack: #53 → #112 → #114 → #50 → #60 → #64 → #115.
Merge order: one linear stack; merge bottom to top (#53 first)

Summary

This PR makes TrainingResult.holdout_path the holdout of the model that was published, or None when that model has no holdout. The answer no longer depends on whether explanations are on.

The holdout is the test-split predictions fit() writes to test_df.parquet. holdout_path points at that file and holdout_df() reads it. Teams use it to check the calibration and score distribution of the model they are about to ship.

One fit can train up to three models from the best trial, and the bundle ships the one trained on the most data:

Fit mode Trained on Has a holdout
fit train yes
refit_trainval (training_job.refit_trainval) train + val yes
refit_full (training_job.refit_full) train + val + test no: it saw the test split

Usage

plan = ModelPlan()
plan.training_job.refit_trainval = True
result = kumo.Trainer(model_plan=plan).fit(training_table, snapshot=snapshot)

result.holdout_path   # .../version_1_refit_trainval/test_df.parquet: the shipped model's
result.holdout_df()   # its test-split predictions

With refit_full on, holdout_path is None, holdout_df() raises FileNotFoundError, and the log says: The published model is refit on the full data, including the test split, so it has no holdout predictions.

Production questions answered

  • Are the holdout predictions I am checking from the model that shipped? Yes, always.
  • Does turning explanations on or off change which holdout I get? No.
  • Why is there no holdout for my refit_full model? It trained on the test split; the log says so.

How it works

fit() asks kumo-core which fit mode the bundle publishes (Trainer.published_fit_mode(): refit_full, else refit_trainval, else fit) and reads test_df.parquet only from that model's run directory. For refit_full it returns None. Prediction and the holdout lookup share this one definition of the published model.

Run directory of a CPU fit on a small synthetic graph (users, items, orders) with both refits on; the best trial is version_1:

<scratch>/trainers/<trainer>/runs/<run>/
  published-model/                     # the bundle; holds the refit_full model
  models/<run>/automl/
    version_0/  version_2/  version_3/  # other trials
    version_1/                         # best trial, fit mode 'fit'
      test_df.parquet  test_df_meta.json  test_result.csv  checkpoint/  ...
    version_1_refit_trainval/          # train + val, evaluated on test
      test_df.parquet  test_df_meta.json  test_result.csv  checkpoint/  ...
    version_1_refit_full/              # train + val + test, never evaluated
      checkpoint/  tensorboard/  train_progress.json  train_result.json

Which file holdout_path returns, before and after:

refit_trainval refit_full explain before after
no no off/on version_N/ version_N/
yes no off/on version_N_refit_trainval/ version_N_refit_trainval/
no yes off None None
no yes on version_N/ (not the shipped model) None
yes yes off None None
yes yes on version_N_refit_trainval/ (not the shipped model) None

Before, the lookup followed whichever fit mode the trainer object was last left in, and explain() changed that mode as a side effect. kumo-core gains Trainer.published_fit_mode() and an optional fit_mode argument on Trainer.get_log_dir, so the lookup reads another mode's directory without changing the trainer or creating empty directories.

Back-compat

Only the choice of file changes. No fields, checks or errors are added, and the run directory layout is unchanged.

Situation Behaviour
No refit, or refit_trainval only Same holdout_path as before, explanations on or off.
refit_full, explanations off None, as before.
refit_full, explanations on None. It used to return an earlier model's holdout without saying so.
No holdout written (e.g. ranking tasks) None, as before.
Result of Trainer.load() None, as before.

Testing

  • test_holdout_df.py: real CPU fits with no refit (file under version_N/), refit_trainval with explanations on (under version_N_refit_trainval/), and both refits (None); the holdout is never inside the bundle.
  • test_training_explanations.py, test_semantic_carry_forward.py: fake trainers answer published_fit_mode() and get_log_dir(fit_mode=).
  • kumo-core test_artifacts.py, training and checkpoint suites pass with the new get_log_dir argument.
  • The three engine files above: 35 passed on CPU.

Out of scope

  • A holdout for a refit_full model. The fit and refit_trainval test predictions stay in the run directory shown above; they are not returned as the shipped model's.

Change map: see the kumo-pr-change-map comment.

🤖 Generated with Claude Code

@Vedaant-J

Vedaant-J commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Change map

File Function / scope What changed Why
packages/kumo-core/src/kumo_core/train/trainer.py new: published_fit_mode; get_log_dir Names the fit mode the bundle publishes; get_log_dir takes an optional fit_mode Callers find the published model's directory
packages/kumo-core/tests/test_artifacts.py fake SourceTrainer Exposes published_fit_mode Matches the fit-mode setter's new call
packages/kumo-engine/kumo/engine/trainer/trainer.py new: _published_holdout; fit, TrainingResult.holdout_path Reads the published fit mode's holdout, or None for refit_full Holdout matches the published model
packages/kumo-engine/test/test_holdout_df.py _fit; new test_holdout_is_the_published_models Real fits for no refit, refit_trainval with explain, and both refits Covers each published fit mode
packages/kumo-engine/test/test_semantic_carry_forward.py _best_trainer fake Answers published_fit_mode() and get_log_dir(fit_mode) Matches the trainer's new calls
packages/kumo-engine/test/test_training_explanations.py fake best trainer Answers published_fit_mode() and get_log_dir(fit_mode) Matches the trainer's new calls

@copy-pr-bot

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

@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review.

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: NVIDIA/kumo-engine/.coderabbit.yaml
  • Review profile: QUIET
  • Plan: Enterprise
  • Run ID: 02f9dcd3-edf8-40f6-b115-ff21b676c041
📥 Commits

Reviewing files that changed from the base of the PR and between 0c37212 and ea7119d.

📒 Files selected for processing: 5
  • packages/kumo-core/src/kumo_core/train/trainer.py
  • packages/kumo-engine/kumo/engine/trainer/trainer.py
  • packages/kumo-engine/test/test_holdout_df.py
  • packages/kumo-engine/test/test_semantic_carry_forward.py
  • packages/kumo-engine/test/test_training_explanations.py

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

Walkthrough

Trainer now resolves the highest completed fit mode through published_fit_mode. get_log_dir can use an explicit fit mode. Trainer.fit uses the published mode to locate holdout artifacts and returns no holdout path for full-data refits. Tests cover standard fitting, train-validation refitting, full-data refitting, explanation settings, path naming, and updated trainer interfaces.

Sequence Diagram(s)

sequenceDiagram
  participant Trainer.fit
  participant published_fit_mode
  participant _published_holdout
  participant Holdout artifacts
  Trainer.fit->>published_fit_mode: determine the completed fit mode
  published_fit_mode-->>Trainer.fit: return the published mode
  Trainer.fit->>_published_holdout: request holdout metadata
  _published_holdout->>Holdout artifacts: locate artifacts for the published mode
  Holdout artifacts-->>_published_holdout: return artifact metadata or no artifact
  _published_holdout-->>Trainer.fit: return holdout metadata
Loading
Merge Risk: Minimal · previous review ea711

Holdout selection matches the published model in the inspected paths. No issue identified here prevents merging after normal checks.

Pre-merge checks: Passed 2 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Change Map Design Review Inconclusive The required PR conversation comment beginning with <!-- kumo-pr-change-map --> is not available. Repository search found only the review documentation reference, and the supplied PR description is … Provide the complete PR conversation comment beginning with <!-- kumo-pr-change-map -->, including its linked problem, inspected behavior, proposed changes, verification, and stopping condition.
Passed Passed checks: 2 passed
Check name Status Explanation
Pr Size Passed The pull request changes 5 files. This count does not exceed 40.
Public Resource Access Passed The pull-request diff adds or modifies no external resource reference. The changed lines contain code, documentation, imports, test paths, and local artifact names only; they add no URL, repository lo…
Full details: Public Resource Access

Explanation

The pull-request diff adds or modifies no external resource reference. The changed lines contain code, documentation, imports, test paths, and local artifact names only; they add no URL, repository location, or package source location that requires public-access verification.

Full details: Change Map Design Review

Explanation

The required PR conversation comment beginning with &lt;!-- kumo-pr-change-map --&gt; is not available. Repository search found only the review documentation reference, and the supplied PR description is explicitly truncated. The change-map design cannot be assessed for necessity, abstraction layer, stopping condition, and focused verification without that comment.

Resolution

Provide the complete PR conversation comment beginning with &lt;!-- kumo-pr-change-map --&gt;, including its linked problem, inspected behavior, proposed changes, verification, and stopping condition.

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

@Vedaant-J
Vedaant-J temporarily deployed to gha-kumo-workflow-tests October 20, 2026 22:35 — with GitHub Actions Inactive

@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/kumo-engine/test/test_holdout_df.py: 1

112-125: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover explanation processing with refit_trainval.

The production path runs best_trainer.explain(...) before _published_holdout(...). The matrix does not combine explain=True with refit_trainval=True, so a regression in mode restoration or holdout selection for this path can pass. Add both reachable refit_trainval explanation cases at this matrix site.

Suggested fix
 @pytest.mark.parametrize('refit_trainval,refit_full,explain,model', [
     (False, False, False, 'fit'),
     (True, True, False, 'refit_trainval'),
+    (True, False, True, 'refit_trainval'),
+    (True, True, True, 'refit_trainval'),
     (False, True, True, 'fit'),
 ])

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: NVIDIA/kumo-engine/.coderabbit.yaml
  • Review profile: QUIET
  • Plan: Enterprise
  • Run ID: b9ce2f06-0cec-4ff9-9845-51a2fb62bc8d
📥 Commits

Reviewing files that changed from the base of the PR and between 3f8cf56 and ab2e389.

📒 Files selected for processing: 1
  • packages/kumo-engine/kumo/engine/trainer/trainer.py

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

@Vedaant-J
Vedaant-J temporarily deployed to gha-kumo-workflow-tests October 21, 2026 00:20 — with GitHub Actions Inactive
@Vedaant-J Vedaant-J changed the title Read the holdout of the published model, not the last-evaluated one Return the published model's holdout, independent of explain Oct 21, 2026
@Vedaant-J
Vedaant-J temporarily deployed to gha-kumo-workflow-tests October 21, 2026 08:47 — with GitHub Actions Inactive
@Vedaant-J
Vedaant-J force-pushed the vedaant/mlops-holdout-fit-mode branch from 0c37212 to 5cebd6f Compare October 21, 2026 16:24
@Vedaant-J
Vedaant-J had a problem deploying to gha-kumo-workflow-tests October 21, 2026 16:24 — with GitHub Actions Error
@Vedaant-J
Vedaant-J changed the base branch from main to vedaant/mlops-bundle-provenance October 21, 2026 16:24
@Vedaant-J
Vedaant-J force-pushed the vedaant/mlops-holdout-fit-mode branch from 5cebd6f to 39f2531 Compare October 21, 2026 16:33
@Vedaant-J
Vedaant-J temporarily deployed to gha-kumo-workflow-tests October 21, 2026 16:34 — with GitHub Actions Inactive
@Vedaant-J
Vedaant-J added this pull request to stack #77 October 21, 2026 17:58
@Vedaant-J
Vedaant-J force-pushed the vedaant/mlops-holdout-fit-mode branch from 5cebd6f to 2108fae Compare October 21, 2026 19:06
@Vedaant-J
Vedaant-J temporarily deployed to gha-kumo-workflow-tests October 21, 2026 19:06 — with GitHub Actions Inactive
@Vedaant-J
Vedaant-J force-pushed the vedaant/mlops-holdout-fit-mode branch from 2108fae to c36dfd8 Compare October 21, 2026 19:51
@Vedaant-J
Vedaant-J temporarily deployed to gha-kumo-workflow-tests October 21, 2026 19:51 — with GitHub Actions Inactive
@Vedaant-J
Vedaant-J temporarily deployed to gha-kumo-workflow-tests October 27, 2026 18:58 — with GitHub Actions Inactive
Vedaant-J and others added 2 commits October 28, 2026 16:00
fit() read test_df.parquet from best_trainer.log_dir, which is whichever
refit stage ran last, not necessarily the model the bundle publishes. With
refit_full the published model has seen the test split, so its holdout is
meaningless.

Read the holdout from the published model's log dir (Trainer.published_fit_mode,
also used to pick the prediction model) and return none for refit_full.
get_log_dir takes an optional fit_mode override.

Verified: test_holdout_df (fit / refit_trainval with explain / refit_full),
test_training_explanations, test_semantic_carry_forward: 35 passed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
test_artifacts.py's fake trainer borrows Trainer methods; select_fit_mode
now calls published_fit_mode, so the fake needs it too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Vedaant-J
Vedaant-J force-pushed the vedaant/mlops-holdout-fit-mode branch from f8c6502 to 86fa3c6 Compare October 28, 2026 16:25
@Vedaant-J
Vedaant-J temporarily deployed to gha-kumo-workflow-tests October 28, 2026 16:25 — with GitHub Actions Inactive
Victsm
Victsm previously approved these changes Oct 31, 2026

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

Re-reviewed 86fa3c6. The bot’s requested train/validation-refit + explanations regression is now covered. Holdout selection uses the same published-model priority as prediction, without changing the trainer’s active mode; a full-data refit correctly reports no holdout. No remaining correctness blocker found.

The extra full-refit + explanations matrix case suggested by the bot remains optional coverage; it does not block this change.

GitHub merge gates remain separate: the PR change-table validation is red, and the config/connector test failure is from two missing BigQuery permission-test identities.

Local validation of the exact Python head: all 11 holdout tests passed, including real fit/refit and explanation runs, alongside 36 passing semantic-carry-forward/explanation tests. Used an isolated compatible DiskGraph binary; initial native-version/PATH setup failures are retained in the local logs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Vedaant-J added a commit that referenced this pull request Oct 31, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Vedaant-J
Vedaant-J temporarily deployed to gha-kumo-workflow-tests October 31, 2026 03:00 — with GitHub Actions Inactive
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Vedaant-J
Vedaant-J temporarily deployed to gha-kumo-workflow-tests November 1, 2026 01:38 — with GitHub Actions Inactive
Vedaant-J added a commit that referenced this pull request Nov 1, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Vedaant-J and others added 2 commits November 1, 2026 02:51
The refit_full case now also explains, as in the upper PRs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Vedaant-J
Vedaant-J temporarily deployed to gha-kumo-workflow-tests November 1, 2026 02:51 — with GitHub Actions Inactive
Vedaant-J added a commit that referenced this pull request Nov 1, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Vedaant-J
Vedaant-J removed this pull request from stack #118 November 2, 2026 18:00
@Vedaant-J
Vedaant-J added this pull request to stack #155 November 2, 2026 18:00
@Vedaant-J
Vedaant-J merged commit 524a2ce into main Nov 2, 2026
104 of 105 checks passed
@Vedaant-J
Vedaant-J deleted the vedaant/mlops-holdout-fit-mode branch November 2, 2026 18:55
Vedaant-J added a commit that referenced this pull request Nov 3, 2026
…tem (#112)

**Stack:** main (#53 merged) → **#112** → #114 → #50 → #60 → #64 → #115.
Merge bottom to top.

## Summary

Prediction exports and model bundles can only go to S3, GCS, ADLS or
local paths: the engine checks the connector type. Databricks volumes
and Snowflake stages hold files too, but one upload is capped (5 GiB on
volumes) or has no multipart. This PR lets any sink say which of its
paths are files, and gives such stores one shared filesystem:

- `kumoapi.plugin.FileStoreSink`: an optional protocol,
`holds_files(connector, path)` (from the path alone) and
`filesystem(connector, path)` (a `pyarrow.fs.FileSystem`).
- `kumo_core.chunked_fs.ChunkedFileHandler`: a pyarrow filesystem over
five store calls (size, list, put, ranged read, remove). A file up to
`part_bytes` is one plain object; a larger one is stored as parts under
`<name>.chunks/<generation>/` and committed by an empty `_SUCCESS`
written last.
- `kumo_core.object_store_sink.FilesystemSink`: the existing
object-store writers over any sink's `filesystem()`. Bundles upload
`_provenance.json` last.
- `kumo_core.object_store_sink.FileStoreRouting`: a mixin that sends a
sink's file paths to `FilesystemSink` and its other paths to its own
table methods.
- `ObjectStoreSinkBackend.preflight_write_files`: an export into an
occupied output directory is refused before scoring, on every object
store.

No volume or stage sink ships here; #114 and #115 add them.

## Usage

```python
class StageSink:                                    # an existing table sink
    def holds_files(self, connector, path):
        return path.startswith('@')
    def filesystem(self, connector, path):
        return PyFileSystem(StageHandler(connector)), path.rstrip('/')

PredictionOutputConfig(connector, output_paths={"predictions": "@stage/kumo/scores/"})
trainer.fit(..., export_config=ModelOutputConfig(connector, path="@stage/kumo/models/m1"))
Trainer.load_from_connector(connector, path="@stage/kumo/models/m1")
```

## Back-compat

| Situation | Behaviour |
|---|---|
| S3, GCS, ADLS or local publish and fetch | Unchanged
(`ObjectStoreSinkBackend` holds every path). |
| `output_paths` on a sink that does not hold the path | `ValueError`,
as before; the message now mentions volume and stage paths. |
| Sink whose package extra is not installed | The install hint is
raised, not the file-destination error. |
| Export into an output directory that already holds files (S3, GCS,
ADLS or a sink's file store) | Refused before scoring, whatever the
write mode, with the same `Output directory ... already contains data
from another export` error that was raised after scoring. |
| A sink without `FileStoreSink` | A table destination, as before. |
| A chunked file read while it is rewritten | The previous file until
the new `_SUCCESS` lands. |
| A write that fails part way | Nothing committed; a stream that
supports `abort` is aborted; the previous file stays readable; the error
is raised. |
| A `.chunks/` file read by Spark or an older engine | A directory of
parts; files up to `part_bytes` are plain objects. |

## Testing

- `kumo-core/tests/test_chunked_fs.py`: empty, sub-part, one-part and
multi-part files; reads across part boundaries; newest committed
generation wins; failed writes keep the old file and abort the stream;
listings, deletes, streamed writes, spool location; concurrent rewrites.
- `kumo-engine/test/test_filestore_sink.py`: output configs, a bundle
round trip, trainer publish and load, and prediction export, the
occupied-directory refusal before scoring, and a file-only sink refusing
a table through a filesystem-only sink over an in-memory store.

Change map: see the `kumo-pr-change-map` comment.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Vedaant-J added a commit that referenced this pull request Nov 3, 2026
…114)

**Stack:** main (#53 merged) → #112 → **#114** → #50 → #60 → #64 → #115.
Sits between #112 and #50. Merge bottom to top.

## Summary

A `/Volumes/<catalog>/<schema>/<volume>/...` path is reachable only
through the FUSE mount on Databricks compute, so a training job on a
laptop, EC2 box or CI cannot publish a model or export scores to the
volume a Databricks job reads. This PR makes such a path a file
destination of `DatabricksConnector` from any machine. The sink
implements #112's `FileStoreSink` and reads and writes the volume
through the Databricks Files API with the connector's identity, reusing
#112's writers. Files up to 4 GiB are plain objects that Spark reads
directly; larger ones are stored as 4 GiB parts (the Files API caps one
upload at 5 GiB). No SQL warehouse is used.

## Usage

```python
root = "/Volumes/main/kumo/artifacts"
trainer.fit(training_table, snapshot=snapshot, export_config=ModelOutputConfig(
    databricks, path=f"{root}/models/churn"))
trainer = Trainer.load_from_connector(databricks, path=f"{root}/models/churn")
trainer.predict(prediction_table, snapshot=snapshot, output_config=PredictionOutputConfig(
    databricks, output_paths={"predictions": f"{root}/scores/"}))
```

The identity needs `USE CATALOG`, `USE SCHEMA`, `READ VOLUME` (load) and
`WRITE VOLUME` (export).

## Back-compat

| Situation | Behaviour |
|---|---|
| Table name on a `DatabricksConnector` | Unchanged: COPY INTO through
the staging volume. |
| Unity Catalog registry publish and fetch (`location=`) | Unchanged. |
| `/Volumes/...` path on a `DatabricksConnector` | Was refused; now
written through the Files API. |
| `/Volumes/...` string root on Databricks compute | Unchanged: a
`FileConnector` over FUSE. |
| Export into a volume directory that already holds files | Fails before
scoring starts: `Output directory '/Volumes/.../scores/' already
contains data from another export. Choose an empty destination path.` |
| Upload or download failure | `FileNotFoundError`, `PermissionError` or
`OSError` with the volume path; no signed URL in the message. A failed
write cancels its upload, so nothing is committed. |
| A file larger than 4 GiB read by Spark | A directory of
`<name>.chunks/<generation>/` parts; only kumo reads it as one file. |

## Testing

- `kumo-databricks/tests/test_volume.py` (10 tests, in-memory Files API
in `tests/fakes.py`): reads across part boundaries; sized writes plain
up to a part; failed and refused uploads; a download that ignores
`Range` is refused; directories and missing paths; bundle publish and
fetch, Parquet and frame exports through a volume path; an occupied
directory refused before scoring.
- Live with the rest of the series applied, on a test workspace with
synthetic data, off-cluster and in a cluster job: 3.0 GiB and 4.29 GiB
files round-trip with matching CRCs, a read across the 4 GiB part
boundary is exact, and a `kumo.mlops` fit and predict with the artifact
root on a volume writes snapshots, models and predictions there.

Change map: see the `kumo-pr-change-map` comment.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Vedaant-J added a commit that referenced this pull request Nov 3, 2026
**Stack:** main (#53 merged) → #112 → #114 → **#50** → #60 → #64 → #115.
Merge bottom to top.

## Summary

Every graph snapshot, training table and model bundle now carries a
self-contained `_provenance.json` that leads back to the source table
versions (and locations, wherever the source backend can name them),
query, plan and engine build that produced it. Today a model has no id,
an artifact records no lineage, an index works only on the machine that
built it, and scoring needs the training job's `Graph`.

This PR adds `kumo.MLOps` / `with kumo.mlops(...)` to store each
artifact once under one artifact root (`s3://`, `gs://`, local, or a
`(connector, path)` file store from #112); `GraphSnapshot.export` /
`load_from_connector` to move a checksummed index between machines;
`snapshot.source_changes(graph)` to see which tables changed since a
snapshot; and `Trainer.predict(snapshot)` to score a stored snapshot
with the trained query. `MLOps(on_error='raise')` turns a failed store
into a `RuntimeError` after the call finishes. Off unless asked for.

**Design decision:** for this release MLOps is opt-in per call or per
block (`mlops=` or `with kumo.mlops(...)`). A call outside both runs
without MLOps, and `on_error="raise"` does not detect that. A model- or
workflow-bound association with an explicit `mlops=False` was considered
and is left as a follow-up. See "Per call, not per model" in
`docs/mlops.md`.

## Usage

```python
cfg = kumo.MLOps("s3://<bucket>/kumo")             # store=True: snapshots, tables, models
with kumo.mlops(cfg):                               # or mlops=cfg on one call
    snapshot = graph.snapshot()
    result = trainer.fit(pq.generate_training_table(snapshot), snapshot=snapshot)

# Later, on another machine with no Graph code:
snapshot = GraphSnapshot.load_from_connector(cfg, id=result.snapshot_id)
trainer = Trainer.load_from_connector(cfg, path=f"models/{result.id}")
scores = trainer.predict(snapshot)
```

## Back-compat

Without a block or `mlops=`, existing calls behave as before.

| Situation | Behaviour |
|---|---|
| Index built before this PR | Reused, not rebuilt; its manifest is
backfilled with `"reconstructed": true`. |
| Bundle published before this PR | Loads and predicts identically; id
computed at load, `manifest` is `None`. |
| Artifact from this PR read by an older engine | Extra files are
ignored. |
| A single S3 or GCS object source | Versioned by VersionId or entity
tag, so its snapshot gets a new id once. |
| `verify_model_bundle` return value | 64 hex instead of a 16-hex digest
no caller used. |
| `DatabricksConnector(identity=...)` | Unchanged; `identity` is now
optional (ambient auth). |
| Manifest, sidecar or root write fails | A warning; the call completes
as before. A failed store raises a `RuntimeError` instead, once the call
has finished, with `MLOps(on_error='raise')`. |

## Testing

- kumo-engine: `test_snapshot_export.py` (round trip, reuse, interrupted
and concurrent exports, corrupt markers, `source_changes`, `on_error`),
`test_snapshot_manifest.py`, `test_training_table_export.py`,
`test_holdout_df.py` (published model's holdout, loaded and fetched
holdout, empty test split), `test_bundle_provenance.py`,
`test_query_from_snapshot.py`, `test_filestore_sink.py` (identical
bundle reused), `test_mlops.py`, `test_graph_mismatch.py`,
`test_artifacts.py`.
- kumo-core typed source versions, bundle ids and export sidecars;
kumo-s3 `test_sink_delete.py`; Snowflake, Databricks and BigQuery
identity tests assert `version_kind`.
- DiskGraph: Rust
`range_checksums_cover_every_listed_file_and_the_manifest`; pybind
`test_exception_exports.py`.
- Env-gated live S3 and GCS round trips in
`test_snapshot_export_live.py`.

Change map: see the `kumo-pr-change-map` comment.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Vedaant-J added a commit that referenced this pull request Nov 3, 2026
)

**Stack:** main (#53 merged) → #112 → #114 → #50 → **#60** → #64 → #115.
Merge bottom to top.

## Summary

This PR adds **experiment tracking and model registration for
`Trainer.fit`**. Before it, a fit reported progress only as progress-bar
text on stdout and could not record itself anywhere a team already
looks, and a chosen threshold had nowhere to live in the bundle.

- `kumo.MLOps(tracking=..., registry=...)` records each fit as one run
in MLflow (Databricks, SageMaker managed MLflow, any server) or
Snowflake Experiment Tracking. The run gets params, per-split metrics,
the search trials, and data summaries (split, health and column tables,
notes, and the source tables as datasets) read from the stats files the
builds already write. The model is then registered under an alias in
that tracker's registry.
- An MLflow-registered model is also a pyfunc, a platform adapter that
loads and scores it through MLflow's model API (for example Spark jobs)
without the training code. It does not replace `Trainer.predict`, the
batch prediction API.
`kumo.engine.integrations.mlflow.log_model(trainer, snapshot=...,
experiment_name=...)` logs one outside a fit, creating the experiment if
it is missing.
- `fit(callbacks=)` and `graph.snapshot(callbacks=)` receive progress
events. `fit(scoring_defaults=)` stores a threshold or top-k in the
bundle.

## Usage

```python
import kumo.engine as kumo
from kumo.engine.integrations.mlflow import MlflowTracking

cfg = kumo.MLOps("s3://<bucket>/kumo", tracking=MlflowTracking("users-churn"),
                 registry=kumo.ModelRegistryLocation("users-churn", alias="candidate"),
                 on_error="raise")
with kumo.mlops(cfg):
    snapshot = graph.snapshot()
    result = kumo.Trainer(plan).fit(table, snapshot=snapshot,
                                    scoring_defaults=kumo.ScoringDefaults(binary_classification_threshold=0.5))
result.registered_model   # PublishedModel(name='users-churn', version='1', uri='models:/users-churn/1', ...)
champion = kumo.Trainer.load_from_connector(cfg, location=kumo.ModelRegistryLocation("users-churn", alias="champion"))
```

Snowflake uses `SnowflakeTracking(connector, experiment_name=...)`. A
custom tracker implements `kumo.engine.tracking.Tracking`.

## Back-compat

| Situation | Behaviour |
|---|---|
| MLOps off, or `kumo.MLOps` without `tracking` and `registry` |
Unchanged. |
| A tracker raises, errors or hangs | Tracking runs on a background
thread on rank 0, so the fit is unaffected. `on_error="warn"` (default)
warns once; `"raise"` raises after the result is stored. |
| Binary `predict` without a threshold | Writes the probabilities and a
null `TARGET_PRED`; before, it raised. |
| Existing bundles (no `scoring-defaults.json`, no `dependencies`) |
Load and predict as before, with the same bundle ids. An explicit
argument always overrides a bundle default. |
| A bundle with `scoring-defaults.json` read by an older engine | The
file is listed and hash-checked, and the older engine ignores it. |
| Registry versions published before this PR | Listed and fetched as
before, with no `kumo_bundle_id`. |
| kumo-engine without the `mlflow` or `snowflake` extra | `import
kumo.engine` works. Building a tracker raises an `ImportError` naming
the extra. |

## Testing

- New engine tests: `test_fit_events.py`, `test_tracking_contract.py`,
`test_mlflow_tracking.py`, `test_mlflow_target.py`,
`test_mlflow_model.py`, `test_snowflake_tracking.py`,
`test_scoring_defaults.py`, `test_data_summaries.py`,
`test_summary_tables.py`, `test_model_agnostic_mlops.py`;
`test_trainer_registry.py` grows with registration, alias and
`registry=` cases.
- The MLflow tests use a real local SQLite store and a real CPU fit, and
check that the logged model scores the same as `Trainer.predict`.
Snowflake tests use a recording fake of `snowflake.ml.experiment` whose
signatures are checked against the installed library.
- Package tests: the kumo-snowflake and kumo-databricks registry tests
cover the bundle id, aliases and name checks. The kumo-core tests cover
searched params, prediction columns, the worker-handle fallback and
export column types.
- CI adds an `mlflow-floor` job that runs the MLflow suites on
mlflow-skinny 3.5.0.

## Also fixes

- pidfd fallback for sandboxes that refuse `pidfd_open`;
`encoder_selection` install hint; Optuna `ExperimentalWarning` filter
scoped to `analyze()`.
- kumo-core: stamping extra columns now stays in Arrow, so the all-null
TARGET_PRED a threshold-less binary predict writes keeps its bool type.
- kumo-core: searchers record the values each trial sampled, so tracked
trial runs and trial_started events carry their searched params.

Change map: see the `kumo-pr-change-map` comment.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Vedaant-J added a commit that referenced this pull request Nov 3, 2026
**Stack:** main (#53, #112, #114, #50, #60 merged) → **#64** → #115.
Merge bottom to top.

## Summary

Teams that score on a schedule cannot tell which model and data produced
a table of scores, whether the scores moved, or how good they were once
outcomes arrived. This PR records and monitors prediction runs:

- Every `Trainer.predict` writes a `PredictionManifest`
(`_provenance.json`): model, snapshot and source-table versions, scoring
options, destinations, skipped entities, and exact counts of its scores
on fixed bins. With MLOps on, the run is also stored under
`<root>/predictions/<id>/` and tracked.
- This is the durable path that `score_drift` and `evaluate` read. The
platform DataFrame adapters (the MLflow pyfunc's `predict`, a
warehouse's batch call) return scores but record no Kumo prediction run.
- Every model manifest keeps exact counts of its holdout scores as the
baseline. `Trainer.score_drift` gives PSI, KS and Wasserstein against
the holdout and a previous run, plus input-column drift;
`Trainer.evaluate` gives realized metrics once outcomes are in a newer
snapshot, with a DiskGraph join that keeps memory bounded. For link
prediction, PSI against the holdout is a plain number with no shift
verdict, since the holdout covers only entities with a future target;
every other task, multilabel included, gets one.
- Every tracker logs prediction and monitoring runs through shared hooks
(`SingleRunHooks`), with a Markdown run card, build time and size as
`prep.*` tags, and each dataset's role (`training examples`, `graph
context`, `scoring graph`, `labels`, ...) in the card's Lineage block.
Metric names are the same on MLflow and Snowflake, with `_at_` for `@`
(`test/map_at_10`).
- Chart data is logged as step metrics, not images:
`pred/score_histogram` (per class as `pred/score_histogram/<class>` for
multi-class and multilabel; step = score in hundredths),
`pred/prediction_histogram` (regression; step = the bin on the training
target's bins) and, for recommendations, `pred/item_popularity` (step =
item rank, top 100). Where the fit counted its holdout, `pred/holdout_*`
carries the holdout's counts on the same steps, scaled to the run's
total. The card's "Charts: step = ..." note says what each step is, and
`docs/mlops.md` shows how to overlay `pred/X` and `pred/holdout_X` in
the MLflow Chart view.
- `Trainer.evaluate` covers every task type. Entities the snapshot lacks
are skipped and counted, every skipped row is listed as Parquet under
`skipped/`, and `predict` raises only when nothing can be scored.
- On MLflow, a monitoring call folds into its prediction run, and the
fit's `test/*` holdout metrics are also logged on its logged model
without a dataset link, so the Models tab and Compare versions show one
`test/<metric>` column per version; the training table remains the run's
input dataset. Snowflake runs carry the card and a `kumo.model` param,
and tracking stops with a clear error at the experiment's 500-run limit.
The MLflow experiment note is a short list of the run filters.
- `examples/mlops` ships fit and score job templates for Databricks
Jobs, SageMaker Pipelines and Snowflake Tasks; `docs/mlops.md` has
recipes that feed exported evaluations to Databricks and Snowflake
warehouse monitors.

## Usage

```python
cfg = kumo.MLOps("s3://<bucket>/kumo", tracking=MlflowTracking("churn"))
with kumo.mlops(cfg):
    run = trainer.predict(snapshot, output_config=kumo.PredictionOutputConfig(conn, path="scores"))
    drift = trainer.score_drift(run, previous=earlier_run)        # psi, ks, wasserstein, features, reasons
    evaluation = trainer.evaluate(run, labels_snapshot=newer)     # metrics, matured, labelled_fraction
evaluation.export(kumo.PredictionOutputConfig(conn, path="scores_evaluated", write_mode=kumo.WriteMode.APPEND))
later = kumo.PredictionResult.load_from_connector(cfg, path=f"predictions/{run.id}")
```

## Back-compat

| Situation | Behaviour |
|---|---|
| Table destination | Replaced, as before. `WriteMode.APPEND` adds
`PREDICTION_ID` and `BUNDLE_ID`. |
| File destination that already holds data | Refused before scoring by
default or with `APPEND`; `OVERWRITE` empties it first. |
| Bundle from before this PR | Loads and scores as before; drift vs
holdout is `None` with a reason. |
| Manifest, statistics or store write fails | Warning, or the error
under `on_error="raise"` after outputs are written; predictions
unchanged. |
| Custom `Tracking` with fit hooks only | Still valid; prediction and
monitoring hooks are optional. |
| Custom `Tracking` reading `record.summaries` | `Series`, `Histogram`
and `Confusion` are new summary types; skip types you don't handle. |
| `diskgraph.compute_col_stats_for_parquet` callers | New options are
keyword-only and off; default output is byte-identical. |

## Testing

- kumo-core: `test_score_counts.py`, `test_evaluation_counts.py`,
`test_prediction_counts.py`, `test_score_drift.py` check every count and
drift statistic against a brute-force recount.
- kumo-engine: `test_monitoring.py` (27 tests: maturity, anchors,
exports, metric definitions, exact drift), `test_prediction_manifest.py`
(12), `test_tracking_contract.py`, `test_mlflow_tracking.py`,
`test_snowflake_tracking.py`, `test_card.py`, `test_score_stats.py`,
`test_dataset_lineage.py`, `test_summary_tables.py`,
`test_prediction_table_output.py`.
- `test_job_templates.py` runs `fit_job.py` then `score_job.py` end to
end on local Parquet.
- DiskGraph: `test_col_stats_options.py` pins the default statistics
output by SHA-256; Rust tests cover the evaluation join and value bins.

Change map: see the `kumo-pr-change-map` comment.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Vedaant-J added a commit that referenced this pull request Nov 3, 2026
…with run_batch (#115)

**Stack:** main (#53, #112, #114, #50, #60 merged) → #64 → **#115**.
Merge bottom to top.

## Summary

Teams whose data lives only in Snowflake have nowhere to keep Kumo
artifacts and cannot score a registered Kumo model inside Snowflake.
This PR adds both:

- **Stages as a file store.** A `@DB.SCHEMA.STAGE/...` path is a file
destination of `SnowflakeConnector` (#112's `FileStoreSink`, as #114
does for volumes): bundles, snapshot and prediction exports, and the
MLOps artifact root. Writes use `PUT`; reads use presigned ranged URLs,
falling back to one `GET` per file. Files up to 4 GiB are plain objects;
larger ones are parts only kumo reads.
- **Runnable registry versions.** With kumo-engine installed, a version
registered in the Snowflake Model Registry is a `KumoModel` that scores
entity ids against a stage snapshot in Snowpark Container Services
(`ModelVersion.run_batch` on a GPU pool). kumo-snowflake finds the
builder through the `kumo_snowflake.registry_models` entry point.
Registering a bundle again reuses its version when the serving
environment matches.

In the container, the snapshot and the stage assets are read with the
container's own Snowflake identity (`_snowflake_serving.py`).

## Usage

```python
sf = kumo.SnowflakeConnector(warehouse="WH", database="ML", schema_name="MODELS")
cfg = kumo.MLOps((sf, "@ML.MODELS.KUMO"), tracking=SnowflakeTracking(sf, experiment_name="CHURN"),
                 registry=kumo.ModelRegistryLocation("CHURN_GNN", alias="champion"))
with kumo.mlops(cfg):                    # the version serves the fit's snapshot on the stage
    result = trainer.fit(train_table, snapshot=snapshot)

mv = Registry(session, database_name="ML", schema_name="MODELS").get_model("CHURN_GNN").version("champion")
mv.run_batch(session.sql("SELECT ID::STRING AS ENTITY FROM ML.MODELS.USERS"), compute_pool="KUMO_GPU_POOL",
             output_spec=OutputSpec(stage_location="@ML.MODELS.KUMO_OUT/churn/"))
```

## Back-compat

| Situation | Behaviour |
|---|---|
| Table name on a `SnowflakeConnector` | Unchanged. |
| `@DB.SCHEMA.STAGE/...` path | Was refused; now written to the stage. |
| Registering from a non-Linux-x86_64 host, or with a `python_version`
or `cuda_version` other than the installed one | Raises at registration.
|
| Export into a stage directory that already holds files | Refused
before scoring by default or with `APPEND`; `OVERWRITE` empties it
first, as on every file store. |
| `SNOWFLAKE_FULL` stage | Writes work; reads raise `OSError` naming
`SNOWFLAKE_SSE`. |
| Registry publish without kumo-engine, or if the builder fails | The
non-scoring carrier, as before (with a warning). |
| Same bundle registered again | Existing version if the serving
environment matches; else a new `V<n>`. |
| `ModelOutputConfig`, `SnowflakeTracking` | New optional
`serving_snapshot` / `serving_options`; existing calls unchanged. |
| `run_batch` output | Scores only; not a Kumo prediction run for
`evaluate` or `score_drift`. |

## Testing

- `kumo-snowflake/tests/test_stage_fs.py` (in-memory stage): routing,
bundles and Parquet through a stage path, listings, exact removes,
ranged and `GET` reads, the occupied-directory rule, refusals, no signed
URL in errors.
- `kumo-snowflake/tests/test_registry.py`: version reuse, builder
arguments, environment refusal, carrier fallback, bundle-only fetch.
- `kumo-engine/test/test_snowflake_model.py` and
`test_model_agnostic_mlops.py`: a version packaged by snowflake-ml
scores like `Trainer.predict`; serving options; staged assets load
through the loading connector; a stage root registers versions serving
its snapshot.
- Live on a Snowflake test account with synthetic data: stage file store
and an MLOps root on a stage; `run_batch` binary (300/300 rows, labels
equal to local `predict`) and regression on a GPU pool; all steps as a
role with only the documented grants.

Change map: see the `kumo-pr-change-map` comment.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

This branch was previously deployed

1 inactive deployment
gha-kumo-workflow-tests — 9d82a62a Deployed Nov 1, 2026 by Vedaant-J via import #1160
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants