Skip to content

feat(inflightloadproducer): allow configuring output ratio#1731

Merged
vMaroon merged 4 commits into
llm-d:mainfrom
asharkhan3101:ashar/configurable-output-ratio
Jun 25, 2026
Merged

feat(inflightloadproducer): allow configuring output ratio#1731
vMaroon merged 4 commits into
llm-d:mainfrom
asharkhan3101:ashar/configurable-output-ratio

Conversation

@asharkhan3101

Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind feature

What this PR does / why we need it:

This PR add a new configurable outputRatio parameter to inflightloaderproducer defaulting to same 1.5 if unspecified. This allows user to better choose a ratio that represents their traffic pattern for input to output ratio. 1.5x default doesn't work very well for high ISL workload with lot of contexts (200K or above). the estimated output token of 300K is very high in those cases.

Allowing it to be configured allows user to choose a value that best matches their workload.

Which issue(s) this PR fixes:

Fixes #1730

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

Add parameter `outputRatio` to inflight load producer for user configurable output token estimation

Signed-off-by: mohammadkhan <mohammadkhan@digitalocean.com>
@asharkhan3101
asharkhan3101 requested a review from a team as a code owner June 23, 2026 20:47
@github-actions github-actions Bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. kind/feature Categorizes issue or PR as related to a new feature. labels Jun 23, 2026

Copilot AI left a comment

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.

Pull request overview

Adds a user-configurable outputRatio to the in-flight load producer so output token estimation can be tuned to workload characteristics (while preserving the current 1.5 default when unset), addressing issue #1730.

Changes:

  • Introduces DefaultOutputRatio and a NewSimpleTokenEstimatorWithRatio(...) constructor to parameterize output estimation.
  • Extends inflight-load-producer config with optional outputRatio (validated as non-negative) and wires it into the producer’s token estimator.
  • Documents the new parameter and adds factory-level tests covering default/custom/zero/negative values.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
pkg/epp/framework/plugins/requestcontrol/dataproducer/inflightload/token_estimator.go Adds a default ratio constant and a ratio-configurable estimator constructor.
pkg/epp/framework/plugins/requestcontrol/dataproducer/inflightload/README.md Documents the new outputRatio parameter and its behavior.
pkg/epp/framework/plugins/requestcontrol/dataproducer/inflightload/producer.go Adds outputRatio to config, validates it, and injects it into the token estimator.
pkg/epp/framework/plugins/requestcontrol/dataproducer/inflightload/producer_test.go Adds tests ensuring outputRatio defaults/overrides/validation behave as intended.

Comment thread pkg/epp/framework/plugins/requestcontrol/dataproducer/inflightload/README.md Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Mohammad Ashar Khan <140482588+asharkhan3101@users.noreply.github.com>
@asharkhan3101 asharkhan3101 changed the title feat(inflightloadproducer): allow configurable output ratio feat(inflightloadproducer): allow configuring output ratio Jun 23, 2026
@github-actions github-actions Bot added kind/feature Categorizes issue or PR as related to a new feature. and removed kind/feature Categorizes issue or PR as related to a new feature. labels Jun 23, 2026
@asharkhan3101

Copy link
Copy Markdown
Contributor Author

Presence of max_tokens (if present) should be a better indicator for output token estimation and there are some other approaches that @LukeAVanDrie suggested in the thread, those can be a follow up. For now this offers some flexibility in output estimation.

@LukeAVanDrie

Copy link
Copy Markdown
Contributor

Presence of max_tokens (if present) should be a better indicator for output token estimation and there are some other approaches that @LukeAVanDrie suggested in the thread, those can be a follow up. For now this offers some flexibility in output estimation.

Thanks, I agree; this is still valuable to ship, but it is papering over a structural flaw that the tunable slope doesn't cure: output is not proportional to input.

Two cheap changes can land in a follow-up:

  1. Honor the request's own max_tokens / max_completion_tokens / max_output_tokens as you suggested. These already exist and are handled elsewhere in the repo (pkg/sidecar/proxy/proxy.go, the connectors), but the estimator ignores them. When a client supplies one, it's a real, free upper bound. Best estimate is roughly min(input × ratio, requestMaxTokens) when the cap is present.
  2. Cap the estimate (min(input × ratio, maxOutputTokens)).

/approve

/lgtm

@vMaroon
vMaroon merged commit 4f0cc9e into llm-d:main Jun 25, 2026
29 checks passed
ahg-g pushed a commit that referenced this pull request Jun 25, 2026
Signed-off-by: llm-d-router-release-notes[bot] <287676111+llm-d-router-release-notes[bot]@users.noreply.github.com>
Co-authored-by: llm-d-router-release-notes[bot] <287676111+llm-d-router-release-notes[bot]@users.noreply.github.com>
@asharkhan3101
asharkhan3101 deleted the ashar/configurable-output-ratio branch June 25, 2026 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature Categorizes issue or PR as related to a new feature. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow configuring outputRation in output token estimator in inflightloadproducer

5 participants