# Oszczędzanie pamięci podczas treningu

EN: **Memory-efficient training** · id `memefficienttraining` · aliases: memory-efficient training, training memory optimization, oszczędny trening, optymalizacja pamięci treningu

Path: [AI Atlas](https://aiatlasgraph.com/llms.txt) › [Trenowanie i dostrajanie](https://aiatlasgraph.com/t/training.md) › [Proces uczenia](https://aiatlasgraph.com/t/optimization.md) › Oszczędzanie pamięci podczas treningu

## Description

- PL: Techniki zmniejszające pamięć zajętą przez aktywacje, gradienty i stany optymalizatora, by trenować większe modele na tym samym sprzęcie.
- EN: Techniques that shrink memory used by activations, gradients and optimiser states, so larger models train on the same hardware.

## In one sentence

- PL: Zestaw sposobów, dzięki którym większy model mieści się w pamięci karty graficznej podczas nauki.
- EN: A set of methods that let a bigger model fit into graphics-card memory while it is being trained.

## Problem it solves

- PL: Trening zużywa wielokrotnie więcej pamięci niż samo uruchamianie modelu i szybko kończy się błędem braku miejsca.
- EN: Training uses many times more memory than running a model, and quickly stops with an out-of-memory error.

## What it does

- PL: Jak przeprowadzka do małego mieszkania: część rzeczy składasz ciaśniej, część wynosisz do piwnicy, a część kupujesz dopiero, gdy trzeba.
- EN: Like moving into a small flat: some things you fold tighter, some go to the basement, some you only buy when needed.

## Everyday example

- PL: Student dostraja średniej wielkości model na jednej karcie graficznej w domowym komputerze zamiast wynajmować serwer.
- EN: A student fine-tunes a mid-sized model on a single graphics card in a home PC instead of renting a server.

## This concerns you if you…

- PL: dostajesz błąd braku pamięci na karcie graficznej
- PL: chcesz trenować na jednym komputerze zamiast w chmurze
- EN: hit out-of-memory errors on your GPU
- EN: want to train on one computer instead of the cloud

## Keywords

gradient checkpointing · activation recomputation · 8-bit Adam · GaLore · CPU offloading · ZeRO · DeepSpeed · bitsandbytes · micro-batching · mixed precision

## How it works

- PL: Pamięć treningu to wagi, gradienty, stany optymalizatora (dla Adama dwa dodatkowe tensory na wagę) i aktywacje zapamiętane do propagacji wstecznej. Oszczędza się ją przez ponowne liczenie aktywacji, kwantyzację lub rzutowanie stanów optymalizatora, niższą precyzję, mniejsze mikrobatche i przenoszenie danych do pamięci CPU.
- EN: Training memory holds weights, gradients, optimiser states (two extra tensors per weight for Adam) and activations kept for backpropagation. It is reduced by recomputing activations, quantising or projecting optimiser states, lower precision, smaller micro-batches and offloading to CPU memory.

## Limits

- PL: Prawie każda oszczędność kosztuje czas obliczeń lub dokładność. Techniki wchodzą w interakcje z zrównoleglaniem i mieszaną precyzją, a zysk zależy od architektury i długości sekwencji.
- EN: Almost every saving costs compute time or accuracy. Techniques interact with parallelism and mixed precision, and the gain depends on architecture and sequence length.

## Key terms

- PL: **aktywacje**: Pośrednie wyniki warstw zapamiętywane, by policzyć gradienty.
- PL: **stan optymalizatora**: Dodatkowe liczby trzymane przez optymalizator dla każdej wagi, np. średnie gradientów.
- PL: **offloading**: Przenoszenie części danych z pamięci karty do zwykłej pamięci RAM.
- EN: **activations**: Intermediate layer outputs kept so gradients can be computed.
- EN: **optimiser state**: Extra numbers an optimiser stores per weight, e.g. gradient averages.
- EN: **offloading**: Moving some data from GPU memory to ordinary RAM.

## Know first

- [Propagacja wsteczna (backpropagation) (Backpropagation)](https://aiatlasgraph.com/t/backprop.md)

## Subtopics (3 direct, 3 in total)

- [8-bitowe stany optymalizatora (8-bit optimizer states)](https://aiatlasgraph.com/t/eightbitoptim.md): Storing optimiser statistics (e.g. Adam moments) in 8 bits with block-wise quantisation instead of 32 bits.
- [Niskorzędowe rzutowanie gradientu (Low-rank gradient projection)](https://aiatlasgraph.com/t/galore.md): Full-parameter training in which gradients and optimiser states are kept in a low-dimensional projection.
- [Ponowne liczenie aktywacji (gradient checkpointing) (Gradient (activation) checkpointing)](https://aiatlasgraph.com/t/gradcheckpointing.md): Only selected activations are stored; the missing ones are recomputed during backpropagation.

## Related topics

Untyped, symmetric "see also" links.

- [Trening w mieszanej precyzji (FP16, BF16, FP8) (Mixed-precision training)](https://aiatlasgraph.com/t/mixedprecision.md)

## Sources

- [Training Deep Nets with Sublinear Memory Cost](<https://arxiv.org/abs/1604.06174>) `chen-2016-sublinear` · by Tianqi Chen, Bing Xu, Chiyuan Zhang, Carlos Guestrin
- [GaLore: Memory-Efficient LLM Training by Gradient Low-Rank Projection](<https://arxiv.org/abs/2403.03507>) `zhao-2024-galore` · by Jiawei Zhao, Zhenyu Zhang, Beidi Chen, Zhangyang Wang, Anima Anandkumar, Yuandong Tian
- [8-bit Optimizers via Block-wise Quantization](<https://arxiv.org/abs/2110.02861>) `dettmers-2021-8bitopt` · by Tim Dettmers, Mike Lewis, Sam Shleifer, Luke Zettlemoyer

---

AI Atlas revision 122 (2026-10-30) · HTML: https://aiatlasgraph.com/t/memefficienttraining · index: https://aiatlasgraph.com/llms.txt · everything: https://aiatlasgraph.com/llms-full.txt · updated 2026-10-30
