Repository navigation
feat(v1): gate model requests with client.request_gate, and vf-gate - #2969
Closed
RGaonkar26 wants to merge 1 commit into
Closed
RGaonkar26 wants to merge 1 commit into
RGaonkar26 wants to merge 1 commit into
Conversation
Model clients now use the host request gate when their endpoint config sets `request_gate`. With it unset (the default), `build_async_httpx` returns the same plain `httpx.AsyncClient` as before and the gate module is never imported. - `BaseClientConfig.request_gate: RequestGateConfig | None = None`, so `[client.request_gate]`, per-agent `env.<agent>.client.request_gate` and judge clients all accept it (eval and train clients alike). An unset gate is left out of dumps, so saved configs and traces stay loadable by verifiers versions without the field (`extra="forbid"`). - `build_async_httpx` returns a `GatedAsyncClient` when it is set (from `verifiers.v1.request_gate`, imported only then). Every request that names a model takes a permit of the gate for its (endpoint origin, API key, model) before it is sent and returns it when the response is read; a streamed response holds its permit until it is closed or collected. Requests that name no model pass straight through. The first use of a gate (which may start the daemon) runs off the event loop. - The gate reads a request's model from its JSON body, for the eval client, the train client and judges alike; the clients themselves are unchanged. - `vf-gate` shows the host's gates (cap, in flight, waiting, admitted, mean wait) and `vf-gate --resize N [--model M]` moves the cap of live gates for every process using them. `--dir` picks a gate directory, `--output json`. - A short section in docs/evaluation.md. Ported from Parker Pettit's verifiers `feat/pipelines`: the client hookup and `GatedAsyncClient` of 627154b ("Gate concurrent model requests per endpoint, key and model across the host"), finalizer-safe stream releases from 9af804e, one gate across auth dialects from dad67e0, and the daemon-backed client of #2946 (c92797b). Operators there resize through `flow gate resize` and prime-rl's `eval control resize-requests` (67661d6); `vf-gate` is the verifiers-native equivalent. Differences from #2946: - No 429/529 absorption or adaptive limit yet (next branch): a provider 429 reaches the caller as it does today, and the harness SDK retries it. - No `ProviderRetryConfig` (96a2e20) and no interception-server changes. - The first `model_gate` of a process is built in a thread, not on the loop. - No `MODEL_EXTENSION`: the eval client does not name the model on the request, so `clients/eval.py` is untouched (and #2675, which replaces its `_request` with the SDK transport, merges cleanly). Parsing the body costs well under a millisecond against a model call. - `vf-gate` is new; `RequestGateConfig` is exported from `verifiers.v1.clients` only, not the top-level namespace. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 23, 2026
Author
|
Closing in favour of Parker's #2946, which is the same request-gate / model-pool work and where it should land. Nothing on verifiers main or our pipeline needs it right now. The branch stays up: it has shared-host hardening (private 0700 dir, peer-uid checks, single-daemon lock, restart window), live tests against the Prime Inference gateway, and the pool poll backoff, all of which apply to #2946 and can be cherry-picked. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
request_gateto client configs. When it is set, every model request through that endpoint waits for a slot of the host-wide gate from #2968. Also adds avf-gateCLI to inspect and resize gates live.Why
Several runs or many workers on one host can push a provider past its per-key concurrency limit (for example Prime Inference's
429 Too many concurrent requests for this model (limit: 32)). Main has no way to cap requests per model across processes, or to change a cap during a run.Change
BaseClientConfig.request_gate: RequestGateConfig | None = None. Because it is on the base config, it applies to[client], per-agent clients and judges, and to both eval and train clients.build_async_httpxreturns aGatedAsyncClient. A request whose JSON body names a model takes a permit before it is sent, and returns it once the response has been read. A stream holds its permit until it is closed or garbage-collected. Requests that name no model pass straight through. A process's first use of a gate, which may start the daemon, runs in a thread.Bearerkey share one gate.vf-gate(a new script) shows a table of model, cap, in flight, waiting, admitted and wait. It also takes--resize N --model M,--dirand--output json. A resize with no live gate exits non-zero.RequestGateConfigis exported fromverifiers.v1.clients. There is a short section indocs/evaluation.md.Behaviour
request_gateunset,build_async_httpxreturns the same plainhttpx.AsyncClientas before, andverifiers.v1.request_gateis not imported.clients/eval.pyis unchanged.X-Prime-Team-ID. Verifiers' clients add it for the Prime Inference host; a gated client whosebase_urlpoints elsewhere at the same gateway must send it itself.Tests
tests/unit/request_gate/test_request_gate.py, against a local fake provider that answers 429 above its limit. They cover one cap shared by 4 processes, a live resize reaching running processes,vf-gate, streams, and a GC-collected stream not deadlocking. Unit suite: 253 passed, 18 skipped.vf-gate --resize 6mid-run from cap 2: in flight stayed at 2 or below before the resize and reached 6 after it; 48/48 requests succeeded.Notes
feat/pipelines(627154bf1,9af804eac,dad67e0b4, and The request gate admits through one daemon per host #2946). Differences: no 429 absorption yet (feat(v1): adapt the request gate's limit to 429/529 #2970), and noProviderRetryConfig. There is noMODEL_EXTENSION: the gate reads the body'smodel, soclients/eval.pystays untouched. An unset gate is left out of dumps, andvf-gateis new.🤖 Generated with Claude Code