Skip to content

Add weightMode toggle for multimodal cache affinity producer#1397

Open
guygir wants to merge 5 commits into
llm-d:mainfrom
guygir:mm_scorer_weight_mode
Open

Add weightMode toggle for multimodal cache affinity producer#1397
guygir wants to merge 5 commits into
llm-d:mainfrom
guygir:mm_scorer_weight_mode

Conversation

@guygir

@guygir guygir commented May 29, 2026

Copy link
Copy Markdown
Contributor

Added weightMode toggle to the existing mm-embeddings-cache-producer, so multimodal encoder-cache affinity can run unweighted (default) or weighted by tokenized placeholder length. It builds on #901 without introducing separate weighted plugin types (the scorer stays size agnostic and continues to score matchedWeight / totalWeight).

  1. Added weightMode (unweighted | weighted, default unweighted) to mm-embeddings-cache-producer:
    1.1 unweighted mode keeps unit item size (1) and no token-producer dependency
    1.2 weighted mode uses MultiModalFeature.Length and declares Consumes(token-producer) when configured
  2. Added sample deploy config, updated producer and scorer READMEs.
  3. Updated producer and scorer READMEs.

Validation:

  • go test ./pkg/epp/framework/plugins/requestcontrol/dataproducer/multimodal/...
  • go test ./pkg/epp/framework/plugins/scheduling/scorer/mmcacheaffinity/...
  • cluster verification

Follow-up to #901.

@github-actions github-actions Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 29, 2026
@github-actions
github-actions Bot requested review from nilig and shmuelk May 29, 2026 20:05
@guygir
guygir force-pushed the mm_scorer_weight_mode branch from 3250359 to 6c9fad7 Compare May 29, 2026 20:11
@ahg-g

ahg-g commented May 30, 2026

Copy link
Copy Markdown
Collaborator

/assign @capri-xiyue

Comment thread pkg/epp/framework/plugins/requestcontrol/dataproducer/multimodal/README.md Outdated
Comment thread pkg/epp/framework/plugins/requestcontrol/dataproducer/multimodal/producer.go Outdated
guygir added a commit to guygir/llm-d-inference-scheduler that referenced this pull request Jun 1, 2026
Signed-off-by: Guy Girmonsky <guygir@gmail.com>
if !p.useWeighted {
return nil
}
return map[plugin.DataKey]any{tokenproducer.TokenizedPromptDataKey: scheduling.TokenizedPrompt{}}

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.

We can declare this as optional, when available we use the length as produced by the token-producer, when not we fall back to 1. No need to have an explicit WeightMode

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed. I removed the explicit weightMode and implemented this as an optional data dependency instead.

I added the small framework primitive because using lengths "when available" needs ordering to be deterministic. Without an optional DAG edge, the MM producer can run before token-producer and silently fall back to 1 even though tokenization is configured and weights DO exist.

With this change, if token-producer is configured, mm-embeddings-cache-producer runs after it and uses TokenizedPrompt.MultiModalFeatures.Length. If token-producer is absent, nothing is auto-created and the producer falls back to unit weight 1.

return map[plugin.DataKey]any{p.dk: attrmm.EncoderCacheMatchInfo{}}
}

// Consumes declares the token-producer dependency only for weighted mode so

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.

What will happen is token-producer is declared but with estimate backend? I assume the weighted model will still work as expected?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, a configured token-producer backend, including estimate, runs before the MM producer through the optional DAG edge, which uses the populated MultiModalFeature.Length values - precise or estimated.

metadata.
- `cacheSize` bounds the EPP routing LRU only; it is not a model-server encoder
cache capacity knob.
- Unweighted mode remains lightweight: structured chat media blocks are enough and

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.

I think token producer with estimate backend is also lightweight. Should the default behavior be use weighted when tokenproducer is available?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That makes sense, yep. Default behavior is automatic now: when token-producer is present, we use the tokenized multimodal lengths, whether estimated or precise. When it is absent, we keep the lightweight unit-weight fallback.

if _, exists := itemsByHash[feature.Hash]; exists {
return
}
size := 1

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.

Is weight a better name?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Indeed, changed the local variable name to weight where it represents scoring contribution.

@ahg-g

ahg-g commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

@guygir are you able to address the comments? code freeze is approaching

@guygir

guygir commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

@guygir are you able to address the comments? code freeze is approaching

Yes, on it. Just made some changes - will push the latest version and address all comments by tomorrow morning.

@guygir
guygir requested a review from a team as a code owner June 9, 2026 22:42
@guygir
guygir requested review from ahg-g and vMaroon June 9, 2026 22:42
@guygir
guygir force-pushed the mm_scorer_weight_mode branch from 1a9e300 to 1fc2f73 Compare June 9, 2026 22:43
@guygir

guygir commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @ahg-g and @capri-xiyue for the reviews, all addressed in the latest commit.

The main change is that mm-embeddings-cache-producer now treats TokenizedPrompt as an optional data dependency: if token-producer is configured, the data graph orders the MM producer after it and the producer uses MultiModalFeature.Length. if token-producer is not configured, nothing is auto-created and the producer falls back to unit weight 1 per hash.

I added a small OptionalConsumerPlugin framework hook because the alternative was not deterministic. Without a DAG edge, mm-embeddings-cache-producer can run before token-producer and silently fall back to unit weights even when tokenization is configured. A required Consumes() edge would fix ordering but would also require or auto-create token-producer, which is what we wanted to avoid in the first place...

Since this commit included a small framework change, I ran additional validations:

go test ./pkg/epp/framework/plugins/requestcontrol/dataproducer/multimodal/...
go test ./pkg/epp/framework/plugins/scheduling/scorer/mmcacheaffinity/...
go test ./pkg/epp/framework/plugins/requestcontrol/dataproducer/tokenizer/...
go test ./pkg/epp/datalayer/...
go test ./pkg/epp/framework/interface/plugin/...

all passed on my end.

@ahg-g

ahg-g commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Thanks @guygir , please rebase.

Comment thread pkg/epp/datalayer/data_graph.go Outdated
@guygir
guygir force-pushed the mm_scorer_weight_mode branch from 1fc2f73 to b029b4a Compare June 13, 2026 12:13
@guygir

guygir commented Jun 13, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main and switched to upstream DataDependencies.Optional. kept the optional DAG ordering behavior and validated fallback,tokenized-weighted paths with tests

extractors:
- pluginRef: mm-embeddings-cache-producer
- pluginRef: precise-prefix-cache-scorer
schedulingProfiles:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How were the weights tuned? Why not extend the current defaults (optimized baseline) with the mm-embeddings-cache-scorer?

On a different note, tuning weights is very tough, we should migrate examples to the new approach.

This can be followed up in a different PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

They were tuned according to the mm benchmarks, but I agree it’s clearer for this sample to extend the current default/optimized baseline and add mm affinity (conservatively), at least for now.

@guygir
guygir force-pushed the mm_scorer_weight_mode branch from b029b4a to 28d17d2 Compare June 13, 2026 22:04
Use TokenizedPrompt as an optional data dependency so multimodal cache affinity can use tokenized placeholder lengths when token-producer is configured, while preserving the lightweight unit-weight fallback when it is absent.

Signed-off-by: Guy Girmonsky <guygir@gmail.com>
@guygir
guygir force-pushed the mm_scorer_weight_mode branch from 28d17d2 to 09bdc45 Compare June 15, 2026 22:00
@github-actions

github-actions Bot commented Jul 7, 2026

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.

@capri-xiyue

Copy link
Copy Markdown
Contributor

Hi @guygir, could you fix the CI/CD including lint and test?

guygir added 2 commits July 20, 2026 01:30
Signed-off-by: Guy Girmonsky <guygir@gmail.com>
Signed-off-by: guygir <guygir@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

No open projects
Status: No status

Development

Successfully merging this pull request may close these issues.

5 participants