feat: nvidia NIM local RPM budget + concurrency cap (#6846)#7726
Merged
Conversation
Phase 1 of client-side quota tracking for NVIDIA NIM (no rate-limit headers, no usage API): - Register nvidia in PROVIDER_DEFAULT_RATE_LIMITS (40 RPM sliding window, matching the documented free-tier note), operator-overridable via a new ResilienceSettings.providerQuotaOverrides map. - Per-connection concurrency cap (default 6) via a new nvidiaConcurrencyGate leaf module wrapping rateLimitSemaphore, wired into DefaultExecutor.execute(). - Per-model 429 lockout: confirmed already satisfied by #6773's passthroughModels flag on the nvidia registry entry (no new code needed) — added as a regression-guard test instead. Phase 2 (AIMD adaptive ceiling learning) and Phase 3 (dashboard quota card + combo-routing headroom preference) are explicitly deferred to follow-up issues, per the plan's own scope note.
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
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.
Summary
Phase 1 of client-side quota tracking for the
nvidia(NVIDIA NIM) provider, which sends no rate-limit headers and has no usage API (see #6846's citations).nvidia: { requests: 40, windowMs: 60_000 }inPROVIDER_DEFAULT_RATE_LIMITS(open-sse/services/providerDefaultRateLimit.ts), matching the documented "~40 RPM" free-tier note. Already wired end-to-end through the existingwithRateLimit()→awaitProviderDefaultSlot()pre-schedule gate — no new call site needed.ResilienceSettings.providerQuotaOverrides: Record<string, { rpm?, concurrency? }>(types/normalize/settings.ts), resolved inrateLimitManager.ts::initializeRateLimitProtection(). Not yet exposed via the/api/resilienceroute or a dashboard form (no UI in Phase 1) — the mechanism is real and tested, wiring the UI is Phase 3 scope.open-sse/executors/default/nvidiaConcurrencyGate.tswraps the existingrateLimitSemaphore.ts, wired intoDefaultExecutor.execute()(the only dispatch path nvidia runs through — no dedicated nvidia executor exists). No-op for every other provider.passthroughModels: trueon nvidia's registry entry, sohasPerModelQuota("nvidia")already returnstruevia the existing generic passthrough branch. No code change needed; added a regression-guard test instead of redundant code.docs/reference/PROVIDER_REFERENCE.mdis auto-generated ("do not edit by hand"), so added a manual "Provider-specific quota tracking notes" section instead of hand-editing the generated table.Deferred (explicitly out of scope for this PR, per the plan's own scope note)
Retry-Afterhonoring, persistence design./api/resilienceexposure ofproviderQuotaOverrides.This PR is Phase 1 only — the issue stays open for the Phase 2/3 follow-ups.
How this was validated (Hard Rule #18 — TDD)
New test file
tests/unit/nvidia-quota-phase1.test.ts(13 tests, mocked/synthetic fixtures only — no live NIM calls):hasPerModelQuota("nvidia")true; a 429 lock on one model doesn't lock a sibling model on the same connection.PROVIDER_BREAKER_FAILURE_STATUSESinsrc/sse/handlers/chat.ts(untouched by this PR) still excludes 429.Proved red→green for the actually-new code: temporarily reverted the
nvidiamap entry inproviderDefaultRateLimit.ts, confirmed the "real default RPM budget" test failed, restored it and confirmed all 13 tests pass. (ThehasPerModelQuotatest intentionally does NOT prove red→green against my diff, since that requirement was already met by #6773 — see commit message / plan-file note.)Gates run locally, all green:
check-test-discovery,typecheck:core,typecheck:noimplicit:core(pre-existing unrelated errors incombo.ts/usageTracking.ts/cliRuntime.tsconfirmed untouched by this diff),eslinton all changed files,check:complexity-ratchets(no regression vs baseline),check-file-size(one documented rebaseline:open-sse/executors/default.ts877→890, justified infile-size-baseline.json),check:cycles,check:docs-sync,check:any-budget:t11,check:tracked-artifacts. Also re-ran the pre-existingrate-limit-provider-default.test.ts,account-fallback-service.test.ts,nvidia-passthrough-models-6773.test.ts,rate-limit-manager.test.ts, and the fullresilience-settings-*.test.tsfamily — all green (one pre-existing test's exact-key-list assertion was updated to include the newproviderQuotaOverridessection).test:coveragewas not re-run locally per the task's own instructions (heaviest gate, shared box) — this change is additive-only (new leaf module + new branches gated behindprovider === "nvidia"), fully covered by the new test file; CI is authoritative.Refs #6846