Repository navigation
Works on My Sandbox: Verifying xgb_train End-to-End #1821
paulzim
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Works on My Sandbox: Verifying xgb_train End-to-End
I had a Michelangelo sandbox running on my laptop, and I wanted to poke at a working ML platform once I had one. So I picked an example pipeline from
michelangelo-examples:xgb_train, XGBoost regression on the classic California Housing dataset and ran it end-to-end. That turned into a bit of an adventure. Here's what the pipeline does, what broke, and why "just run it" is an underrated way to spend an afternoon.The problem being solved
The data is the "California Housing" dataset, which is ~20,000 homes from the 1990 census, each with room count, building age, area median income, location, and the actual sale price as the target. That target caps at $500,001, presumably so a few Atherton mansions didn't skew the set. In 2026 California, $500,001 gets you a down payment.
It's a stand-in. Any real Michelangelo pipeline with ETAs, fraud risk, whatever, has the same shape (input columns, one number to predict), so it's a small, fast way to prove the plumbing works before pointing it at something real.
What XGBoost is, without the math
XGBoost is a popular algorithm for exactly this "predict a number from some columns" problem: it builds a sequence of simple decision trees ("is median income above $50k? older than 30 years?"), where each tree corrects the mistakes of the ones before it. A few hundred small, weak trees add up to one strong predictor... fast, hard to beat on spreadsheet-shaped data, and everywhere in industry.
The pipeline, like a recipe
The whole job is four steps, each handing its output to the next:
feature_prep— fetch the raw housing data and split it into a training pile and a validation pile, kept aside so the final accuracy check isn't just the model grading its own homework.preprocess— reshape the data into the numeric format training expects. Runs on Spark, the big-data engine real-world pipelines use.train— feed the training pile to XGBoost. Runs on Ray, a framework for spreading compute across machines, mostly here to prove the distributed path works, since this dataset could train on one laptop core in seconds.push_step— files the finished model and an accuracy report card into Michelangelo's model registry, a catalog others can browse for trained models.Under the hood: what each step is actually doing
Each step runs as its own isolated unit of work. The platform spins up dedicated compute (a small Ray or Spark cluster), runs the step, and tears it down. Steps never share a process or in-memory data; each one writes its output to shared storage (MinIO, an S3-compatible store, in my case) and passes along a lightweight handle (
DatasetVariable) pointing at where that data lives. The next step reads the handle and pulls the data itself. That's how Ray and Spark, two unrelated engines, hand work to each other without ever talking directly.feature_prepray.data.from_pandas(...)into a Ray Dataset, a table Ray can split across machines. Overkill at ~20,000 rows, but the same code path a multi-terabyte dataset would use.DatasetVariableand written to storage; only the handle moves forward.preprocessfeature_prepwrote, now as a Spark DataFrame instead of a Ray Dataset. Same files, different engine's API.float. A production pipeline built from this template would do real feature engineering here; this step just proves the plug-in point works.DatasetVariables fortrainto pick up.trainuuid/datestrcolumns so they're never mistaken for model inputs.ray.cluster_resources()) before training, reserves half for Ray's own data-shuffling, and splits the rest across workers, so the same code runs unmodified on a 3-core sandbox or a production cluster, no hardcoded worker count.xgboost.DMatrix(XGBoost's pre-sorted, pre-bucketed format).xgboost.train(...)runs with this pipeline's settings (10 boosting rounds, depth-5 trees); Ray'sXGBoostTrainerkeeps workers coordinated so they jointly build one model, exchanging summary stats each round so every worker's trees reflect the whole dataset. That coordination is what "distributed training" means here. A callback checkpoints progress and reports accuracy after each round.model.ubj) and the final round's metrics, including the validation RMSE used as this exercise's success signal.push_stepdefault/ray_results/run-..., nots3://...), expecting the caller to already know the storage system. This step re-attaches the prefix, then usesfsspecto find and download the model file.ma model getreads from), or a fake in-memory one for unit tests.Why run it inside a fake mini-cluster
Rather than risk a shared or production cluster, this all ran inside
k3d, a disposable Kubernetes cluster that lives entirely in Docker on a laptop. Same APIs, same building blocks as the real thing, just smaller. It's a safe place to prove a pipeline works before it touches anything that matters.Two ways to press "go" (and three places the results can land)
Two ways to kick off the same pipeline:
remote-run— a one-off command-line trigger. Fire-and-forget; good for quick testing.ma pipeline apply+dev_run— registers the pipeline and the run as trackable records, which is what populates MA Studio's "Pipelines"/"Pipeline Runs" tabs.Once a run is going, though, there are three separate systems of record — each populated only if something explicitly writes to it:
flowchart LR subgraph Triggers["Two ways to press \"go\""] A["remote-run<br/>(one-off CLI)"] B["ma pipeline apply<br/>+ dev_run"] end subgraph Layers["Three places results can land"] C["Cadence workflow execution<br/>cadence CLI / Web UI"] D["Pipeline / PipelineRun catalog<br/>MA Studio: Pipelines, Pipeline Runs"] E["Model registry<br/>MA Studio: Trained Models / ma model get"] end A --> C B --> C B --> D C -->|push_step| E classDef trigger fill:#e0f2fe,stroke:#0369a1,color:#0c4a6e; classDef layer fill:#fef3c7,stroke:#b45309,color:#78350f; class A,B trigger; class C,D,E layer;Early on,
remote-runworked and the model showed up in the registry, but Studio's "Pipelines"/"Pipeline Runs" tabs stayed empty, becauseremote-runtalks straight to Cadence and skips the catalog layer entirely. Not a bug, just two separate front doors into the same house (fitting, for a pipeline about housing prices), and only one of them has a mail slot.How I know it actually worked
Two independent signals confirmed success:
1.3883880945235523, matching a known-good baseline exactly.ma model get --namespace california-housingshowed the new model, confirming the whole pipeline, not just the training math, completed end to end.Why bother running an example end-to-end?
Nothing about this model is meant for anything real. It's 20K rows of 1990 census data. The point was never the model; it was proving the published pipeline actually runs on a fresh setup. Along the way I bumped into some stuff to resolve, like a container
PATHissue, a missing dataset file, a platform scheduling bug (hiding in the exactcontrollermgrsubsystem from my last post), and a resource-sizing issue. None of that would have shown up from reading the code alone. It only surfaced because I actually ran it, start to finish, on a clean checkout.If you want to poke at it yourself, the pipeline's here, and its README has the run instructions.
A couple of questions for the group: What's your favorite "toy" dataset for kicking the tires on a new ML platform: California Housing, Iris, Titanic, something else? And if you've poked at Michelangelo's example pipelines yourself, which one should I run next?
All reactions