EasyDeepLearn

Why is the softmax + cross-entropy at the LM head a training bottleneck?

hard

Answer

  • For a vocab V=128k and hidden d=4k, the logit matrix (batch × seq × V) can dominate activations — often the single biggest tensor in the graph.
  • Materializing it in fp32 wastes memory and compute.
  • Modern trick: 'fused CE' — compute logits and cross-entropy in a single fused CUDA kernel that never materializes the full V-dim tensor.
  • Liger Kernel and CUTCROSSENTROPY\mathrm{CUT}_{\mathrm{CROSS}}\mathrm{ENTROPY} (2024) do this — 2-5x memory reduction on the LM head, faster training.
Check yourself — multiple choice
  • LM head is negligible
  • Huge V·d logit tensor dominates activations → fused CE kernels (Liger,  CUTCROSSENTROPY)(\mathrm{Liger}, \;\mathrm{CUT}_{\mathrm{CROSS}}\mathrm{ENTROPY}) save 2-5× memory
  • Only in inference
  • Only for MoE

LM head cross-entropy is a memory hog → fused CE kernels cut activation memory 2-5×.

#architecture#pretraining

Practise LLMs & GenAI

214 interview questions in this topic.

Related questions