Skip to content
Effloow
← Back to Articles
AI INFRASTRUCTURE ARTICLES ·2026-12-01 ·BY EFFLOOW EDITORIAL ·10 MIN READ

Unsloth Multi-GPU DDP: QLoRA Setup, Costs, and Deployment Gates

A reproducible Unsloth QLoRA DDP setup, fair single-vs-multi-GPU benchmark design, and deployment gates for memory, warmup, and GPU-hour costs.
Unsloth QLoRA Distributed Training GPU Infrastructure
SHARE
Illustration for Unsloth Multi-GPU DDP: QLoRA Setup, Costs, and Deployment Gates
Illustration: AI-assisted. Editorial policy

Why We Brought This Tool Into Our Lab

We care about distributed fine-tuning for a straightforward reason: a domain-adaptation job that finishes after the deployment window is not operationally useful. Adding GPUs looks like the obvious fix. It can also turn one inexpensive training job into several synchronized GPUs waiting on the slowest worker.

Official two-T4 QLoRA comparison
DDP with block swap: time per step 16.4 seconds
Layer split: time per step 9.0 seconds
DDP with block swap: peak GPU memory 13.2 GB
Layer split: peak GPU memory 10.8 GB

In this specific offloaded MoE workload, layer splitting was faster and used less peak GPU memory than DDP with block swap; the result is not a general verdict against DDP.

Unsloth makes this decision interesting because QLoRA already reduces the memory needed for a frozen base model. If the complete training workload fits on one card, we can consider replicating it across two or four cards to process more data concurrently.

The distinction matters: DDP is a throughput strategy, not a way to combine GPU memory into one larger pool. Each rank holds a model replica and processes its own samples. Gradient synchronization coordinates the trainable parameters; with QLoRA, that primarily means adapters rather than updates to the frozen quantized base.

Our evidence boundary is important. We reviewed the official execution paths and constructed the reproduction and acceptance plan below, but we did not execute a GPU benchmark for this review. We therefore do not present consumer-GPU throughput, compile latency, or rank-level memory measurements as our own results. The numerical hardware baselines below retain their original configurations and provenance.

For our architecture review, we used three official references: the DDP walkthrough, the multi-GPU overview, and the Inkling 2 Mini fine-tuning guide. Together, they establish a viable launch path, but not a production guarantee for an arbitrary workstation.

Our initial verdict is conditional: Unsloth DDP is worth qualifying when the model already fits on every participating GPU and training duration matters more than minimizing GPU-hours. We would not buy additional cards on the assumption that “approximately linear” scaling transfers unchanged from H100s to a PCIe workstation.

Hands-On Walkthrough: Setup, Execution & Output

We start with a single Linux node and two visible NVIDIA GPUs. Four GPUs use the same launch pattern with a different process count. We keep model downloads and dataset access separate from training timing.

We start our installation plan with a source checkout. That is convenient for experimentation, but we do not treat a moving checkout as a reproducible production dependency. Our setup records the resolved commit and environment immediately:

set -euo pipefail

python3.12 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip

git clone https://github.com/unslothai/unsloth.git
cd unsloth
python -m pip install .

mkdir -p artifacts
git rev-parse HEAD > artifacts/unsloth-commit.txt
python -m pip freeze > artifacts/requirements-resolved.txt
nvidia-smi > artifacts/nvidia-smi.txt
nvidia-smi topo -m > artifacts/gpu-topology.txt

python unsloth-cli.py --help > artifacts/cli-help.txt

python - <<'PY'
import json
import torch

world_size = 2
batch_per_gpu = 1
accumulation = 4

print(json.dumps({
    "cuda_available": torch.cuda.is_available(),
    "visible_gpus": torch.cuda.device_count(),
    "planned_world_size": world_size,
    "per_device_train_batch_size": batch_per_gpu,
    "gradient_accumulation_steps": accumulation,
    "effective_batch_examples": (
        world_size * batch_per_gpu * accumulation
    ),
}, indent=2))

assert torch.cuda.is_available(), "CUDA is required for this workload"
assert torch.cuda.device_count() >= world_size, "Not enough visible GPUs"
PY

Illustrative output for a correctly configured two-GPU host—not a captured lab result:

{
  "cuda_available": true,
  "visible_gpus": 2,
  "planned_world_size": 2,
  "per_device_train_batch_size": 1,
  "gradient_accumulation_steps": 4,
  "effective_batch_examples": 8
}

Recording a commit does not ensure the next machine uses it. Before scheduling repeated jobs, we would rebuild from that exact revision and retain the resolved package environment or immutable container image.

For a small-model QLoRA qualification, we use the Llama-3.2-1B-Instruct model family used in the official DDP comparison, with four-bit loading explicitly enabled:

CUDA_VISIBLE_DEVICES=0,1 \
torchrun --standalone --nnodes=1 --nproc_per_node=2 \
  unsloth-cli.py \
  --model_name=unsloth/Llama-3.2-1B-Instruct \
  --dataset=yahma/alpaca-cleaned \
  --load_in_4bit \
  --r=16 \
  --lora_alpha=16 \
  --learning_rate=2e-5 \
  --max_seq_length=2048 \
  --per_device_train_batch_size=1 \
  --gradient_accumulation_steps=4 \
  --max_steps=200 \
  --save_model

This combines the documented CLI launch mechanism with an explicit QLoRA configuration; it is not a claim that this exact invocation has been benchmarked here. We check the installed CLI help before execution because supported arguments depend on the pinned revision.

Model access remains a separate prerequisite. If the selected repository requires authorization, we provision Hugging Face access before launching workers. No other external API credential is needed for this path.

The corresponding Python loading pattern is:

import os
import torch
from unsloth import FastLanguageModel

local_rank = int(os.environ.get("LOCAL_RANK", "0"))
torch.cuda.set_device(local_rank)

model, tokenizer = FastLanguageModel.from_pretrained(
    model_name="unsloth/Llama-3.2-1B-Instruct",
    max_seq_length=2048,
    load_in_4bit=True,
    device_map={"": local_rank},
)

This is the placement portion of a custom training script, not a complete trainer. We would then attach adapters and use a distributed-aware trainer. For a custom script, we use torchrun --nproc_per_node N_GPUS train.py in our launch plan. We can alternatively use accelerate launch train.py with an appropriate Accelerate configuration.

We prefer explicit torchrun parameters for the first qualification because process count is visible in the job command.

Our first acceptance check is not loss. It is placement: two workers, two intended devices, one primary replica per rank. Only then do we accept optimizer progress, adapter output, and a separate reload-and-generation smoke test.

Verification Limits and Deployment Constraints

The immediate roadblock in this review was verification: we did not have a suitable GPU environment to confirm warmup behavior, OOM thresholds, or workstation scaling. We will not turn those gaps into invented failure traces. Instead, we separate confirmed execution constraints from the failure modes our deployment gate must test.

The launch command is part of the training configuration. Running python train.py does not become DDP merely because several GPUs are visible. We use one process per participating GPU through the launcher. For custom scripts, we inspect local-rank placement before model loading and avoid initializing every replica on device zero.

Balanced loading and DDP solve different problems. We distinguish model splitting with device_map="balanced" from DDP replication in our placement plan. We do not combine cross-device model placement indiscriminately with one-rank-per-GPU replication. If a replica cannot fit on one card, plain DDP is not our capacity fix. We evaluate sharding, model splitting, offload, or a larger-memory device instead.

Per-device batch size is genuinely per device. Our planning equation is:

effective batch = world size × per-device batch × accumulation steps

At batch one and accumulation four, one GPU processes four examples per optimizer update; two GPUs process eight; four GPUs process sixteen. That changes the optimization experiment, not just its speed.

For a matched effective batch of eight, our matrix is:

GPUs Per-device batch Accumulation Effective batch
1 1 8 8
2 1 4 8
4 1 2 8

We keep batch one as a conservative starting point, not a universal optimum. Increasing accumulation does not shrink the memory required for one microbatch. It helps when the alternative is increasing the per-device microbatch.

Compile warmup remains unconfirmed for this configuration. We have not verified which paths invoke compilation, how long compilation takes, or whether caches are reused across ranks. We therefore cannot assign a warmup duration or prescribe a verified cache workaround.

Our measurement workaround is procedural: record process start, model-ready time, first optimizer update, and subsequent step timings separately. If the installed stack invokes torch.compile, capture compilation and recompilation diagnostics. Report cold and warm runs independently rather than quietly dropping inconvenient startup time.

Memory balance needs measurement, not assumptions. When we inspected the two-H100 reference snapshot, we found nearly symmetric total device usage: 18,903 and 18,905 MiB. We also identified small allocations from each process on the other GPU. We would not diagnose a placement bug from an extra CUDA context alone.

For our acceptance run, we would collect both device-wide memory and per-rank PyTorch allocated/reserved peaks. Those measure different things. Sequence lengths, evaluation, saving, and unrelated workloads can all affect the observed peak; none is a confirmed imbalance incident in this review.

Finally, when checking multi-GPU readiness, we encountered “official support soon” language alongside a concrete DDP launch path. We treat that mismatch as a release-qualification warning: lock the working stack, test checkpoint behavior, and do not assume every model-specific multi-GPU feature applies to every architecture.

Scale, Latency & Cost vs. Alternatives

Our benchmark design uses two comparison methods.

First, we hold the effective batch constant using the matrix above. We fix model revision, dataset revision, tokenization, sequence cap, packing policy, adapter targets, optimizer, and learning-rate schedule. Each configuration processes the same token budget. This asks whether additional GPUs finish comparable training work sooner.

Second, we hold per-device batch and accumulation constant. This measures throughput scaling while allowing global batch to grow. We label it separately because equal optimizer-step counts then represent different amounts of training data.

For either comparison, our report includes:

  • End-to-end duration, including startup and final adapter saving.
  • Steady-state useful, non-padding tokens per second across all ranks.
  • Optimizer updates separately from microsteps.
  • Per-device memory peaks and the busiest device.
  • Validation quality at comparable token budgets.
  • GPU-hours and cost per completed, accepted checkpoint.

We repeat runs and retain variability. A fast training loop that produces an unusable checkpoint is not a cost saving. Our Inspect AI deployment-gate review provides the complementary evaluation discipline; our Distilabel review covers the data-quality work that should precede buying more training throughput.

Official Numerical Baselines and Their Limits

For our Qwen3-8B reference baseline, we recorded a two-H100 80GB configuration with sequence length 2,048, per-device batch one, and accumulation four. When inspecting its memory snapshot and training summary, we identified approximately 19 GB per GPU and approximately 1.1 iterations per second. These are reference-run figures, not measurements from a local GPU run.

We do not label that command a QLoRA memory benchmark: its displayed invocation does not include --load_in_4bit. Nor do we translate iterations per second into useful tokens per second without actual token counts.

The separate Llama-3.2-1B-Instruct comparisons cover LoRA and four-bit QLoRA over 500 steps. They establish the expected distinction between step count and data progress, but do not supply enough numerical timing detail to calculate consumer-GPU speedup.

Our counterexample is the official Inkling 2 Mini two-T4 comparison. Under its short FP16 QLoRA workload—rank eight and two times 512 tokens per step—DDP with block swap takes 16.4 seconds per step and peaks at 13.2 GB on the busiest GPU. The layer-split baseline takes 9.0 seconds and peaks at 10.8 GB. That is a specific offloaded MoE configuration, not a general verdict against DDP.

It does, however, prevent us from equating “more replicas” with “faster.”

Option What we would use it for Main trade-off Evidence boundary
Single-GPU Unsloth QLoRA Simple, repeatable adaptation No inter-GPU throughput scaling Our required baseline; no measured result here
Unsloth DDP Replicas that fit independently Synchronization and multiplied GPU billing Official DDP examples, not a consumer-node guarantee
One larger GPU More memory without distributed launch Different hourly price and availability Requires a measured hardware comparison
Model splitting or offload Capacity-limited workloads Transfer overhead and architecture-specific behavior Inkling two-T4 example only
Managed fine-tuning Reduced infrastructure ownership Service limits, billing model, portability No comparable vendor quote or benchmark supplied

Our break-even calculation

Let a one-GPU job take (T_1) hours and a two-GPU job take (T_2). With equal per-GPU hourly pricing, two GPUs reduce compute cost only when:

2 × T2 < T1

Equivalently, speedup must exceed 2×. At exactly 2×, GPU-hours are unchanged.

For illustration—not a measured Unsloth result—suppose one GPU costs $1 per hour and finishes in ten hours. At 1.6× speedup, two GPUs finish in 6.25 hours:

  • Single GPU: 10 GPU-hours, $10.
  • Two GPUs: 12.5 GPU-hours, $12.50.
  • Time saved: 3.75 hours.

We would pay that premium if the earlier checkpoint unblocks a release. We would not describe it as a GPU-hour reduction.

For managed fine-tuning, our break-even adds engineering time, failed runs, storage, and checkpoint export to infrastructure charges. For short jobs, cold-start and compilation overhead can dominate the decision even when steady-state scaling looks attractive.

Our Final Verdict: When to Deploy, When to Skip

We would put Unsloth DDP through production qualification when:

  • A complete QLoRA training replica fits on each GPU with measured headroom.
  • Training duration materially delays evaluation or delivery.
  • The node has sufficient CPU, storage, and interconnect capacity.
  • We can pin the stack and preserve the exact training configuration.
  • A matched-work benchmark demonstrates a worthwhile wall-clock improvement.
  • Checkpoint reload, validation, and restart behavior pass independently.

We would hold off when:

  • The objective is pooling several small GPUs to fit one oversized replica.
  • The proposed speedup comes only from processing more examples per update.
  • Jobs are too short to amortize startup overhead.
  • GPU-hour reduction is promised without end-to-end measurements.
  • The workload depends on model-specific offload behavior that has not been qualified.
  • Nobody owns distributed-training failures after the initial successful run.

Our conclusion is deliberately narrower than a blanket recommendation: Unsloth exposes a practical DDP path, but deployment value comes from measured time-to-accepted-checkpoint, not GPU count.

We would begin with the official DDP CLI guide, keep the multi-GPU placement distinction explicit, and require our matched-batch comparison before increasing the training budget. Until that run exists on the target hardware, our setup is a reproducible qualification plan—not a completed consumer-GPU performance endorsement.

Get the next one
in your inbox.

One short weekly dispatch with new guides, tools, and what we tested. No spam, unsubscribe anytime.

Get weekly AI tool reviews & automation tips

Join our newsletter. No spam, unsubscribe anytime.

More in Articles

Tools you can use