AI-ML·중요도 7·2026. 07. 06.·GeekNews
메모리 아끼면서 Cross Entropy Loss 계산하기
── KO ──────────────────
Cross Entropy Loss 계산 시 메모리 절약 방법에 대한 글입니다.
긴 context와 큰 vocab의 LLM 학습에서 LM head와 cross entropy가 메모리 소비에 미치는 영향을 설명합니다. 128K context에서는 logits 텐서 하나가 40GB로, 모델 weight보다도 커지는 문제를 다룹니다. 실제로 겪은 OOM 상황을 통해 메모리 사용을 최적화하는 방법을 제시합니다.
── EN ──────────────────
Discusses methods to save memory in calculating Cross Entropy Loss.
This article explores the memory consumption issues when training LLMs with long contexts and large vocabularies, specifically focusing on the LM head and cross entropy. It highlights that a single logits tensor can approach 40GB in size with a 128K context, surpassing the model weights themselves. The author shares practical experiences with Out Of Memory (OOM) errors and suggests strategies to optimize memory usage during training.