Hardware-isolate,

Back to Blog
Tutorial
Jul 28, 2026
6 min read

Fine-Tune Your First LLM on a GPU Slice

Learn how to fine-tune a 7B-parameter LLM like Llama 3.1 8B on a single 24GB GPU slice using QLoRA.

Fine-Tune Your First LLM on a GPU Slice Banner
You don't need 8 H100s to fine-tune a language model. With parameter-efficient techniques like LoRA and QLoRA, you can fine-tune a 7B-parameter model on a single 24GB GPU slice — the kind that costs about $0.50/hour instead of $12/hour for a dedicated GPU.
This guide walks you through fine-tuning Llama 3.1 8B on your own dataset using QLoRA, deployed on Istidlal's GPU slices. You'll have a custom model running in under an hour, including training time.

Why Fine-Tune on a Slice?

Full fine-tuning updates every parameter in the model. For an 8B-parameter model in FP16, that's 16GB just for the weights, plus 16GB for optimizer states — you need at least 40GB of VRAM, which means a dedicated A100 or H100.
LoRA (Low-Rank Adaptation) freezes the base model and trains small adapter matrices instead. QLoRA goes further — it quantizes the base model to 4 bits, cutting VRAM usage by 4x. The result: you can fine-tune an 8B model on a 24GB slice.
Figure 1: VRAM Memory Footprint: Full Fine-Tuning vs LoRA vs QLoRA on 8B Models

Figure 1: VRAM Memory Footprint: Full Fine-Tuning vs LoRA vs QLoRA on 8B Models

Step 1: Prepare Your Dataset

We'll use the Alpaca instruction-tuning dataset as an example. Your data should be in a JSONL file with instruction, input, and output fields:
json
1{"instruction": "Convert this sentence to passive voice", "input": "The cat ate the mouse.", "output": "The mouse was eaten by the cat."}
2{"instruction": "Classify the sentiment", "input": "I loved every minute of this movie!", "output": "Positive"}
Upload your dataset to the platform's storage:
shell
1istidlal storage upload ./my-dataset.jsonl datasets/alpaca-custom/

Step 2: Create the Fine-Tuning Function

From the dashboard or CLI:
yaml
1containerImage: winglian/axolotl:v0.5.0
2inferencePort: 8000
3gpu:
4  mode: shim
5  framework: generic
6  multiplexing: 2
7resources:
8  limits: { memory: 32Gi }
9args:
10  - "--config"
11  - "/workspace/config.yaml"
Axolotl is a popular fine-tuning framework that wraps Hugging Face's PEFT library. It handles LoRA/QLoRA configuration, dataset loading, and checkpoint saving.

Step 3: Configure QLoRA

Create a config.yaml:
yaml
1base_model: meta-llama/Llama-3.1-8B
2model_type: LlamaForCausalLM
3tokenizer_type: AutoTokenizer
4
5load_in_8bit: false
6load_in_4bit: true
7strict: false
8
9datasets:
10  - path: /workspace/datasets/alpaca-custom/my-dataset.jsonl
11    type: alpaca
12
13dataset_prepared_path: /workspace/last_run_prepared
14output_dir: /workspace/output
15
16sequence_len: 2048
17sample_packing: true
18pad_to_sequence_len: true
19
20lora_r: 16
21lora_alpha: 32
22lora_dropout: 0.05
23lora_target_modules:
24  - q_proj
25  - k_proj
26  - v_proj
27  - o_proj
28  - gate_proj
29  - up_proj
30  - down_proj
31
32gradient_accumulation_steps: 4
33micro_batch_size: 2
34num_epochs: 3
35optimizer: adamw_8bit
36lr_scheduler: cosine
37learning_rate: 0.0002
38
39train_on_inputs: false
40group_by_length: false
41bf16: auto
42fp16: false
43
44wandb_project: my-finetune
45wandb_watch: gradients
The key settings: load_in_4bit: true (QLoRA), lora_r: 16 (rank 16 adapters), micro_batch_size: 2 with gradient_accumulation_steps: 4 (effective batch size 8, fits in 24GB VRAM).
Figure 2: QLoRA Parameter-Efficient Fine-Tuning Workflow & Architecture

Figure 2: QLoRA Parameter-Efficient Fine-Tuning Workflow & Architecture

Step 4: Run Fine-Tuning

Deploy the function. Axolotl will:
  1. Download the base model (cached on the platform)
  2. Load it in 4-bit quantization (~5GB VRAM)
  3. Initialize LoRA adapters (~100MB)
  4. Process and tokenize the dataset
  5. Train for 3 epochs
For a dataset of 1,000 examples with an effective batch size of 8, training takes about 20-30 minutes on a GPU slice. The output is a set of LoRA adapter weights (~50MB), not a full model checkpoint.

Step 5: Deploy Your Fine-Tuned Model

Your LoRA weights are saved to the platform's storage. To deploy the fine-tuned model:
yaml
1containerImage: vllm/vllm-openai:v0.22.1
2inferencePort: 8000
3gpu:
4  mode: shim
5  framework: vllm
6  multiplexing: 1
7args:
8  - "--model"
9  - "meta-llama/Llama-3.1-8B"
10  - "--lora-modules"
11  - "my-finetune=/workspace/output"
12  - "--max-lora-rank"
13  - "16"
vLLM can serve LoRA adapters natively — it loads the base model once and applies different adapters per request. This means you can serve multiple fine-tuned variants of the same base model on a single GPU slice.

Step 6: Test Your Model

shell
1curl -X POST https://invoke.istidlal.ai/v1/my-finetuned-llama/v1/chat/completions \
2  -H "Authorization: Bearer $ISTIDLAL_API_KEY" \
3  -H "Content-Type: application/json" \
4  -d '{
5    "model": "my-finetune",
6    "messages": [{"role": "user", "content": "Convert to passive: The dog chased the ball."}],
7    "max_tokens": 50
8  }'
The response should reflect your fine-tuned behavior. Our Alpaca-trained model now understands instruction-following tasks that the base Llama model would struggle with.

Cost Breakdown

StepGPU HoursSlice Cost
Fine-tuning (1K examples, 3 epochs)0.5~$0.25
Deploying the fine-tuned modelPay per second of inference~$0.50/hour active, $0 idle
Total cost to go from base model to deployed fine-tuned endpoint: under $1.
Figure 3: Cost & Time Breakdown: Dedicated H100 Cluster vs Istidlal 24GB GPU Slice

Figure 3: Cost & Time Breakdown: Dedicated H100 Cluster vs Istidlal 24GB GPU Slice

What's Next

  • Iterate: Adjust your dataset, LoRA rank, or learning rate and fine-tune again. LoRA weights are small — you can store dozens of variants.
  • Evaluate: Use a held-out test set to measure your fine-tune's performance on your specific task.
  • Scale: Add more replicas if you need higher throughput. The base model is loaded once; additional replicas share the same cached weights.
  • Combine: Serve multiple LoRA adapters on the same base model. vLLM's LoRA support makes this efficient — you pay for one GPU slice, serve five fine-tuned models.
Infrastructure Platform

Scale
Without
Limits.

Deploy serverless endpoints, agents, and containerized applications on Istidlal's hardware-isolated fractional GPUs.