# Write your own training loop — without managing GPUs — with Amazon SageMaker training session APIs

> **Publication**: aitalky (Independent AI Journalism)
> **Canonical Citation URL**: https://aitalky.vercel.app/news/write-your-own-training-loop-without-managing-gpus-with-amazon-sagemaker-training
> **Original Source**: [AWS ML Blog](https://aws.amazon.com/blogs/machine-learning/write-your-own-training-loop-without-managing-gpus-with-amazon-sagemaker-training-sessions/)
> **Author**: Nicolas Jourdan (undefined)
> **Published Date**: Thursday, October 22, 2026
> **Category**: PRODUCTS
> **Tags**: AI, AWS ML Blog, products

## Executive Summary
Amazon SageMaker AI training session APIs let you write your own LLM training loop (SFT, RL, or custom objectives) in a Python script while the service runs the GPUs.



## Full Coverage
Fine-tuning a large language model (LLM) today usually forces a tradeoff between training loop control and operational simplicity. With fully managed services you select a base model, provide data and hyperparameters, and the service owns everything else, which works well when a standard, prepackaged recipe fits your problem. Less managed services give you more control, but you also manage more of the underlying infrastructure and training frameworks. Sometimes a standard recipe isn't enough: you need a custom loss or data curriculum for supervised fine-tuning (SFT), your own preference optimization, a reinforcement learning (RL) reward function, or an alignment algorithm published last week. As soon as you need to shape the training procedure yourself, you take on that infrastructure work to gain algorithmic freedom

Today, serverless model customization in Amazon SageMaker AI expands with training session APIs, which remove that tradeoff by drawing the abstraction boundary one level lower. Instead of abstracting away the algorithm, they abstract away the compute. Operations like forward_backward() , optim_step() , and sample() become SageMaker API calls that you compose into whatever procedure your technique requires: SFT, preference optimization, RL, or something new. The calls target a live, stateful session, so the model stays loaded on the GPUs across steps, and you drive as many calls as you need against it. The service handles runtime setup, distributed execution, gradient synchronization, fault recovery, tenant isolation, and the operations of running GPUs at scale. You write the training loop, and SageMaker AI runs the infrastructure

Alongside the service, we're releasing the SageMaker training sessions cookbook , a set of ready-to-run SFT and RL recipes that you can use as blueprints for your own training loops

---
*Generated for AI agents and LLM citation by aitalky (https://aitalky.vercel.app).*
