‹ BackHN Continuity

Thread

Show HN: Fine-tune an 8B model on a 4 GB laptop GPU

135 points · 28 comments · MakazhanAlpamys

  1. MakazhanAlpamys · · focus · HN ↗
    Author here.

    The constraint everyone works around is that the frozen base has to fit in VRAM. But during LoRA the base is frozen — read, never written. It doesn't need to live in VRAM, it needs to arrive before the matmul that uses it. So it sits in host RAM and streams into a small pool of pre-allocated VRAM buffers, one decoder layer at a time, prefetched one ahead on a dedicated CUDA stream. Peak VRAM becomes one layer instead of the whole model.

    Measured on an RTX 3050 Laptop (4 GB, Windows): Llama-3.1-8B in NF4 at 119.6 tok/s, 3.32 GB peak, 100% SM occupancy. Also Qwen2.5-3B with an un-quantized bf16 base at 143 tok/s in 2.15 GB, which is CUDA OOM when trained resident on the same card. Overhead is 1.43x vs resident, measured at 0.5B — the only size on this card with a valid resident baseline, and I publish that baseline so you can check the division.

    Most of the work wasn't speed, it was correctness. Streaming fails silently: cut the autograd path and the loss still falls because the upper layers keep learning. So the bar was bit-exactness against a resident reference of the same numerics — max abs logit difference 0.0, across nine architecture families in two precisions, as a CI test rather than a one-off. That protocol caught a PEFT dispatch defect producing 0.94 logit divergence with byte-identical weights and adapters, no crash, no warning.

    Not claiming anything above 8B — 14B NF4 needs ~7.5 GB page-locked against a measured 7.12 GB ceiling here, so I didn't run it. All numbers are Windows, so pessimistic vs Linux.

    Measurement records, including the ones I threw away: <a href="https:&#x2F;&#x2F;github.com&#x2F;MakazhanAlpamys&#x2F;Soup&#x2F;tree&#x2F;main&#x2F;benchmarks" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;MakazhanAlpamys&#x2F;Soup&#x2F;tree&#x2F;main&#x2F;benchmarks

    Write-up: <a href="https:&#x2F;&#x2F;doi.org&#x2F;10.5281&#x2F;zenodo.21771064" rel="nofollow">https:&#x2F;&#x2F;doi.org&#x2F;10.5281&#x2F;zenodo.21771064

    Happy to answer anything about the scheduler or the correctness protocol.

    1. selimthegrim · · focus · HN ↗
      Can you write one answer that isn&#x27;t AI-sourced?
      1. skeledrew · · focus · HN ↗
        Can you just get over it and read what&#x27;s already there? Anyway, your loss.
        1. selimthegrim · · focus · HN ↗
          If their native language isn’t English then I’ll come off my pedestal
          1. MakazhanAlpamys · · focus · HN ↗
            It isn&#x27;t. Kazakh and Russian. I said this further down but that comment is dead so you would not have seen it. The later replies are mine, written by me.
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.