Skip to content

Hold MLOps artifacts in Snowflake stages and score registry versions with run_batch - #115

Merged
Vedaant-J merged 833 commits into
mainfrom
vedaant/mlops-sf-stage
Nov 3, 2026
Merged

Vedaant-J merged 833 commits into
mainfrom
vedaant/mlops-sf-stage

Conversation

@Vedaant-J

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

Copy link
Copy Markdown
Contributor

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 (Let any sink hold files: FileStoreSink protocol and a chunked filesystem #112's FileStoreSink, as Hold MLOps artifacts on Unity Catalog volumes through the Files API #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

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

@Vedaant-J Vedaant-J self-assigned this Oct 24, 2026
@copy-pr-bot

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

@Vedaant-J
Vedaant-J temporarily deployed to gha-kumo-workflow-tests October 24, 2026 19:29 — with GitHub Actions Inactive
@coderabbitai

coderabbitai Bot commented Oct 24, 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.

Walkthrough

The changes add named internal-stage storage and Snowflake model registration and scoring. Serving snapshot and option metadata flow through model publication. Registry publication can reuse a version when its bundle and serving environment match. Model retrieval downloads registered version files through a Snowflake session. The changes also add a batch-inference smoke script and documentation for Snowflake serving, stage storage, and batch inference.

Sequence Diagram(s)

sequenceDiagram
  participant ModelVersion
  participant KumoModel
  participant score_registered
  participant Predictor
  ModelVersion->>KumoModel: run_batch invokes predict
  KumoModel->>score_registered: bundle, serving artifacts, rows, and scoring parameters
  score_registered->>Predictor: predict with loaded snapshot and rows
  Predictor-->>score_registered: prediction frame
  score_registered-->>KumoModel: prediction frame aligned to serving metadata
Loading
Merge Risk: Minimal · previous review 8670c

The previously identified registration and version-reuse risks are addressed in the current code. No actionable issue remains before normal checks and merge.

Pre-merge checks: Passed 2 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Change Map Design Review Warning The prior code concerns are addressed: check_host() rejects non-linux x86_64 registration at _snowflake_model.py:115-122, and _version_holding() restricts reuse to location.version when spec… Add or restore the complete PR conversation comment beginning <!-- kumo-pr-change-map -->. Include the observed problem, inspected existing behavior, rationale for each abstraction-layer change, smallest sufficient change, focused verific…
Passed Passed checks: 2 passed
Check name Status Explanation
Pr Size Passed The pull request changes 21 files in the authoritative review range. The failure threshold is more than 40 files, so this check passes.
Public Resource Access Passed The only new external URL is packages/kumo-engine/docs/mlops.md:320, linking to Snowflake batch-inference documentation. An anonymous request returned HTTP 200. The PyTorch URL already existed on th…
Full details: Public Resource Access

Explanation

The only new external URL is packages/kumo-engine/docs/mlops.md:320, linking to Snowflake batch-inference documentation. An anonymous request returned HTTP 200. The PyTorch URL already existed on the base branch, and the Snowflake repository and stage names are illustrative examples, so they are excluded.

Full details: Change Map Design Review

Explanation

The prior code concerns are addressed: check_host() rejects non-linux x86_64 registration at _snowflake_model.py:115-122, and _version_holding() restricts reuse to location.version when specified at registry.py:251-252; focused tests cover both cases. The required conversation comment beginning &lt;!-- kumo-pr-change-map --&gt; is not included in the supplied review context. The checkout contains only process/template references to that marker. Therefore the proposed design cannot be reviewed for the observed failure, abstraction choices, smallest sufficient change, focused verification, or stopping condition.

Resolution

Add or restore the complete PR conversation comment beginning &lt;!-- kumo-pr-change-map --&gt;. Include the observed problem, inspected existing behavior, rationale for each abstraction-layer change, smallest sufficient change, focused verification, and a stopping condition. Keep optional refinements separate from required design decisions.

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

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 7b3c997 and 8670c98.

Files selected for processing: 14
  • examples/mlops/snowflake/README.md
  • examples/mlops/snowflake/run_batch_smoke.py
  • packages/kumo-engine/docs/mlops.md
  • packages/kumo-engine/kumo/engine/integrations/_snowflake_model.py
  • packages/kumo-engine/kumo/engine/integrations/snowflake.py
  • packages/kumo-engine/kumo/engine/trainer/trainer.py
  • packages/kumo-engine/test/test_model_agnostic_mlops.py
  • packages/kumo-engine/test/test_snowflake_model.py
  • packages/kumo-engine/test/test_trainer_registry.py
  • packages/kumo-snowflake/src/kumo_snowflake/artifacts.py
  • packages/kumo-snowflake/src/kumo_snowflake/registry.py
  • packages/kumo-snowflake/src/kumo_snowflake/sink.py
  • packages/kumo-snowflake/tests/fakes.py
  • packages/kumo-snowflake/tests/test_registry.py

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

@Vedaant-J

Vedaant-J commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Change map

File Function / scope What changed Why
packages/kumo-snowflake/src/kumo_snowflake/stage_fs.py new: StageFileSystemHandler, stage_filesystem Chunked filesystem over a named stage: PUT, LIST, REMOVE, presigned ranged reads, GET fallback Stages have no multipart upload
packages/kumo-snowflake/src/kumo_snowflake/sink.py SnowflakeSinkBackend: holds_files, filesystem, writers, publish_model, fetch_model Stage paths go through FilesystemSink and its shared preflight; tables and registry unchanged Exports and bundles on @DB.SCHEMA.STAGE/...
packages/kumo-snowflake/src/kumo_snowflake/artifacts.py StageArtifactLocation.restore Imports rebased lazily Public connector image has no kumo_core.diskgraph
packages/kumo-snowflake/src/kumo_snowflake/registry.py publish_model, fetch_model, _model_args, _version_holding, _backfill, _export Runnable versions via an entry-point builder; reuse a version holding the bundle for the same serving environment, recording missing metrics on it; parallel fetch Score in Snowflake; no duplicate versions; faster alias load
packages/kumo-engine/kumo/engine/integrations/_snowflake_model.py new: KumoModel, log_model_args, pip_requirements, embedded_code, signature CustomModel scoring entity ids; registration arguments and environment Run Kumo models with run_batch
packages/kumo-engine/kumo/engine/integrations/_snowflake_serving.py new: score_registered, load_snapshot Scores rows in the container against a stage snapshot, reading assets with the container identity Serving path for registered versions
packages/kumo-engine/kumo/engine/integrations/snowflake.py SnowflakeTracking.serving_options New serving_options= argument Registry versions follow the tracker
packages/kumo-engine/kumo/engine/_tracking.py TrackingBase.serving_options Optional field trackers set Carries options to registration
packages/kumo-engine/kumo/engine/trainer/output_config.py ModelOutputConfig.serving_snapshot, serving_options Two optional fields; unknown options raise Configure the Snowflake serving version
packages/kumo-engine/kumo/engine/trainer/trainer.py _connector_registry, _publish, _store_and_register Serving settings into publish metadata; a stage root serves its snapshot Carry serving settings through publish_model
packages/kumo-engine/pyproject.toml entry points kumo_snowflake.registry_models → log_model_args kumo-snowflake cannot import kumo-engine
packages/kumo-snowflake/tests/fakes.py FakeStage, _stage_session In-memory stage: LIST, PUT, GET, REMOVE, presigned Range Tests need no account
packages/kumo-snowflake/tests/test_stage_fs.py new tests Paths, bundles, Parquet, ranged and GET reads, removes, occupied directory Covers the stage file store
packages/kumo-snowflake/tests/test_registry.py publish and fetch tests Reuse, builder arguments, environment refusal, carrier fallback, fetch Covers registry changes
packages/kumo-engine/test/test_trainer_registry.py export config fakes Carry serving_snapshot and serving_options Follows ModelOutputConfig
packages/kumo-engine/test/test_snowflake_model.py new tests Packaged version scores like the trainer; options; requirements Covers the Snowflake model
packages/kumo-engine/test/test_model_agnostic_mlops.py stage asset and registration tests Staged assets load through the loading connector; stage root registers versions serving its snapshot Covers Snowflake serving
packages/kumo-snowflake/README.md stage and registry sections Stage paths, grants, runnable registry versions Setup the code cannot show
packages/kumo-engine/docs/mlops.md Snowflake serving, Assets, Grants Batch inference in Snowflake; asset identity per loading call User docs for the new paths
examples/mlops/snowflake/run_batch_smoke.py new script Fit, register, run_batch, compare with local scores Live check of Snowflake serving
examples/mlops/snowflake/README.md Snowflake job README Says run_batch writes scores only: no Kumo prediction run, nothing for evaluate or score_drift Keeps the two scoring paths apart
packages/kumo-engine/kumo/engine/_deps.py stored_roots Stored asset roots on a given store, shared by connector lookups and the Snowflake container The container reads staged assets

@Vedaant-J
Vedaant-J force-pushed the vedaant/mlops-sf-stage branch from 86d7e79 to b9ba641 Compare October 24, 2026 20:30
@Vedaant-J
Vedaant-J temporarily deployed to gha-kumo-workflow-tests October 24, 2026 20:30 — with GitHub Actions Inactive
@Vedaant-J
Vedaant-J temporarily deployed to gha-kumo-workflow-tests October 24, 2026 21:02 — with GitHub Actions Inactive
@Vedaant-J
Vedaant-J temporarily deployed to gha-kumo-workflow-tests October 24, 2026 21:25 — with GitHub Actions Inactive
@Vedaant-J
Vedaant-J force-pushed the vedaant/mlops-sf-stage branch from 42acd3d to 28cdf93 Compare October 26, 2026 18:29
@Vedaant-J
Vedaant-J temporarily deployed to gha-kumo-workflow-tests October 26, 2026 18:29 — with GitHub Actions Inactive
@Vedaant-J
Vedaant-J changed the base branch from vedaant/mlops-prediction-tracking to vedaant/mlops-filestore-sink October 26, 2026 18:29
@Vedaant-J
Vedaant-J force-pushed the vedaant/mlops-sf-stage branch from 28cdf93 to 0a24e45 Compare October 27, 2026 07:30
@Vedaant-J
Vedaant-J temporarily deployed to gha-kumo-workflow-tests October 27, 2026 07:30 — with GitHub Actions Inactive
@Vedaant-J
Vedaant-J force-pushed the vedaant/mlops-sf-stage branch from 0a24e45 to 348c337 Compare October 27, 2026 09:51
@Vedaant-J
Vedaant-J temporarily deployed to gha-kumo-workflow-tests October 27, 2026 09:51 — with GitHub Actions Inactive
@Vedaant-J
Vedaant-J force-pushed the vedaant/mlops-sf-stage branch from 348c337 to ff5a9c6 Compare October 27, 2026 18:58
@Vedaant-J
Vedaant-J temporarily deployed to gha-kumo-workflow-tests October 27, 2026 18:59 — with GitHub Actions Inactive
@Vedaant-J
Vedaant-J changed the base branch from vedaant/mlops-filestore-sink to vedaant/mlops-score-sketch October 27, 2026 20:36
Victsm
Victsm previously approved these changes Nov 3, 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 01a2b87. Snowflake stage/registry checks pass (67 focused tests), and the dependent file/volume/tracking fixes are preserved. The native run_batch lifecycle limitation is documented separately from canonical Trainer prediction records. No new code blocker found; no fresh live Snowflake qualification was performed in this pass.

Vedaant-J and others added 24 commits November 3, 2026 19:52
The MLflow runs list shows a run's first input, so a fit logs its
training table, then its graph snapshot, then its source tables by name.
The snapshot input lists its id and each table's row count as its schema.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@nivle1661 nivle1661 mentioned this pull request Nov 3, 2026
3 tasks done

This branch was previously deployed

1 inactive deployment
gha-kumo-workflow-tests — 41837408 Deployed Nov 3, 2026 by Vedaant-J via import #1418
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