Minibatch selection for Language Models via Partition Matroid Constrained Gradient Matching

Prayas Agrawal, Prateek Chanda, Ishita Khatri, Ganesh Ramakrishnan, Bamdev Mishra, Pratik Jawanpuria

Introduction

Training large language models (LLMs) on heterogeneous data requires selecting minibatches that balance convergence speed with broad coverage across domains. PartitionSel is a novel, efficient method for selecting optimal training minibatches across multiple data domains. By framing minibatch selection as a combinatorial optimization problem under "partition matroid" constraints, PartitionSel selects samples that maximize a validation-guided utility while minimizing redundant or conflicting gradients—all without the computational overhead of training auxiliary proxy models.

The Challenge of Heterogeneous Data

LLM training is a delicate balancing act. While large minibatches accelerate convergence, GPU memory remains a finite and expensive bottleneck. To mitigate this, researchers employ minibatch selection: identifying a high-quality subset of data for each training step.

Modern training corpora are rarely uniform; they resemble a "mixture of experts" scenario spanning diverse domains like mathematics, coding, and literature. Existing selection methods typically struggle with this heterogeneity, falling into two primary categories:

  1. Independent Selection: Samples are chosen from each domain in isolation. This approach ignores cross-domain redundancies (e.g., a "Math" sample and a "Physics" sample providing identical learning signals).
  2. Continuous Weighting: Methods like DoReMi train a smaller "proxy" model alongside the primary LLM to learn optimal domain weights. This introduces significant computational expense and is difficult to synchronize with the main model's trajectory.

PartitionSel addresses these shortcomings by enabling joint, domain-aware selection across the entire batch using a highly efficient discrete approach.

The PartitionSel Methodology

PartitionSel formulates minibatch selection as a constrained optimization problem, built on three core pillars:

1. Gradient Matching Utility

The algorithm evaluates a candidate pool against a small validation set, seeking training samples whose gradients align with the validation gradient. The utility function balances two objectives:

  • Alignment: Maximizing the sample's contribution to reducing validation loss.
  • Diversity: Penalizing samples that are overly similar to those already selected or that introduce "conflicting gradients" (gradients pointing in opposite directions that cancel each other out).

2. Partition Matroid Constraints

To guarantee that the model does not neglect any specific domain, PartitionSel applies a partition matroid constraint. Conceptually, this enforces a strict "budget" for each domain within the minibatch (e.g., mandating that 20% of the batch is math, 30% is code, etc.).

3. Weak Submodularity and OMP

The authors demonstrate that their selection objective is weakly submodular. This theoretical property guarantees that a greedy algorithm—iteratively selecting the next best sample—will closely approximate the mathematically optimal solution. PartitionSel utilizes an Orthogonal Matching Pursuit (OMP) algorithm to execute this selection rapidly at every training step. To circumvent the massive memory costs of calculating gradients for every candidate, the method employs "ghost inner-products" and low-pass filters on LoRA parameters, rendering the selection overhead negligible.

Experimental Setup

The researchers evaluated PartitionSel by fine-tuning Qwen2.5 and Llama-3 models. The primary benchmarks included:

  • MetaMathQA: A dataset of 260,000 math instruction-tuning samples sourced from 14 highly imbalanced domains.
  • Mol-Instructions: A biomolecular dataset covering tasks such as molecule design (SMILES strings), reaction prediction, and retrosynthesis.

Downstream evaluation spanned rigorous reasoning tasks, including GSM8K, MATH, MMLU-Math, and AQuA.

Key Findings and Results

  • Superior Accuracy: PartitionSel consistently outperformed strong baselines like GREATS and COLM on math reasoning tasks. Notably, on the SAT math benchmark, it achieved 75.45% accuracy, a substantial improvement over the 67.27% achieved by the previous state-of-the-art method (GREATS).
  • Outperforming Proxy Models: In head-to-head comparisons with DoReMi, PartitionSel achieved lower validation perplexity and superior downstream performance (an average gain of +4.65 across math tasks), despite its simpler, proxy-free implementation.
  • Reduced Gradient Conflicts: By selecting samples jointly across domains, PartitionSel effectively induces an "implicit domain mixture." Qualitative analyses revealed a marked decrease in conflicting gradient pairs within batches, translating to a more stable, compatible, and efficient optimization trajectory.

Limitations and Future Directions

While highly effective, PartitionSel has a few limitations:

  • Validation Set Dependency: The method's success hinges on a small, high-quality validation set. If this set is biased or unrepresentative of the target tasks, selection quality may degrade.
  • Scale of Pre-training: The current evaluation focuses heavily on fine-tuning (demonstrated on a 1.5B token corpus). Scaling this discrete selection approach to trillion-token pre-training runs remains an open challenge.
  • Fixed Domain Budgets: The partition matroid capacities are currently set proportionally to domain size. Future research could explore dynamically adjusting these budgets as the model learns which domains require more focus.

Summary updated

BibTeX
@inproceedings{agrawal2026minibatch,
  author = {Prayas Agrawal and Prateek Chanda and Ishita Khatri and Ganesh Ramakrishnan and Bamdev Mishra and Pratik Jawanpuria},
  title = {{Minibatch selection for Language Models via Partition Matroid Constrained Gradient Matching}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=Rl7YAiRT04},
}
Figure