Skip to content

re-ordered the scheduling stages in the disagg handler - #2340

Closed
ahg-g wants to merge 2 commits into
llm-d:mainfrom
ahg-g:prefill
Closed

re-ordered the scheduling stages in the disagg handler#2340
ahg-g wants to merge 2 commits into
llm-d:mainfrom
ahg-g:prefill

Conversation

@ahg-g

@ahg-g ahg-g commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

re-ordered the scheduling stages in the disagg handler such that prefiller is picked first, then encoder, then decoder

What type of PR is this?
/kind feature

What this PR does / why we need it:

With #2299 merging, picking the prefill last becomes suboptimal. The priority should be to pick the endpoint with the highest kv-cache match across domains/racks and then constrain the decoder to that rack.

Which issue(s) this PR fixes:

Related to #2315

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

NONE

@ahg-g
ahg-g requested a review from a team as a code owner August 9, 2026 20:28
@ahg-g
ahg-g requested review from elevran and vMaroon August 9, 2026 20:28
@github-actions github-actions Bot added 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. labels Aug 9, 2026
@ahg-g ahg-g changed the title re-ordered the scheduling stages in the disagg handler such that pref… re-ordered the scheduling stages in the disagg handler Aug 9, 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 Aug 9, 2026
@github-actions github-actions Bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 10, 2026
…iller is picked first, then encoder, then decoder

Signed-off-by: ahg-g <ahg@google.com>
Signed-off-by: ahg-g <ahg@google.com>
@ahg-g

ahg-g commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator Author

/hold

@ahg-g

ahg-g commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator Author

This PR changes existing semantics, which is not good. To maintain backward compatibility #2342 makes this an opt-in choice.

@elevran elevran left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reordering prefill-before-decode makes sense given #2299 (rack-affinity constraint needs the prefill pick before decode runs). Good catch fixing the nil-endpoint case in PrefixBasedPDDecider in the latest push - that was a real bug in the first version of this PR.

Two things before merge: the release note is marked NONE but this changes default routing/metrics behavior for every disagg deployment; and worth considering whether stage order should be configurable rather than hardcoded, since different deployments may want either (decode vs prefill heavy?).

// Stages run in order: decode → encode (optional) → prefill (optional).
// Stages run in order: prefill (optional) → encode (optional) → decode.
// Returns the next profile to execute, or an empty map when all stages are done.
func (h *Handler) Pick(ctx context.Context, request *scheduling.InferenceRequest, profiles map[string]scheduling.SchedulerProfile,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

A few comments

  • IIRC, you need to run encoding to get the object's token for prefill stage,
  • running prefill before decode is changed user behavior and warrants a releae note
  • for backward compat, worth considering making the order configurable via DisaggProfileHandler parameters so that decode first can still be selected (might need to be the default for compatibility or at least add a deprecation note after validating the performance gain from prefill first). The parameter can be simple bool (run prefill first), or an array of steps/profiles to avoid another full reorder in the code next time the trade-off changes.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I sent out #2342 which adds a parameter and preserves backward compatibility and adds a release note, I will close this PR

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

IIRC, you need to run encoding to get the object's token for prefill stage,

This is only changing the picking order within the scheduler, not the execution order.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

what I'm not sure of is if the prefill plugins need token information that is produced as part of the encoding profile's plugins. If that's the case (might not be... could be that they all run earlier to produce request attributes), then encode profile must run before the prefill profile.
It was meant as an open question - I don't know if that's the case.

Runs each scheduling stage in sequence and assembles the final result from all stages that ran.

1. Run the decode profile (always).
1. If a prefill decider is configured and approves the request, run the prefill profile.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: the lead-in sentence above this list (line 27) still says "decode (always), and optionally encode and prefill," but this numbered list now runs prefill -> encode -> decode. Update the lead-in to match.

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/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants