Prerequisites
- A Vast.ai account with credits
- The Vast.ai CLI installed locally:
You can find your API key at cloud.vast.ai/cli.
- An SSH key added to your Vast.ai account (see SSH setup guide)
Hardware Requirements
- GPU VRAM: 16 GB minimum — training peaks at ~14 GB with LoRA and gradient checkpointing. A 24 GB card (RTX 3090/4090, A5000, A100) gives enough headroom to raise the batch size or sequence length.
- Disk: 100 GB (model weights ~6 GB, plus dataset cache and checkpoints)
- CUDA: 12.4+
Find and Rent a GPU
Search for a GPU instance with at least 16 GB VRAM, CUDA 12.4+, and a fast network downlink:<OFFER_ID> with an ID from the search results:
new_contract: 33402620). Use this <CONTRACT_ID> for all subsequent commands.
Instances typically reach running status in 2–5 minutes (not counting Docker image pull time). Poll with the following loop, which exits automatically once the status is running:
ssh and scp command in this guide reuses them:
Configure Training
Axolotl uses a single YAML file to configure the entire training job. Save the following asconfig.yml on your local machine:
nano or vim if you prefer.
The following table explains the key settings:
Run Training
SSH into your instance and launch the training run:Weights & Biases (W&B) is an experiment tracking platform. Setting
WANDB_MODE=disabled skips it so you are not prompted for a login. To enable tracking, set wandb_project in your config and run wandb login first.loss (how wrong the model’s predictions are — lower is better), grad_norm (magnitude of parameter updates), and epoch (progress through the dataset, where 1.0 = one full pass):
./outputs/qwen25-3b-lora/. The adapter is approximately 80 MB, compared to the 6 GB base model.
Test the Fine-Tuned Model
Verify the fine-tuned model by running inference. Save the following astest_inference.py on your local machine:
Download Your Model
Before destroying the instance, download the LoRA adapter to your local machine:Qwen/Qwen2.5-3B), which can be re-downloaded from HuggingFace.
Cleanup
Destroy the instance to stop billing:Next Steps
- Train longer: Increase
num_epochsto 3–4 or use the full 100K dataset (split: train) for better results - Try QLoRA: Add
load_in_4bit: trueand changeadapter: qlorato reduce VRAM further — useful for larger models like Qwen2.5-72B - Merge the adapter: Run
axolotl merge-lora config.ymlto combine the LoRA weights into the base model for faster inference without the PEFT library - Use your own data: Replace the dataset with your own JSONL file in Alpaca or conversation format
- Scale to multi-GPU: Add a
deepspeedorfsdpconfig section for distributed training across multiple GPUs — see the multi-node training guide