Reproduce “Scaling Deep Contrastive Learning Batch Size under Memory Limited Setup” on OpenResearch

Run Claude Code, Codex or any coding agent as a research agent: literature, hypotheses and experiments on your laptop, cluster or cloud GPUs.

Universal app for Apple silicon and Intel. Requires macOS 11 or later.

About this paper

Luyu Gao, Yunyi Zhang, Jiawei Han, Jamie Callan

Gradient Cache enables large-batch retrieval training by separating representation-gradient calculation from encoder backpropagation. It computes loss over full-batch representations, then recomputes encoder outputs in smaller chunks, bounding activation memory while cached storage grows with batch size. On Natural Questions, top-five hit accuracy, the share of questions with an answer-containing passage in the top five, was 68.6% versus 64.3% for accumulation at 128 questions per update, in one experiment.

Key insights

  • The partial derivatives of an encoder's output with respect to its parameters depend only on its specific input and internal state, making backpropagation through the encoder for individual examples independent of others.
  • The gradients of the contrastive loss with respect to the output representations depend solely on the numerical values of all representations in the batch, allowing these gradients to be computed separately.
  • Decoupling the two-stage gradient computation allows memory-intensive encoder activation storage to be managed in smaller sub-batches, while the relatively smaller representation gradients are cached for the full batch.

Summary by alphaXiv.

Tip: change arxiv.org to autoarxiv.org in any arXiv abstract link to open the paper here.