Skip to content

refactor(flowcontrol): UsageLimitPolicy fills a framework-owned ceilings buffer - #2171

Open
LukeAVanDrie wants to merge 1 commit into
llm-d:mainfrom
LukeAVanDrie:fc-usage-limit-fill-api
Open

refactor(flowcontrol): UsageLimitPolicy fills a framework-owned ceilings buffer#2171
LukeAVanDrie wants to merge 1 commit into
llm-d:mainfrom
LukeAVanDrie:fc-usage-limit-fill-api

Conversation

@LukeAVanDrie

Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

UsageLimitPolicy.ComputeLimit returned a slice parallel to the priorities argument, and the dispatch loop indexed it unchecked: a policy returning a short slice panicked the processor. The policy now writes into a buffer the framework sizes to len(priorities) and pre-fills with 1.0, so a short result cannot exist and a skipped entry fails open instead of keeping a stale value. The processor reuses one buffer across cycles, removing a per-cycle allocation on the 1ms dispatch path.

The call stays batch-shaped rather than per-band, and the interface doc now states why: the framework calls ComputeLimit exactly once per dispatch cycle, duty-cycle policies (soft-reflective-ceiling) use that call as their tick, and computing all ceilings together is what lets every gated band see the same open/closed decision within a cycle.

Breaking SDK change for out-of-tree UsageLimitPolicy implementations; part of the panic-posture cleanup in #2098.

Which issue(s) this PR fixes:

Part of #2098

Release note:

ACTION REQUIRED for out-of-tree UsageLimitPolicy plugins: ComputeLimit now fills a framework-provided ceilings buffer instead of returning a slice.

…ings buffer

ComputeLimit returned a slice parallel to the priorities argument, and
the dispatch loop indexed it unchecked: a policy returning a short slice
panicked the processor. The policy now writes into a caller-provided
buffer that the framework sizes to len(priorities) and pre-fills with
1.0, so a mis-sized result is unrepresentable and an unwritten entry
fails open instead of carrying stale state. The processor reuses one
buffer across cycles, removing the per-cycle allocation on the 1ms
dispatch path.

A batch call (rather than per-band) is retained deliberately: duty-cycle
policies such as soft-reflective-ceiling advance shared state once per
dispatch cycle and require all gated bands to observe the same open or
closed decision within a cycle.

Signed-off-by: Luke Van Drie <lukevandrie@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/cleanup size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant