Deploy and Scale
Deploying
Select Deploy on a model's page; it is offered while the model is Ready to Deploy or Failed. A Stopped model is brought back with Start, which runs it on the image it was built with, at the size and scaling saved on its Environment tab. The model builds its serving image (Building), starts (Deploying, Starting) and serves (Running), using the size and scaling saved on its Environment tab. Follow it on the Logs tab.
- Stop takes a running model down; it keeps its versions, settings, predictions and monitoring. Start brings a stopped model back.
- Delete removes the model, its versions, its deployment and its uploaded files. A model connected to apps is not deleted until it is disconnected; if its deployment cannot be deleted, the model is kept and the message says why.
Deploying can require governance approval when a governance solution covers ML models.
Retrain to deploy
An AutoML model is served on the trainer image that trained it (its Trainer Image on the Overview tab), whatever the current trainer is: a model only loads with the libraries it was trained with. An environment's container image never replaces it.
A model published before AutoML jobs recorded their trainer image is marked Retrain to deploy, on its page and in the Models list. Deploy, Start and Deploy this version are not offered, and the REST API and the Python SDK refuse them with the reason. Retrain its AutoML job with the same data and settings, publish the new model, and delete the old one.
The Environment tab
The model's editors change how it is served here. Save keeps the settings for the model's next deploy; on a running model, Save & Restart saves them and redeploys it with them as a rolling update (the current pod serves until the new one is ready). Changing a running model's settings requires a restart.
Resource Configuration
- Environment: a pre-configured size (its vCPUs, memory and GPUs), or Custom Configuration to set each:
- CPU (vCPU): 1, 2, 4, 8 or 16;
- Memory (GB): 4, 8, 16, 32 or 64;
- GPU: none, or 1, 2, 4 or 8, with the GPU type;
- Disk Space (GB): 10, 20, 50, 100 or 200.
- Replicas: the pod count when the model is active (1 to 10). An always-on model holds this count; an on-demand model wakes from zero to it.
The size is the whole workload, exactly what it requests and is limited to: the platform's helper services beside the model come out of it, never on top, and a size bigger than the largest allowed machine gives one workload is refused naming the resource and both figures (see the largest size a workload can have). The model's math libraries (PyTorch, NumPy, ONNX Runtime) run as many threads as it has vCPUs: the workload sets OMP_NUM_THREADS, MKL_NUM_THREADS and OPENBLAS_NUM_THREADS to its CPU size, and a bundle's manifest or the model's own environment variables can set a different count. The disk is the workload's temporary local storage: a model that writes more than its disk is evicted, so raise the disk if it is.
Scaling Strategy
The same five strategies a self-hosted model has:
| Strategy | How it runs | Settings |
|---|---|---|
| Always-on (fixed replicas) | Holds Replicas pods all the time. Every prediction is answered at once. | |
| Always-on + auto-scaling | A Kubernetes HPA scales between min and max on CPU and memory use, read on Kubernetes' own schedule. Never scales to zero. | Min Replicas (1 to 20), Max Replicas (2 to 50), CPU Threshold (%) (default 70), Memory Threshold (%) (default 80) |
| Scheduled (runs during set hours) | Started with Replicas pods at each start time and stopped at each stop time, on the days you choose. | Days of Operation, Operating Hours (one or more start and stop times; Add Time Range), Timezone |
| On-demand (scales to zero) | Scales to zero when idle and wakes to Replicas on its first prediction. | Auto-shutdown after idle (minutes) (1 to 1,440, default 15) |
| On-demand + auto-scaling | Wakes from zero, then sizes the fleet to the live request load (in-flight predictions divided by the target), between min and max, and scales back to zero when idle. | Auto-shutdown after idle (minutes), Min Replicas, Max Replicas, Target Concurrency / Replica (default 3) |
On-demand suits low-traffic models that should not keep an idle pod. The first prediction after a scale-down waits for the pod to start (a cold start, typically 30 to 90 seconds for a scikit-learn model). The registry list shows a scaled-down on-demand model as Idle (on-demand).
A scheduled model is started and stopped by the platform as its Start and Stop buttons do. A start is checked against your budgets like any start, and a time that passes while the model is still building or starting is applied when it is running. Between its windows, a scheduled model is Stopped; you can still start or stop it by hand.
Scheduling and demand scaling apply to a deployed model as soon as they are saved; resources and spot from its next deploy or start (Save & Restart on a running model). A start always runs the model as its Environment tab is saved, whether you start it or its schedule does.
Long predictions
A prediction runs as long as it takes; nothing on the way to the model cuts it on a clock. When a worker is stopped (scaled down, replaced by a new version, or moved off its node), it takes no new predictions and has 30 minutes to finish the ones it holds. A prediction still waiting for a free worker when the AI Gateway restarts is answered 503 and sent again by the workflow node, since it never reached the model.
A prediction is never sent twice. If the connection closes after the request reached the model and before its answer came back, the call fails with an error that opens Response lost: and the workflow does not run that item again, because the model may already have done the work.
Spot capacity
Use Spot Instances runs the model on spot capacity, which is cheaper but can be reclaimed: the pod is then restarted on another node, and predictions in flight at that moment fail with Response lost: (they are not sent again). Fall back to on-demand when spot capacity is unavailable (on by default) prefers spot: the model runs on a spot node when one has room or a new node is added for it, and on on-demand capacity otherwise; turned off, the model waits for spot capacity.
Versions
Each model keeps its versions on the Versions tab, each with its status, the experiment run it was registered from (Run), description, size (and file count for a bundle) and creation time.
Versions are numbered. A version's only status is Deployed: the version serving now (the model's active version while the model is deployed; an A/B test routing to the model is served by it too). Every other version is kept and can be deployed again.
- Add Version uploads a new artifact as the next version (see Register a model).
- Set as Active makes a version active on a model that is not deployed.
- Deploy this version makes it active and deploys the model with it; this is also how you roll back to an earlier version. The current version serves until the new one is ready. An AutoML version that records no trainer image cannot be deployed (see Retrain to deploy).
- Delete version deletes a version you no longer want, such as a duplicate: its image, its uploaded bundle, its baselines and the drift analyses against them. When another version is the same upload, the bundle and image stay for that version. The dialog says what is deleted before you confirm.
You cannot delete the active version (deploy or activate another one first), the only version (delete the model instead), a version being deployed, or a version whose baseline is being built.
A deleted version's predictions are kept. They show as, for example, v3 (deleted), and the tab lists the deleted versions. A new version never reuses a deleted version's number. A run that registered the version shows it as deleted.
The active version is the one the model serves and the one drift analyzes. Each version keeps its own drift baseline, so a version you switch to is compared with its own reference data. A model trained on a feature service serves the features its own version trained on.
From Python
client.model_registry.deploy(model_id)
client.model_registry.stop(model_id)
client.model_registry.start(model_id)
client.model_registry.delete_version(model_id, 3)
A model's retrain_reason says why it must be retrained before it can be deployed or started, None when it can be; deploying or starting such a model raises ConflictError with that reason.
The REST API's POST /api/v1/mlops/models/{id}/deploy takes the same size and scaling as the Environment tab: resources, autoShutdownMinutes (above 0 deploys on demand), schedulingMode (always_on, on_demand or scheduled), scheduleRules, scalingMode (fixed or auto), minReplicas, maxReplicas, targetConcurrency, useSpot and spotFallback. PATCH /api/v1/mlops/models/{id}/serving changes them without deploying. See the Model Registry API.