How Fast Can Reward Models Score? A Systems Study of C++ and PyTorch Inference Runtimes for RLHF

Hugging Face Daily Papers Papers

Summary

This paper presents a systems study comparing C++ and PyTorch inference runtimes for reward model scoring in RLHF pipelines, finding that ONNXRuntime provides speedups on CPU while torch.compile leads on GPU, with batching strategy mattering more than language or runtime.

In RLHF pipelines, reward scoring blocks policy updates. Slow scoring bottlenecks the entire loop, since no update runs until every rollout gets a score. And yet most setups just default to PyTorch eager mode or torch.compile, no one checks if that's actually fastest. Scoring itself is small. Rollout generation eats far more of a typical RLHF step. But scoring and generation fight over the same CPU and GPU resources, so a faster scoring engine doesn't shrink step time on its own. It mainly frees up capacity generation can use instead. We built a native C++ inference engine on ONNX Runtime. First step: confirm correctness. Output matched the PyTorch reference to 5.7 x 10^-6 on CPU and 4.2 x 10^-3 on GPU, close enough to trust. Then we tested it against PyTorch eager mode, torch.compile, and FastAPI, on both CPU and GPU. CPU was decisive. Our engine beat every baseline, confidence intervals didn't even overlap. GPU gave a different view: we beat PyTorch and FastAPI, but torch.compile came out ahead. Further testing traced the speedup to ONNX Runtime itself, not C++ as a language. And batching strategy mattered more than either the language or the runtime choice, more than we expected. The results are from repeated, independent runs, since single runs just aren't reliable enough to trust.
Original Article
View Cached Full Text

Cached at: 07/29/26, 07:54 PM

Paper page - How Fast Can Reward Models Score? A Systems Study of C++ and PyTorch Inference Runtimes for RLHF

Source: https://huggingface.co/papers/2607.19712

Abstract

InRLHFpipelines,rewardscoringblockspolicyupdates.Slowscoringbottleneckstheentireloop,sincenoupdaterunsuntileveryrolloutgetsascore.AndyetmostsetupsjustdefaulttoPyTorcheagermodeortorch.compile,noonechecksifthat’sactuallyfastest.Scoringitselfissmall.RolloutgenerationeatsfarmoreofatypicalRLHFstep.ButscoringandgenerationfightoverthesameCPUandGPUresources,soafasterscoringenginedoesn’tshrinksteptimeonitsown.Itmainlyfreesupcapacitygenerationcanuseinstead.WebuiltanativeC++inferenceengineonONNXRuntime.Firststep:confirmcorrectness.OutputmatchedthePyTorchreferenceto5.7x10^-6onCPUand4.2x10^-3onGPU,closeenoughtotrust.ThenwetesteditagainstPyTorcheagermode,torch.compile,andFastAPI,onbothCPUandGPU.CPUwasdecisive.Ourenginebeateverybaseline,confidenceintervalsdidn’tevenoverlap.GPUgaveadifferentview:webeatPyTorchandFastAPI,buttorch.compilecameoutahead.FurthertestingtracedthespeeduptoONNXRuntimeitself,notC++asalanguage.Andbatchingstrategymatteredmorethaneitherthelanguageortheruntimechoice,morethanweexpected.Theresultsarefromrepeated,independentruns,sincesinglerunsjustaren’treliableenoughtotrust.

View arXiv pageView PDFProject pageGitHubAdd to collection

Get this paper in your agent:

hf papers read 2607\.19712

Don’t have the latest CLI?curl \-LsSf https://hf\.co/cli/install\.sh \| bash

Models citing this paper0

No model linking this paper

Cite arxiv.org/abs/2607.19712 in a model README.md to link it from this page.

Datasets citing this paper0

No dataset linking this paper

Cite arxiv.org/abs/2607.19712 in a dataset README.md to link it from this page.

Spaces citing this paper0

No Space linking this paper

Cite arxiv.org/abs/2607.19712 in a Space README.md to link it from this page.

Collections including this paper1

Similar Articles

Rewriting model inference with CUDA kernels: the bottleneck was not just GEMM [P]

Reddit r/MachineLearning

Author describes building FlashRT, a CUDA-first inference runtime that rewrites model inference paths with C++/CUDA kernels to address bottlenecks beyond GEMM for small-batch/realtime workloads, achieving significant latency improvements on Jetson Thor and RTX 5090. The article discusses lessons on precision (FP8 helpful, FP4 mixed) and the need to bypass generic runtimes for realtime inference.

Scaling laws for reward model overoptimization

OpenAI Blog

OpenAI researchers empirically study how reward model overoptimization affects performance, establishing scaling laws that show the relationship between proxy reward optimization and ground truth performance varies by optimization method and scales predictably with model size.