Skip to content

[RunInference] Reject use_model_manager with a multi-model KeyedModelHandler - #40574

Open
schizophrenicmaniac wants to merge 1 commit into
apache:masterfrom
schizophrenicmaniac:fix/40539-feature-request-runinference-support
Open

schizophrenicmaniac wants to merge 1 commit into
apache:masterfrom
schizophrenicmaniac:fix/40539-feature-request-runinference-support

Conversation

@schizophrenicmaniac

Copy link
Copy Markdown
Contributor

When a KeyedModelHandler is built from a list of KeyModelMappings, load_model() returns a _ModelHandlerManager. That object then loads and caches the per-key models itself, using its own count-based LRU. With use_model_manager=True, ModelManager only sees that wrapper, so the real models skip its memory tracking and eviction, and KeyModelPathMapping side-input updates don't work either.

This PR takes the validation route from the issue. RunInference now raises a ValueError at construction time when use_model_manager=True is used with a multi-model KeyedModelHandler, including when it's wrapped by with_preprocess_fn, with_postprocess_fn or with_no_batching. The error suggests max_models_per_worker_hint instead. Single-model KeyedModelHandlers are unaffected. I also documented use_model_manager and model_manager_args in the RunInference docstring and added a note to KeyedModelHandler.

Added a test in base_test.py that covers the plain and wrapped cases, plus the combinations that should still be allowed.

Fixes #40539

@codecov

codecov Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.93%. Comparing base (76f6e6d) to head (25cc5e9).
⚠️ Report is 162 commits behind head on master.

Additional details and impacted files
@@              Coverage Diff              @@
##             master   #40574       +/-   ##
=============================================
+ Coverage     56.16%   79.93%   +23.76%     
=============================================
  Files          1124      488      -636     
  Lines        178336    82353    -95983     
  Branches       1489        0     -1489     
=============================================
- Hits         100170    65829    -34341     
+ Misses        75645    16524    -59121     
+ Partials       2521        0     -2521     
Flag Coverage Δ
go ?
java ?
python 79.93% <100.00%> (+0.37%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @jrmccluskey for label python.
Backup reviewer: tvalentyn (if the main reviewer is unresponsive, you can escalate to them by tagging their username)

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

@jrmccluskey

Copy link
Copy Markdown
Contributor

Looping in Valentyn who has more context on this bug

@tvalentyn

Copy link
Copy Markdown
Contributor

R: @AMOOOMA mind taking a look? Thanks!

@github-actions

Copy link
Copy Markdown
Contributor

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment assign set of reviewers

@AMOOOMA AMOOOMA 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.

LGTM, thanks!

@tvalentyn

Copy link
Copy Markdown
Contributor

@schizophrenicmaniac could you resolve the conflicts please? thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request][RunInference] Support multi-model KeyedModelHandler with ModelManager

4 participants