flâneur — a map of the web's best reading

Cut Cross Entropy from first principles - Omkaar Kamath

omkaark.com · 897 words · saved by 1 readers

If you’ve ever tried training a 70B model and watched your GPU memory bar hit 99%, you’ve already met the enemy: Cross Entropy Loss. It’s silently eating half your VRAM, and Apple’s new Cut Cross Entropy (CCE) paper could help out. Cross Entropy Loss is commonly calculated by materializing all the logits, which, given the large vocab size and number of batch tokens, leads to exploding VRAM usage. The green pie segment shown in the image below is proportion of memory used by the Cross Entropy loss calculation... notice how with CCE green pie segments seemingly vanish. Following is an image from Apple's paper showing ratio of memory consumed by different parts of a training run with and without CCE. The CE Loss formula = -log(prob(Correct Token)) Probability of a token comes from softmax over the vocab dimension of the logits tensor. Putting all this together and a few math tricks, we get loss = -correct_token + LSE The most naive form of Cross Entropy loss calculation would be: That wou

Cut Cross Entropy from first principles - Omkaar Kamath Cut Cross Entropy from first principles If you’ve ever tried training a 70B model and watched your GPU memory bar hit 99%, you’ve already met the enemy: Cross Entropy Loss. It’s silently eating half your VRAM, and Apple’s new Cut Cross Entropy (CCE) paper could help out. Cross Entropy Loss is commonly calculated by materializing all the logits, which, given the large vocab size and number of batch tokens, leads to exploding VRAM usage. The green pie segment shown in the image below is proportion of memory used by the Cross Entropy loss ca

Explore this link on the map →

saved by

related reading