Cost-Aware SGD: Theory and Applications to LLM Policy Optimization
Abstract
We consider the problem of Cost-Aware Learning, where sampling different components of a finite-sum objective incurs different costs. The objective is to reach a target error while minimizing the total cost. We propose Cost-Aware SGD, which uses a distribution based on gradient norms and costs to sample components. We provide a thorough analysis of this algorithm, including cost-improvement bounds over baselines, a characterization of distribution proxy sub-optimality, and a lower bound. We apply our theoretical insights to reinforcement learning with language models, where the cost of including a sequence in a policy-gradient update scales with its length. We find that advantage magnitude is a high-fidelity proxy for sequence-level gradient norms, motivating Cost-Aware GRPO. Across 1.5B, 4B, and 8B LLMs, Cost-Aware GRPO matches or exceeds baseline accuracy while using up to 33\% fewer policy-optimization FLOPs and 33\% fewer total FLOPs.