Cloud ML infrastructure
Start with three bookstore workloads
A bookstore wants to forecast tomorrow's demand each night, predict stock shortages during checkout, and answer questions about its return policy. The first can run batch inference over a file, the second may need an online endpoint with a measured latency target, and the third may use a hosted foundation model with document retrieval. Training changes model parameters using examples and an objective; inference applies a trained model to new input. A notebook is an interactive development environment, not a production scheduler. For a stable forecast, start with a simple baseline before choosing GPUs or a large model. Compare accuracy, latency, throughput, freshness, privacy and total cost. No live cloud account is required for this chapter.
Choose compute and bound its cost
CPU inference can be adequate for small models; GPUs accelerate suitable parallel matrix operations, but memory capacity, precision, data-loading throughput and inter-device communication limit usable performance. Training often needs more memory than inference because gradients and optimizer state must be stored. Benchmark representative input and output lengths, batch sizes and concurrency; don't extrapolate peak theoretical FLOPS to actual request throughput. A fictional training job uses 2 GPUs for 3 hours at $2/GPU-hour: $12 accelerator compute. Add host, storage, network and failed jobs as applicable; some instances bundle GPU and host instead. A 2-replica endpoint at $0.60/replica-hour for 720 hours costs $864 even if mostly idle under this model. A batch job using 4 workers for 2 hours at $0.60 costs $4.80 per run, or $144 for 30 runs. These are hypothetical prices, not quotes; the modes meet different latency requirements. Set maximum duration, instance count, queue length and spending authorization, and delete or stop idle resources according to product semantics. Budget alerts are not hard limits.
Design the model lifecycle
Version data snapshots, preprocessing code, model artifact, environment, training configuration and evaluation results. Split training, validation and held-out testing to avoid leakage; for time series use time-aware splits. A model registry records versions and metadata, not necessarily running endpoints. Promote only approved versions through staging; deploy to a small traffic fraction or shadow traffic with privacy review, compare quality and latency, then expand or rollback to the last approved model and matching feature pipeline. MLOps applies reproducible build, test, release and monitoring practices to models and data. Track model version, missing features, distribution shift, delayed ground truth, error by relevant cohort, p95 latency, saturation and cost. Drift signals a need for investigation, not automatic proof of lower accuracy. Retraining needs a fresh evaluation and approval. Use notebook identities with scoped access, private datasets and short-lived credentials; never include secrets in notebooks or artifacts.
Compare provider service families
AWS SageMaker AI offers model registry, deployment and batch transform options; Amazon Bedrock provides managed foundation-model access and related generative AI capabilities. Azure Machine Learning supports training and managed online or batch endpoints; Microsoft Foundry provides a model catalog and multiple deployment options, including managed compute for supported models. Google documentation now describes Gemini Enterprise Agent Platform as an evolution of Vertex AI and lists renamed services such as Model Registry; existing Vertex AI names may remain in SDKs or documentation. Compare a custom training workflow with a hosted model API rather than assuming equivalent services. Confirm the selected model ID, lifecycle, license, quota, supported hardware, deployment type, project eligibility and actual processing geography. The names are based on documentation excerpts accessed 2026-11-28, not live tenant access. SageMaker inference, model registry, Foundry catalog, Google naming changes.
Capacity and evaluation worksheet
Suppose one tested replica sustains 20 requests/s at the required p95, and you target 75% of that rate for headroom: 15 requests/s. For a 65 requests/s peak, ceil(65/15)=5 replicas; if one may fail, plan 6 under identical capacity and perfect load balancing. Check placement, shared dependencies and startup lag; this is a sizing estimate, not a guarantee. A classifier correctly labels 90 of 100 test examples, but detects only 6 of 10 actual shortages: accuracy 90%, shortage recall 60%. Record both and evaluate false alerts, per-group performance, confidence and cost of errors. For a nightly job, confirm completion before its deadline; for real-time predictions, test p95/p99 and overload handling. A model with higher offline accuracy can be worse in production if it misses the latency target. Prefer a documented rollback condition and human review when results are uncertain.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Cloud ML infrastructure — knowledge check
Choose the best answer for each offline scenario.
Which workload best fits batch inference?
What does training change?
At $2 per GPU-hour what do 2 GPUs for 3 hours cost?
What does model registry approval record?
What is shortage recall with six detected of ten actual shortages?