Model Online / On-Site
Duration
Modules 5 modules

Course Objective & Scope

LoRA and QLoRA are the industry standard for fine-tuning 7B-to-70B open-weight models on a single enterprise GPU. Yet choosing arbitrary rank/alpha ratios, targeting only attention layers or naively merging a LoRA adapter into a 4-bit quantised base model can silently ruin downstream quality.

This hands-on course covers low-rank matrix decomposition ($\Delta W = B A$), 4-bit NormalFloat (nf4) quantisation, double quantisation, paged AdamW optimizers, Unsloth custom triton kernels and lossless merging back into 16-bit base weights. Participants fine-tune and benchmark an 8B–32B model using QLoRA on a real task.

Who Should Attend?

  • AI engineers fine-tuning large language models on single or constrained GPU setups
  • Data scientists who want principled control over LoRA and QLoRA hyperparameters
  • ML engineers preparing trained adapters for production inference engines
  • Prerequisite: Python, PyTorch basics and familiarity with Hugging Face

Key Takeaways

  • Select LoRA rank r, lora_alpha, lora_dropout and target modules for any task
  • Configure QLoRA with NF4 quantisation, double quantisation and BF16 compute dtypes
  • Prevent out-of-memory (OOM) spikes using paged optimizers and gradient checkpointing
  • Merge QLoRA adapters cleanly into 16-bit base weights without double-quantisation degradation
  • Benchmark 16-bit LoRA against 4-bit QLoRA across VRAM usage, training speed and task accuracy

Curriculum

LoRA Mechanics and Hyperparameter Selection
  • The intrinsic rank hypothesis, Gaussian/zero initialisation of $A$ and $B$, and $\alpha / r$ scaling
  • Why targeting all linear layers (Attention + MLP projections) beats q_proj, v_proj alone
  • How rank selection (r=8, 16, 32, 64, 128) affects capacity and overfitting
QLoRA: 4-Bit NormalFloat and Paged Optimizers
  • Information-theoretically optimal 4-bit NormalFloat (nf4) and block-wise quantisation
  • Double Quantization: quantising the quantisation constants to save additional VRAM
  • Preventing sequence-length OOM spikes with Paged AdamW (8-bit and 32-bit) optimizers
Speed and Memory Optimisation (bitsandbytes & Unsloth)
  • Setting bnb_4bit_compute_dtype=torch.bfloat16 and on-the-fly dequantisation during forward/backward passes
  • Cutting VRAM by 50%+ with Unsloth Triton kernels and smart gradient checkpointing
Adapter Merging and Quantisation Pitfalls
  • The common anti-pattern: why calling merge_and_unload() directly on a 4-bit model degrades quality
  • The right pipeline: merging into a clean FP16/BF16 base checkpoint before downstream AWQ/GGUF export
Workshop: Single-GPU QLoRA Training and Benchmarking
  • Running ablation experiments across rank sizes and target module sets
  • Comparing 16-bit LoRA and 4-bit QLoRA on task accuracy, throughput and peak VRAM

Other Courses in This Category

Get in touch