Skip to content

[RunInference] Fix ModelManager active accounting when spawning after eviction - #41901

Open
arijeetmukherjee3108-droid wants to merge 1 commit into
apache:masterfrom
arijeetmukherjee3108-droid:fix-model-manager-eviction-accounting
Open

arijeetmukherjee3108-droid wants to merge 1 commit into
apache:masterfrom
arijeetmukherjee3108-droid:fix-model-manager-eviction-accounting

Conversation

@arijeetmukherjee3108-droid

Copy link
Copy Markdown
Contributor

Fixes #41900

Right now, when ModelManager.should_spawn_model() frees up memory using _evict_to_make_space() it returns True without updating _pending_reservations, _total_active_jobs or _active_counts[tag].

This breaks the counters:

  • _total_active_jobs stays 0 while the new model is actually running, so an unknown model can enter isolation mode and delete it mid-inference.
  • When release_model() runs later, _total_active_jobs goes negative.
  • _spawn_new_model() still subtracts est_cost from _pending_reservations (messing up other concurrent loads) and drops _active_counts[tag] below 0 if the load fails.

Changes

  • Update _pending_reservations, _total_active_jobs and _active_counts[tag] in should_spawn_model() even when space is freed via eviction.
  • Added 3 unit tests in sdks/python/apache_beam/ml/inference/model_manager_test.py:
    • test_eviction_spawn_updates_active_accounting
    • test_eviction_spawn_load_failure_preserves_accounting
    • test_eviction_spawn_protected_from_isolation_flush

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @kennknowles added as fallback since no labels match configuration
Backup reviewer: Abacn (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).

@kennknowles

Copy link
Copy Markdown
Member

I think @tvalentyn is a possible good reviewer here. The PR didn't get tagged appropriately.

@codecov

codecov Bot commented Dec 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 59.64%. Comparing base (8e76c39) to head (cb11288).
⚠️ Report is 26 commits behind head on master.

Files with missing lines Patch % Lines
...s/python/apache_beam/ml/inference/model_manager.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master   #41901   +/-   ##
=========================================
  Coverage     59.63%   59.64%           
  Complexity     5188     5188           
=========================================
  Files          1471     1471           
  Lines        188508   188541   +33     
  Branches       3885     3885           
=========================================
+ Hits         112418   112456   +38     
+ Misses        72678    72673    -5     
  Partials       3412     3412           
Flag Coverage Δ
python 80.84% <0.00%> (+0.01%) ⬆️

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.

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.

[Bug]: ModelManager.should_spawn_model() skips active job accounting when spawning after eviction

2 participants