Skip to content

feat(flowcontrol): add VTC fairness policy with token-based cost and starvation prevention#1222

Open
gyliu513 wants to merge 2 commits into
llm-d:mainfrom
gyliu513:vtc
Open

feat(flowcontrol): add VTC fairness policy with token-based cost and starvation prevention#1222
gyliu513 wants to merge 2 commits into
llm-d:mainfrom
gyliu513:vtc

Conversation

@gyliu513

Copy link
Copy Markdown
Member

What type of PR is this?

/kind feature

What this PR does / why we need it:

Implements the vtc-fairness-policy plugin as described in #1182 (Task 1).

Unlike round-robin-fairness-policy (which treats every request equally regardless of size), VTC tracks a cumulative virtual token cost per flow. The flow with the lowest virtual counter wins the next dispatch slot, ensuring large-prompt tenants don't starve small-prompt tenants.

/cc @LukeAVanDrie

Which issue(s) this PR fixes:

Related to task1 for #1182

Release note (write NONE if no user-facing change):

feat(flowcontrol): add VTC fairness policy with token-based cost and starvation prevention

@github-actions github-actions Bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label May 19, 2026
@github-actions
github-actions Bot requested review from ahg-g and nilig May 19, 2026 20:51
//
// Priority order:
// 1. Client-provided hint via InputTokenCountHint() (e.g., from pre-tokenized completions prompt).
// 2. Length of a pre-tokenized prompt in InferenceRequestBody.TokenizedPrompt.

@roytman roytman May 25, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a PR #1248, which adds support to inference/v1/generate. Depends on which PR will be merged first, this part should be updated.
Can #1303 be relevant ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the heads-up, @roytman!

For #1248: good catch. The /inference/v1/generate endpoint uses GenerateRequest{TokenIDs}, which may not surface through the existing ir.Body.TokenizedPrompt path in estimateInputTokens. Depending on merge order, I'll update the cascade to handle that format when #1248 lands (or if it merges first, I'll add support before this one is merged).

For #1303: agree that centralizing token estimation is the right long-term direction. The current approach in vtc is a local heuristic to avoid a hard dependency, but if #1303 moves forward with a shared estimation backend, this function should be replaced to use that.

@github-actions

Copy link
Copy Markdown
Contributor

This PR is marked as stale after 21d of inactivity. After an additional 14d of inactivity (7d to become rotten, then 7d more), it will be closed. To prevent this PR from being closed, add a comment or remove the lifecycle/stale label.

@ahg-g

ahg-g commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

@gyliu513 what is the status here? sorry this fell through the cracks, but if you think this is still relevant and show some evaluation to better understand its potential vs existing policies, I will be happy to review it.

@LukeAVanDrie

Copy link
Copy Markdown
Contributor

@gyliu513 what is the status here? sorry this fell through the cracks, but if you think this is still relevant and show some evaluation to better understand its potential vs existing policies, I will be happy to review it.

This is on me. We talked and paused this since there was a lot of churn on the inflight tokens data producer and I wanted to wait for that to land so we can leverage it here. Will do a fresh review today and suggest some short-term pragmatic fixes here as the data architecture is still not ideal for flow control plugins.

@gyliu513
gyliu513 requested review from a team, LukeAVanDrie and shmuelk as code owners July 15, 2026 00:55
@gyliu513
gyliu513 requested a review from liu-cong July 15, 2026 00:55
@gyliu513
gyliu513 force-pushed the vtc branch 2 times, most recently from fe4211f to d427414 Compare July 16, 2026 04:54
…starvation prevention

Signed-off-by: Guangya Liu <gyliu513@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

No open projects
Status: No status

Development

Successfully merging this pull request may close these issues.

5 participants