← All questions
Retrieval & EmbeddingsHard· Gradient Checkpointing· Memory Optimization· Contrastive Learning

Your teammate says the queue is a hack - use gradient c...

While gradient checkpointing allows for larger batches and exact gradients, it is computationally expensive. It requires recomputing forward passes, which does not scale well compared to the queue-based approach. Furthermore, exact gradients on negatives with very high margins provide negligible benefit. Grad-Cache is a better alternative for exact gradients, but the queue remains the most efficient method for amortizing the encoding cost of key vectors.

Code playground (Python)