Diagrams — Deep-Dive FTDD-03: Unsloth

Deep-Dive: FTDD-03 — Unsloth Diagram count: 4 Tool: Mermaid (primary). Each diagram validated in Mermaid Live Editor.


Diagram 1 — How Unsloth Achieves the Win (three engineering decisions)

Type: Three-pillar supporting a single outcome Purpose: The single most important diagram. Shows Unsloth's three engineering decisions (Triton kernels, manual autograd, 4-bit optimizers) and the outcome each produces — and makes the critical point that none is an algorithmic change. Reading the diagram: Three pillars (the decisions) support the outcome (~2x speed, ~60% less memory). The bottom annotation is the load-bearing claim: same algorithm, same result, faster and cheaper.

flowchart TB
  P1["HAND-WRITTEN TRITON KERNELS\nreplace generic PyTorch kernels\nfor forward/backward passes"]
  P2["MANUAL AUTOGRAD\ncompute gradients by hand for\ncustom kernels; bypass graph overhead"]
  P3["4-BIT OPTIMIZERS\noptimizer state at 4-bit\n(8x memory reduction)"]

  OUTCOME["~2x TRAINING SPEED\n~60% LESS VRAM\non a single NVIDIA GPU"]

  P1 --> OUTCOME
  P2 --> OUTCOME
  P3 --> OUTCOME

  NOTE["NOT an algorithmic change.\nSame LoRA/QLoRA, same result —\nfaster and cheaper."]

  OUTCOME --> NOTE

  style P1 fill:#14141f,stroke:rgba(94,234,212,0.6),color:#e4e4e8
  style P2 fill:#14141f,stroke:rgba(94,234,212,0.6),color:#e4e4e8
  style P3 fill:#14141f,stroke:rgba(94,234,212,0.6),color:#e4e4e8
  style OUTCOME fill:#14141f,stroke:#5eead4,stroke-width:1.5px,color:#5eead4
  style NOTE fill:#08080c,stroke:rgba(240,168,104,0.5),stroke-dasharray: 4 2,color:#f0a868

Diagram 2 — The Consumer-GPU Enabler (before vs after Unsloth)

Type: Two-track comparison Purpose: Visualize the democratization claim — what 7B fine-tuning required before Unsloth versus after. This is the diagram that justifies Unsloth's pedagogical role. Reading the diagram: Top track = before Unsloth (expensive GPU or compromises). Bottom track = after Unsloth (RTX 4090, comfortable). The annotation marks the economic and pedagogical threshold crossed.

flowchart TB
  subgraph BEFORE["BEFORE UNSLOTH — 7B QLoRA on consumer hardware"]
    direction LR
    B1["Required 24GB+ VRAM\n($2,000–$5,000 GPU tier)"]
    B2["OR aggressive compromises:\ntiny batch, short seq, CPU offload (slow)"]
    B1 --> B2
  end
  subgraph AFTER["AFTER UNSLOTH — 7B QLoRA on consumer hardware"]
    direction LR
    A1["$1,500 RTX 4090 (24GB)"]
    A2["Reasonable batch + seq length\n~2x speed, ~60% less memory"]
    A1 --> A2
  end

  THRESHOLD["THE THRESHOLD:\nfine-tuning moves from 'labs do it'\nto 'I do it, on my desk, today'"]

  AFTER --> THRESHOLD

  style BEFORE fill:#14141f,stroke:rgba(240,128,128,0.4),color:#9494a0
  style AFTER fill:#14141f,stroke:#5eead4,stroke-width:1.5px,color:#e4e4e8
  style THRESHOLD fill:#08080c,stroke:rgba(94,234,212,0.5),stroke-dasharray: 4 2,color:#5eead4
  style B1 fill:#08080c,stroke:rgba(240,128,128,0.3),color:#f08080
  style B2 fill:#08080c,stroke:rgba(240,128,128,0.3),color:#f08080
  style A1 fill:#08080c,stroke:rgba(94,234,212,0.3),color:#5eead4
  style A2 fill:#08080c,stroke:rgba(94,234,212,0.3),color:#5eead4

Diagram 3 — Dynamic 4.0 vs Uniform Quantization (per-layer intelligence)

Type: Side-by-side layer map Purpose: Show why Dynamic 4.0 GGUF quants beat uniform quants. Each row is a model layer; the two tracks show how precision is assigned. The point: dynamic allocates precision where it matters; uniform wastes it. Reading the diagram: Left = uniform (every layer the same precision). Right = dynamic (sensitive layers get more bits, robust layers get fewer, same average). The annotation marks the outcome.

flowchart LR
  subgraph UNIFORM["UNIFORM QUANTIZATION (same precision everywhere)"]
    U1["Layer 1 (attention): 4-bit"]
    U2["Layer 2 (MLP): 4-bit"]
    U3["Layer 3 (attention): 4-bit"]
    U4["Layer 4 (output proj): 4-bit"]
    U5["...all layers: 4-bit"]
  end
  subgraph DYNAMIC["DYNAMIC 4.0 (per-layer by sensitivity)"]
    D1["Layer 1 (attention): 6-bit ← sensitive"]
    D2["Layer 2 (MLP): 3-bit ← robust"]
    D3["Layer 3 (attention): 6-bit ← sensitive"]
    D4["Layer 4 (output proj): 6-bit ← sensitive"]
    D5["...per-layer analysis"]
  end

  OUTCOME["SAME average bit-size,\nBETTER quality.\nDynamic beats uniform at the same footprint."]

  DYNAMIC --> OUTCOME

  style UNIFORM fill:#14141f,stroke:rgba(255,255,255,0.12),color:#9494a0
  style DYNAMIC fill:#14141f,stroke:#5eead4,stroke-width:1.5px,color:#e4e4e8
  style OUTCOME fill:#14141f,stroke:#5eead4,stroke-width:1.5px,color:#5eead4
  style U1 fill:#08080c,stroke:rgba(255,255,255,0.08),color:#9494a0
  style U2 fill:#08080c,stroke:rgba(255,255,255,0.08),color:#9494a0
  style U3 fill:#08080c,stroke:rgba(255,255,255,0.08),color:#9494a0
  style U4 fill:#08080c,stroke:rgba(255,255,255,0.08),color:#9494a0
  style U5 fill:#08080c,stroke:rgba(255,255,255,0.08),color:#9494a0
  style D1 fill:#08080c,stroke:rgba(94,234,212,0.4),color:#5eead4
  style D2 fill:#08080c,stroke:rgba(148,148,160,0.3),color:#9494a0
  style D3 fill:#08080c,stroke:rgba(94,234,212,0.4),color:#5eead4
  style D4 fill:#08080c,stroke:rgba(94,234,212,0.4),color:#5eead4
  style D5 fill:#08080c,stroke:rgba(94,234,212,0.3),color:#e4e4e8

Diagram 4 — Unsloth vs Axolotl vs TRL (the framework decision)

Type: Three-branch decision tree Purpose: The decision diagram for choosing a fine-tuning framework. The deciding factors are hardware (single vs multi-GPU) and control level. Reading the diagram: Three branches from a single decision node. Each branch names the framework, the use case, and the tradeoff. The summary line captures the relationship (TRL is the substrate).

flowchart TB
  DECISION{"Your constraint?\n(hardware + control)"}

  UNSLOTH["UNSLOTH\nSingle GPU · speed/memory constrained · GGUF export\nTradeoff: opinionated, makes decisions for you"]
  AXOLOTL["AXOLOTL\nMulti-GPU · production configs · YAML-driven\nTradeoff: config overhead, broader surface"]
  TRL["TRL\nFull control · custom training loops · research\nTradeoff: you write more code (it IS the library)"}

  DECISION -->|"One GPU, go fast, export GGUF"| UNSLOTH
  DECISION -->|"Multiple GPUs, production configs"| AXOLOTL
  DECISION -->|"Custom loop, maximum control"| TRL

  SUBSTRATE["TRL is the SUBSTRATE.\nAxolotl and often Unsloth build on it.\nPrototype in Unsloth → scale in Axolotl → custom in TRL."]

  TRL -.-> SUBSTRATE

  style DECISION fill:#08080c,stroke:rgba(240,168,104,0.5),stroke-dasharray: 4 2,color:#f0a868
  style UNSLOTH fill:#14141f,stroke:#5eead4,stroke-width:1.5px,color:#5eead4
  style AXOLOTL fill:#14141f,stroke:rgba(94,234,212,0.5),color:#e4e4e8
  style TRL fill:#14141f,stroke:rgba(94,234,212,0.5),color:#e4e4e8
  style SUBSTRATE fill:#08080c,stroke:rgba(255,255,255,0.12),color:#9494a0

Validation notes

# Diagrams — Deep-Dive FTDD-03: Unsloth

**Deep-Dive**: FTDD-03 — Unsloth
**Diagram count**: 4
**Tool**: Mermaid (primary). Each diagram validated in [Mermaid Live Editor](https://mermaid.live).

---

## Diagram 1 — How Unsloth Achieves the Win (three engineering decisions)

**Type**: Three-pillar supporting a single outcome
**Purpose**: The single most important diagram. Shows Unsloth's three engineering decisions (Triton kernels, manual autograd, 4-bit optimizers) and the outcome each produces — and makes the critical point that none is an algorithmic change.
**Reading the diagram**: Three pillars (the decisions) support the outcome (~2x speed, ~60% less memory). The bottom annotation is the load-bearing claim: same algorithm, same result, faster and cheaper.

```mermaid
flowchart TB
  P1["HAND-WRITTEN TRITON KERNELS\nreplace generic PyTorch kernels\nfor forward/backward passes"]
  P2["MANUAL AUTOGRAD\ncompute gradients by hand for\ncustom kernels; bypass graph overhead"]
  P3["4-BIT OPTIMIZERS\noptimizer state at 4-bit\n(8x memory reduction)"]

  OUTCOME["~2x TRAINING SPEED\n~60% LESS VRAM\non a single NVIDIA GPU"]

  P1 --> OUTCOME
  P2 --> OUTCOME
  P3 --> OUTCOME

  NOTE["NOT an algorithmic change.\nSame LoRA/QLoRA, same result —\nfaster and cheaper."]

  OUTCOME --> NOTE

  style P1 fill:#14141f,stroke:rgba(94,234,212,0.6),color:#e4e4e8
  style P2 fill:#14141f,stroke:rgba(94,234,212,0.6),color:#e4e4e8
  style P3 fill:#14141f,stroke:rgba(94,234,212,0.6),color:#e4e4e8
  style OUTCOME fill:#14141f,stroke:#5eead4,stroke-width:1.5px,color:#5eead4
  style NOTE fill:#08080c,stroke:rgba(240,168,104,0.5),stroke-dasharray: 4 2,color:#f0a868
```

---

## Diagram 2 — The Consumer-GPU Enabler (before vs after Unsloth)

**Type**: Two-track comparison
**Purpose**: Visualize the democratization claim — what 7B fine-tuning required before Unsloth versus after. This is the diagram that justifies Unsloth's pedagogical role.
**Reading the diagram**: Top track = before Unsloth (expensive GPU or compromises). Bottom track = after Unsloth (RTX 4090, comfortable). The annotation marks the economic and pedagogical threshold crossed.

```mermaid
flowchart TB
  subgraph BEFORE["BEFORE UNSLOTH — 7B QLoRA on consumer hardware"]
    direction LR
    B1["Required 24GB+ VRAM\n($2,000–$5,000 GPU tier)"]
    B2["OR aggressive compromises:\ntiny batch, short seq, CPU offload (slow)"]
    B1 --> B2
  end
  subgraph AFTER["AFTER UNSLOTH — 7B QLoRA on consumer hardware"]
    direction LR
    A1["$1,500 RTX 4090 (24GB)"]
    A2["Reasonable batch + seq length\n~2x speed, ~60% less memory"]
    A1 --> A2
  end

  THRESHOLD["THE THRESHOLD:\nfine-tuning moves from 'labs do it'\nto 'I do it, on my desk, today'"]

  AFTER --> THRESHOLD

  style BEFORE fill:#14141f,stroke:rgba(240,128,128,0.4),color:#9494a0
  style AFTER fill:#14141f,stroke:#5eead4,stroke-width:1.5px,color:#e4e4e8
  style THRESHOLD fill:#08080c,stroke:rgba(94,234,212,0.5),stroke-dasharray: 4 2,color:#5eead4
  style B1 fill:#08080c,stroke:rgba(240,128,128,0.3),color:#f08080
  style B2 fill:#08080c,stroke:rgba(240,128,128,0.3),color:#f08080
  style A1 fill:#08080c,stroke:rgba(94,234,212,0.3),color:#5eead4
  style A2 fill:#08080c,stroke:rgba(94,234,212,0.3),color:#5eead4
```

---

## Diagram 3 — Dynamic 4.0 vs Uniform Quantization (per-layer intelligence)

**Type**: Side-by-side layer map
**Purpose**: Show why Dynamic 4.0 GGUF quants beat uniform quants. Each row is a model layer; the two tracks show how precision is assigned. The point: dynamic allocates precision where it matters; uniform wastes it.
**Reading the diagram**: Left = uniform (every layer the same precision). Right = dynamic (sensitive layers get more bits, robust layers get fewer, same average). The annotation marks the outcome.

```mermaid
flowchart LR
  subgraph UNIFORM["UNIFORM QUANTIZATION (same precision everywhere)"]
    U1["Layer 1 (attention): 4-bit"]
    U2["Layer 2 (MLP): 4-bit"]
    U3["Layer 3 (attention): 4-bit"]
    U4["Layer 4 (output proj): 4-bit"]
    U5["...all layers: 4-bit"]
  end
  subgraph DYNAMIC["DYNAMIC 4.0 (per-layer by sensitivity)"]
    D1["Layer 1 (attention): 6-bit ← sensitive"]
    D2["Layer 2 (MLP): 3-bit ← robust"]
    D3["Layer 3 (attention): 6-bit ← sensitive"]
    D4["Layer 4 (output proj): 6-bit ← sensitive"]
    D5["...per-layer analysis"]
  end

  OUTCOME["SAME average bit-size,\nBETTER quality.\nDynamic beats uniform at the same footprint."]

  DYNAMIC --> OUTCOME

  style UNIFORM fill:#14141f,stroke:rgba(255,255,255,0.12),color:#9494a0
  style DYNAMIC fill:#14141f,stroke:#5eead4,stroke-width:1.5px,color:#e4e4e8
  style OUTCOME fill:#14141f,stroke:#5eead4,stroke-width:1.5px,color:#5eead4
  style U1 fill:#08080c,stroke:rgba(255,255,255,0.08),color:#9494a0
  style U2 fill:#08080c,stroke:rgba(255,255,255,0.08),color:#9494a0
  style U3 fill:#08080c,stroke:rgba(255,255,255,0.08),color:#9494a0
  style U4 fill:#08080c,stroke:rgba(255,255,255,0.08),color:#9494a0
  style U5 fill:#08080c,stroke:rgba(255,255,255,0.08),color:#9494a0
  style D1 fill:#08080c,stroke:rgba(94,234,212,0.4),color:#5eead4
  style D2 fill:#08080c,stroke:rgba(148,148,160,0.3),color:#9494a0
  style D3 fill:#08080c,stroke:rgba(94,234,212,0.4),color:#5eead4
  style D4 fill:#08080c,stroke:rgba(94,234,212,0.4),color:#5eead4
  style D5 fill:#08080c,stroke:rgba(94,234,212,0.3),color:#e4e4e8
```

---

## Diagram 4 — Unsloth vs Axolotl vs TRL (the framework decision)

**Type**: Three-branch decision tree
**Purpose**: The decision diagram for choosing a fine-tuning framework. The deciding factors are hardware (single vs multi-GPU) and control level.
**Reading the diagram**: Three branches from a single decision node. Each branch names the framework, the use case, and the tradeoff. The summary line captures the relationship (TRL is the substrate).

```mermaid
flowchart TB
  DECISION{"Your constraint?\n(hardware + control)"}

  UNSLOTH["UNSLOTH\nSingle GPU · speed/memory constrained · GGUF export\nTradeoff: opinionated, makes decisions for you"]
  AXOLOTL["AXOLOTL\nMulti-GPU · production configs · YAML-driven\nTradeoff: config overhead, broader surface"]
  TRL["TRL\nFull control · custom training loops · research\nTradeoff: you write more code (it IS the library)"}

  DECISION -->|"One GPU, go fast, export GGUF"| UNSLOTH
  DECISION -->|"Multiple GPUs, production configs"| AXOLOTL
  DECISION -->|"Custom loop, maximum control"| TRL

  SUBSTRATE["TRL is the SUBSTRATE.\nAxolotl and often Unsloth build on it.\nPrototype in Unsloth → scale in Axolotl → custom in TRL."]

  TRL -.-> SUBSTRATE

  style DECISION fill:#08080c,stroke:rgba(240,168,104,0.5),stroke-dasharray: 4 2,color:#f0a868
  style UNSLOTH fill:#14141f,stroke:#5eead4,stroke-width:1.5px,color:#5eead4
  style AXOLOTL fill:#14141f,stroke:rgba(94,234,212,0.5),color:#e4e4e8
  style TRL fill:#14141f,stroke:rgba(94,234,212,0.5),color:#e4e4e8
  style SUBSTRATE fill:#08080c,stroke:rgba(255,255,255,0.12),color:#9494a0
```

---

## Validation notes

- All four diagrams use the course design system colors: `#14141f` panel fill, `#5eead4` accent for primary, `rgba(255,255,255,0.12)` for secondary borders, `#e4e4e8` / `#9494a0` for text. The warn tones (`#f0a868` for the decision/annotation nodes, `#f08080` for the "before Unsloth" compromises) mark decision points and the contrast track.
- Paste each into [Mermaid Live Editor](https://mermaid.live) to render. All use stable Mermaid syntax (`flowchart TB/LR`, `subgraph`) supported in current Mermaid (v10.4+).
- For the slide deck (artifact 03), these are rendered as static SVG/PNG captures from Mermaid Live, inlined into reveal.js.