Skip to main content
Training Jobs runs your training code on managed cloud GPUs. You bring your own framework, point it at a GPU type, and submit. Baseten handles provisioning, syncs checkpoints as they’re saved, and deploys any checkpoint as a production endpoint in one command. This tutorial fine-tunes Qwen3-4B with LoRA on a single H100, from job submission to calling the deployed model. You’ll set up a project directory, define your infrastructure in a configuration file, and write the training scripts that run on an H100. You’re billed per minute of GPU time while the job runs and while the deployed model serves traffic; see Baseten pricing for H100 rates. The training job is capped at 50 steps and ends on its own within minutes.

Prerequisites

Create your training project

Write your configuration file

Your configuration file uses the truss_train library to define your training infrastructure as Python objects:
  • TrainingProject: the top-level container for your project.
  • TrainingJob: a single job within a project, combining:
    • Image: what container to run.
    • Compute: what hardware to provision.
    • Runtime: how to start training and what to persist.
This is the file Baseten reads when you submit a job. It tells the platform which GPU to provision, which container image to use, and where to sync checkpoints. Create config.py:
config.py
CacheConfig avoids re-downloading models and datasets between jobs. CheckpointingConfig tells Baseten to sync your saved checkpoints so you can deploy them later.

Write your training scripts

Create run.sh to install dependencies and launch training. This tutorial uses pip install in the start command, but you can also pre-install dependencies in a custom base image.
run.sh
Your train.py is your own training code. Baseten runs it as-is, so you can use any framework or training loop that works locally. This example fine-tunes Qwen3-4B on the pirate-ultrachat-10k dataset using LoRA with TRL (Transformer Reinforcement Learning). The dataset teaches the model to respond in pirate dialect, so you’ll know fine-tuning worked when the deployed model starts saying “Ahoy, matey!”
train.py
Save checkpoints to $BT_CHECKPOINT_DIR so Baseten can sync and deploy them. Baseten sets this variable automatically when checkpointing is enabled.
With save_steps=25 and max_steps=50, the trainer saves LoRA checkpoints at steps 25 and 50.

Submit your training job

Now that your project is set up, submit your training job. The CLI packages your files, creates the training project, and starts the job on your specified GPU.
You’ll see:
Copy the job_id to use in the next steps.

Monitor your training job

Tail logs in real time with the job ID from the previous step.
You can also view logs, metrics, and job status in the Baseten dashboard.

Deploy your trained model

Checkpoints sync while training runs: the logs show each one move from SYNCING to COMPLETE as it’s saved. When the job finishes, you’ll see:
To deploy a checkpoint:Deploy your checkpoint to Baseten’s inference platform. The deployment downloads the base model weights and serves them with your LoRA adapter using vLLM. This step uses the hf_access_token secret from the prerequisites because the serving layer downloads the base model separately.
Follow the interactive prompts to select a checkpoint, name your model, and choose a GPU.
To script this step instead of answering prompts, pass --config with a DeployCheckpointsConfig and --non-interactive; see serve your trained model.

Test your deployment

Call your deployed model using the OpenAI-compatible chat format. The model field matches the checkpoint name you selected during deployment.
To call your deployed model:Set your API key as an environment variable:
Then send the request:
The fine-tuned model responds in pirate dialect, confirming that the LoRA adapter is active. Qwen3 opens its reply with a (often empty) <think> block from its reasoning mode:

Next steps