Skip to content

Implement Vertex AI Model Monitoring v2 - #39738

Open
jrmccluskey wants to merge 7 commits into
apache:masterfrom
jrmccluskey:hallMonitor
Open

Implement Vertex AI Model Monitoring v2#39738
jrmccluskey wants to merge 7 commits into
apache:masterfrom
jrmccluskey:hallMonitor

Conversation

@jrmccluskey

Copy link
Copy Markdown
Contributor

Implementation of https://s.apache.org/beam-python-vertex-model-monitoring for model monitoring v2.


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

@github-actions

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @shunping for label python.

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
jrmccluskey requested a review from damccorm August 18, 2026 17:31

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

Thanks! Overall this looks good to me, had a few specific questions/comments

_ = (
results
| 'BeamML_RunInference_MonitoringOutlet' >>
self._monitoring_transform)

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.

Does the monitoring track error rates as well? If yes, we should probably find a way to route the bad inferences here as well.

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.

No error rates at the moment. If that ever changes we could probably add similar optional branching to the DLQ.

explanation_spec: Optional[Any] = None,
output_spec: Optional[Any] = None,
notification_spec: Optional[Any] = None,
credentials: Optional[Any] = None,

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.

Should we accept arbitrary kwargs? That way if any arguments are added in the future, it provides a workaround even if we don't add it to the base beam implementation

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.

Reasonable change, I've plumbed those through.

location=self.location,
credentials=self.credentials,
)
monitors = ml_monitoring.model_monitors.ModelMonitor.list(

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.

Do we need any sort of backoff on this if it isn't found? I'm not sure how long monitors take to create, but what happens if you have 2 DoFns, A and B with setup called at the same time. Could you end up with:

A -> create monitor (starts)
B -> create monitor (fails, conflict)
B -> list monitors (finds nothing, throws)
A -> create monitor (finishes)

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.

In my experience the creation happens pretty quickly, but adding a little backoff in the Conflict case is a reasonable way to mitigate potential race conditions. Added.

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. The failure case isn't that bad since setup would be retried, but it would be nice to avoid an error in this case


if is_streaming:
if not self.cron:
raise ValueError(

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.

Within the current approach, could a user have an existing monitoring job and just point this to populate the correct BQ table? Or is there a reason we couldn't support this?

The cron piece made me think of this since a cron schedule wouldn't be needed if you configured the job already.

This would potentially allow multiple streaming pipelines to feed the same monitoring job (e.g. if you have the same model deployed in multiple regions but wanted a single monitoring job)

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.

In this form yes, but with the caveat that the entire configuration would need to be completely identical. I took a quick run at allowing the omission of a cron schedule to effectively skip the monitoring transform altogether (and log a warning for the user that this happened.) We still route the inferences to the BQ table, but don't worry about anything else.

Comment thread sdks/python/apache_beam/ml/inference/vertex_ai_model_monitoring_v2_it_test.py Outdated

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

Just one more follow up, thanks

location=self.location,
credentials=self.credentials,
)
monitors = ml_monitoring.model_monitors.ModelMonitor.list(

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. The failure case isn't that bad since setup would be retried, but it would be nice to avoid an error in this case

'A cron schedule was not provided, so a monitoring job will not be'
' created. Inferences will still be written to the BigQuery table'
' %s',
self.bigquery_table)

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.

Sorry, should've mentioned this before - can we do a lookup in this case to determine if a job already exists for this model name/version with a cron schedule? If not, then we should at least force a user to specify a value in this case (e.g. cron is not optional, but pass a constant in to skip creation) - otherwise I'd worry about users accidentally falling into this case

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.

2 participants