Skip to main content

Fine-Tuning

Train models on your custom data to improve performance for domain-specific tasks. The platform supports 4 training methods (LoRA, QLoRA, full fine-tuning, and prompt tuning), with real-time monitoring and one-click deployment. What a job costs is shown in FinOps.

Overview​

Fine-tuning creates a specialized version of a base model by training on your data. The platform handles the full lifecycle:

  1. Configure - Select base model, training method, dataset, and hyperparameters
  2. Train - Dedicated GPU nodes run your training job with real-time metrics
  3. Monitor - Track loss curves and resource usage in real-time
  4. Deploy - One-click deployment as an inference endpoint

Base Models​

Fine-tuning offers one list of 103 open models, the same in the create wizard, the REST API (GET /api/v1/ai-gateway/fine-tuning/base-models), the Python SDK (client.fine_tuning.base_models()) and STAN. A job on any other model is refused. Every model is a causal language model, the kind the trainer fine-tunes; vision, speech and encoder-only models are not offered.

FamilyModelsProviders
Llama21Meta
Qwen16Alibaba, IFM
Mistral10Mistral AI
Deepseek8DeepSeek
Gemma8Google
Yi701.AI
Falcon6TII
Phi6Microsoft
Baichuan3Baichuan
Bloom3BigScience
ChatGLM3Zhipu AI
InternLM3Shanghai AI Lab
Starcoder3BigCode
GPT2EleutherAI, Microsoft
OpenELM2Apple
MiniCPM1OpenBMB
OLMo1Allen AI

In the wizard, filter by family or search by name, provider or size. Each model shows its size, its context window and the least GPU memory a LoRA fine-tune of it needs; the eight marked Recommended are good starting points. A model's entry also carries what a model fine-tuned from it is deployed with (GPUs, instance type, tensor-parallel degree and concurrent sequences), which Deploy uses unless you choose otherwise.


Training Methods​

LoRA (Low-Rank Adaptation)​

Adds small trainable matrices to model layers while freezing original weights.

  • Memory: ~50% of base model VRAM
  • GPU: 16GB minimum (T4 recommended)
  • Quality: Near full fine-tuning performance
  • Storage: 1-50MB adapter files

LoRA Parameters:

ParameterDefaultRangeDescription
Rank (r)161-256Dimensionality of adapter matrices. Higher = more capacity
Alpha321-512Scaling factor. Typically 2x rank
Dropout0.10-0.5Prevents overfitting. Higher for small datasets
Target Modulesq_proj, v_projVariousWhich layers get adapters

QLoRA (Quantized LoRA)​

LoRA with 4-bit quantization of the base model for maximum memory efficiency.

  • Memory: ~25% of base model VRAM
  • GPU: 8GB minimum (T4 recommended)
  • Quality: Minimal degradation vs standard LoRA
  • Best for: Large models (70B) on limited hardware

QLoRA Parameters:

ParameterDefaultOptionsDescription
Bits42, 3, 4, 5, 6, 8Quantization precision
Quant Typenf4nf4, int4, fp4Quantization algorithm
Double Quanttruetrue/falseQuantize the quantization constants
Compute Dtypefloat16float16, bfloat16, float32Compute precision

Full Fine-Tuning​

Updates all model weights for maximum customization.

  • Memory: 150% of base model VRAM (4-8x model size total)
  • GPU: 40GB+ (A100 recommended)
  • Quality: Maximum customization potential
  • Storage: Full model copy (10-140GB)
  • Best for: Significant domain shift, ample resources

Prompt Tuning​

Learns soft prompt embeddings prepended to inputs, keeping the full model frozen.

  • Memory: Minimal additional VRAM
  • GPU: 16GB+ recommended
  • Quality: Good for simple task adaptation
  • Storage: Very small adapter (< 1MB)
  • Best for: Quick experiments, task-specific tuning with minimal resources

Dataset Configuration​

Supported Formats​

FormatStructureBest For
JSONLOne JSON object per lineGeneral purpose
Alpaca{"instruction", "input", "output"}Instruction following
ShareGPT{"conversations": [...]}Multi-turn chat
OpenAI{"messages": [...]}Chat format
CSVColumnar dataClassification, simple tasks
ParquetCompressed columnarLarge datasets

Dataset Parameters​

ParameterDefaultDescription
Train/Val/Test Split80/15/5Automatic dataset splitting
Max SamplesunlimitedLimit training examples
Cutoff Length2048Maximum tokens per example (128-4096)
StreamingfalseStream large datasets from storage

Data Sources​

Every dataset is trained from a shared volume, so a job can use a dataset of any size:

  • Upload File - Choose a JSON, JSONL, CSV, Parquet or Arrow file and the shared volume to store it in
  • From Volume - Pick a file already in one of your shared volumes (an earlier upload, or a Data Forge export)
  • From URL - Enter an https:// link to a dataset file, or a Hugging Face dataset ID (hf://org/dataset), and choose the shared volume to store it in. A Hugging Face dataset is saved to that volume when the job starts, in the folder datasets/huggingface/org/dataset, and the job trains from it there. A later job that uses the same dataset and volume reuses the saved files. The dataset is read with the job owner's Hugging Face token from Profile > Integrations > HuggingFace; a gated or private dataset needs that token, with access granted on huggingface.co

Through the REST API, the Python SDK or STAN, name the volume together with the Hugging Face dataset ID or the link. A job for a Hugging Face dataset that names no volume is not created.

Dataset Requirements​

  • Minimum: 100 examples (1,000-10,000 recommended)
  • Validation: When a job starts, its dataset is checked before any GPU is used: format errors, duplicates and encoding problems (these checks can be turned off), and the length of every example (always checked)

Hyperparameters​

Training Parameters​

ParameterDefaultRangeDescription
Learning Rate2e-41e-6 to 1e-2Step size for weight updates
Batch Size41-32Examples per gradient step
Epochs31-50Complete passes through dataset
Gradient Accumulation41-32Simulates larger batch size with less memory
Warmup Steps1000+Gradual learning rate increase at start
Weight Decay0.010-1L2 regularization strength
Max Sequence Length2048128-4096Maximum tokens per example. A longer example is never cut: the job checks every example when it starts, before any GPU is used, and stops with the status Validation failed and a message naming each such row, its length in the base model's tokens and the maximum. Shorten or split those rows, or raise the maximum, then restart the job

Advanced Configuration​

SettingDefaultDescription
Early StoppingtrueStop training when validation loss plateaus
Save StrategystepsWhen to save checkpoints
Evaluation StrategystepsWhen to run evaluation
Logging Steps10Steps between log entries
Save Steps500Steps between checkpoint saves
Eval Steps500Steps between evaluations
Dataloader Workers4Parallel data loading threads (0-16)
FP16trueHalf-precision training for memory efficiency
Gradient CheckpointingtrueTrade compute for memory

Hardware Selection​

GPU Types​

The GPU Type list offers only the types the administrator's Compute selection provides (GET /compute/gpu-options); a GPU without enough memory for the model is disabled. Any other type is refused with 400. The types the platform knows:

GPUVRAMValid gpu_type ValueBest For
NVIDIA T416GBnvidia-t4LoRA/QLoRA on 7B models
NVIDIA L424GBnvidia-l4LoRA on 13B models
NVIDIA A10G24GBnvidia-a10gLoRA/Full on 7-13B models
NVIDIA A100 40GB40GBnvidia-a100-40gbFull fine-tuning 13B+, LoRA 70B
NVIDIA A100 80GB80GBnvidia-a100-80gbFull fine-tuning 70B
NVIDIA H10080GBnvidia-h100Maximum performance
NVIDIA L40S48GBnvidia-l40sLarger LoRA/QLoRA runs on one GPU
NVIDIA H200141GBnvidia-h200Full fine-tuning of large models
NVIDIA B200180GBnvidia-b200Full fine-tuning of the largest models

Hardware Configuration Options​

ParameterDefaultRangeDescription
GPU Type(required)A type GET /compute/gpu-options listsThe GPU the job runs on
GPU Count11-8Number of GPUs
Storage (GB)10050-1000Ephemeral storage
Instance Type(derived)OptionalLegacy field, derived from gpu_type
Use Spot InstancesOffOn / OffTrain on spot capacity; when it is reclaimed, training resumes from its last checkpoint
Fall back to on-demand when spot capacity is unavailableOnOn / OffWith spot: on-demand when no spot capacity is available; off waits for spot

VRAM Requirements by Method​

Model SizeQLoRALoRAFull
7B~4GB~8GB~28GB
13B~7GB~13GB~52GB
30B~16GB~30GB~120GB
70B~35GB~70GB~280GB

Monitoring​

Real-Time Metrics​

During training, monitor:

  • Training Loss - Should decrease consistently
  • Validation Loss - If increases while train loss decreases = overfitting
  • Learning Rate - Current rate per schedule
  • Training Speed - Samples/second throughput
  • Gradient Norm - Spikes indicate instability

Resource Monitoring​

  • GPU Utilization - GPU compute usage %
  • GPU Memory - VRAM used/total
  • GPU Temperature - Thermal monitoring
  • CPU/Memory - System resource usage

Logs​

Filter logs by source:

  • Build - Docker image build output
  • Deployment - Kubernetes deployment events
  • Training - Training loop output

Log levels: debug, info, warning, error, critical

Cost​

A job's cost is the infrastructure it ran on, recorded in the cost record and shown in FinOps only. The job page shows no cost or estimate.


Job Lifecycle​

Status States​

StatusDescription
pendingJob created, waiting to start
preparingUploading dataset, building Docker image
buildingDocker image being built and pushed to ECR
deployingKubernetes node provisioning
trainingModel training in progress
evaluatingRunning validation metrics
completedTraining finished successfully
failedError occurred (check logs)
stoppingStop requested, shutting down
cancelledStopped by user

Infrastructure​

Each fine-tuning job:

  1. Builds a custom Docker image (PyTorch 2.1.0 + CUDA 11.8 + HuggingFace)
  2. Pushes to AWS ECR
  3. Provisions a dedicated GPU node (AWS EKS) in the organization's namespace
  4. Runs as a Kubernetes Job with exclusive node access
  5. Uploads model artifacts to S3 on completion
  6. Cleans up node and resources

Post-Training​

After a job completes:

  • Deploy - One-click deployment as a vLLM inference endpoint (uses the same API as any other model)
  • Delete - Remove job, logs, metrics, and S3 artifacts

API Endpoints​

Job Management​

EndpointMethodDescription
/api/v1/ai-gateway/fine-tuning-jobsPOSTCreate a fine-tuning job (JSON body)
/api/v1/ai-gateway/fine-tuning-jobsGETList your jobs (cursor-paged)
/api/v1/ai-gateway/fine-tuning-jobs/{job_id}GETGet a job
/api/v1/ai-gateway/fine-tuning-jobs/{job_id}/statusGETGet a job's lifecycle status, synced live from the gateway
/api/v1/ai-gateway/fine-tuning-jobs/{job_id}/stopPOSTStop a running job
/api/v1/ai-gateway/fine-tuning-jobs/{job_id}/restartPOSTRestart a job
/api/v1/ai-gateway/fine-tuning-jobs/{job_id}/deployPOSTDeploy the fine-tuned model
/api/v1/ai-gateway/fine-tuning-jobs/{job_id}DELETEDelete a job
/api/v1/ai-gateway/fine-tuning-jobs/{job_id}/logsGETGet a job's logs from one source (logType: build, validation, training, deploy, or all)
/api/v1/ai-gateway/fine-tuning-jobs/{job_id}/metricsGETGet training metrics
/api/v1/ai-gateway/fine-tuning-jobs/statsGETCount the jobs you may use: total, active, completed and failed

Planning a job​

EndpointMethodDescription
/api/v1/ai-gateway/fine-tuning/base-modelsGETList the base models
/api/v1/ai-gateway/fine-tuning/hardwareGETList the hardware options
/api/v1/ai-gateway/fine-tuning/model-requirements?baseModel=&method=GETThe hardware and VRAM a base model needs (optionally for one method)
/api/v1/ai-gateway/fine-tuning/recommendPOSTA recommended configuration for a base model (baseModel, useCase, datasetSize)
/api/v1/ai-gateway/fine-tuning-jobs/validatePOSTCheck a configuration before creating the job (baseModel, method, hardware, methodConfig): valid, errors, warnings

See the Fine-tuning REST API for bodies and answers.


Best Practices​

Dataset Quality​

  • Minimum 1,000 examples for meaningful fine-tuning
  • Consistent format - Ensure all examples follow the same structure
  • Balanced distribution - Avoid class imbalance (>10:1 ratio triggers warnings)
  • Remove duplicates - Platform warns if >10% duplicates detected
  • Appropriate length - Set max_sequence_length based on your data distribution

Training Configuration​

  • Start with LoRA - Most cost-effective for initial experiments
  • Use QLoRA for large models - Fine-tune 70B on a single T4
  • Monitor validation loss - Stop early if it increases (overfitting)
  • Lower learning rate for larger models - 1e-5 for 70B vs 2e-4 for 7B
  • Increase rank for complex tasks - r=16-64 for specialized domains

Cost Optimization​

  • Start small - Test with subset of data before full training
  • Use QLoRA - 75% less GPU cost than full fine-tuning
  • Set early stopping - Avoid unnecessary training epochs
  • Right-size GPU - Don't use A100 for a 7B LoRA job

Next Steps​