Skip to content

Preserve ModelManager metric_tag across RunInference side-input model updates - #40714

Open
AMOOOMA wants to merge 4 commits into
apache:masterfrom
AMOOOMA:preserve-model-manager-metric-tag
Open

AMOOOMA wants to merge 4 commits into
apache:masterfrom
AMOOOMA:preserve-model-manager-metric-tag

Conversation

@AMOOOMA

@AMOOOMA AMOOOMA commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Summary

When RunInference updates its model via side input (ModelMetadata), _RunInferenceDoFn._load_model acquires the new model under the updated model_id tag (self._cur_tag) so ModelManager caches and evicts the new model version separately from the previous version, while the BeamML_RunInference transform annotation remains fixed at construction time (self._model_tag / model_identifier).

This PR passes metric_tag=self._model_tag through _SharedModelWrapper to ModelManager.acquire_model(..., metric_tag=...), and maps metric_tag to the active version tag in ModelManager and ResourceEstimator so num_loaded_models_<metric_tag> and memory_estimate_mb_<metric_tag> continue reporting under the original metric_tag across runtime side-input model updates.

Testing

  • Updated test_run_inference_dofn_model_update_acquires_and_releases_matching_tag in base_test.py to verify metric_tag preservation across model updates.
  • Added test_model_manager_metrics_with_metric_tag in model_manager_test.py.

@AMOOOMA
AMOOOMA marked this pull request as ready for review October 21, 2026 21:25
@AMOOOMA

AMOOOMA commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

R: @tvalentyn

@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

@codecov

codecov Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 3.12500% with 31 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.05%. Comparing base (a8d6afd) to head (5766f0c).
⚠️ Report is 35 commits behind head on master.

Files with missing lines Patch % Lines
...s/python/apache_beam/ml/inference/model_manager.py 0.00% 30 Missing ⚠️
sdks/python/apache_beam/ml/inference/base.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master   #40714    +/-   ##
========================================
  Coverage   80.04%   80.05%            
========================================
  Files         490      490            
  Lines       82916    83031   +115     
========================================
+ Hits        66373    66467    +94     
- Misses      16543    16564    +21     
Flag Coverage Δ
python 80.05% <3.12%> (+<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.

self.models = models
self.use_model_manager = not isinstance(models, list)
self.model_tag = model_tag
self.metric_tag = metric_tag or model_tag

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.

could we clarify in the docstring the difference between these two concepts?

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.

Sg! Added comments

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants