Skip to content

[ML] Trained Models: Count tests run against trained models#212927

Merged
rbrtj merged 10 commits intoelastic:mainfrom
rbrtj:ml-count-tests-run-against-trained-models
Mar 10, 2025
Merged

[ML] Trained Models: Count tests run against trained models#212927
rbrtj merged 10 commits intoelastic:mainfrom
rbrtj:ml-count-tests-run-against-trained-models

Conversation

@rbrtj
Copy link
Contributor

@rbrtj rbrtj commented Mar 3, 2025

Part of: #200725
This PR adds EBT for tests (success and failed) run against trained models.

@rbrtj rbrtj added :ml release_note:skip Skip the PR/issue when compiling release notes Feature:3rd Party Models ML 3rd party models Team:ML Team label for ML (also use :ml) t// backport:version Backport to applied version labels v9.1.0 v8.19.0 labels Mar 3, 2025
@rbrtj rbrtj self-assigned this Mar 3, 2025
@rbrtj rbrtj requested a review from a team as a code owner March 3, 2025 14:30
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

PR Overview

This PR adds UI counters to track the number of tests run against trained models (both success and failure) by updating usage events and passing the MlUsageCollection dependency to various inference modules.

  • Added new ML usage event constants for test events in the constants file.
  • Updated the inference classes and their constructors to accept and use MlUsageCollection.
  • Modified UI components and service hooks to supply the new dependency to model inference instances.

Reviewed Changes

File Description
x-pack/platform/plugins/shared/ml/common/constants/usage_collection.ts Adds new usage event constants for test counters.
x-pack/platform/plugins/shared/ml/public/application/model_management/test_models/models/inference_base.ts Updates runInfer method to count test events using mlUsageCollection.
x-pack/platform/plugins/shared/ml/public/application/services/usage_collection.ts Exports the MlUsageCollection type to support dependency injection.
x-pack/platform/plugins/shared/ml/public/application/model_management/test_models/selected_model.tsx Retrieves and passes mlUsageCollection to the inference model constructors.
Other inference modules (ner, text classification, lang ident, text embedding, question answering, zero shot, text expansion, fill mask) Their constructors are updated to receive mlUsageCollection and pass it to the superclass.

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

x-pack/platform/plugins/shared/ml/common/constants/usage_collection.ts:15

  • [nitpick] The constant name is plural (TESTED_TRAINED_MODELS) but its value is singular ('tested_trained_model'); consider aligning these for consistency.
TESTED_TRAINED_MODELS: 'tested_trained_model',

x-pack/platform/plugins/shared/ml/public/application/model_management/test_models/models/inference_base.ts:317

  • Instead of using hardcoded event strings, consider using the defined constants (e.g., ML_USAGE_EVENT.TESTED_TRAINED_MODELS) to ensure consistency across the codebase.
this.mlUsageCollection.count('tested_trained_model');

@rbrtj rbrtj requested a review from Copilot March 3, 2025 14:36
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

PR Overview

This PR integrates UI counters for tracking the number of tests run against trained models by adding new usage event constants and wiring up usage collection calls into the inference workflows.

  • Added two new usage event constants (“tested_trained_model” and “test_failed_trained_model”) to support tracking the tests.
  • Injected and utilized the mlUsageCollection dependency into various inference models to record UI counter events on success and error paths.
  • Updated the usage collection service to export a type for mlUsageCollection, ensuring type consistency across the plugin.

Reviewed Changes

File Description
x-pack/platform/plugins/shared/ml/common/constants/usage_collection.ts Added new usage event constants for tracking trained model tests.
x-pack/platform/plugins/shared/ml/public/application/model_management/test_models/models/inference_base.ts Integrated mlUsageCollection counting in the runInfer method for both success and failure scenarios.
x-pack/platform/plugins/shared/ml/public/application/services/usage_collection.ts Exported the MlUsageCollection type from the usage collection provider.
x-pack/platform/plugins/shared/ml/public/application/model_management/test_models/selected_model.tsx Updated usage context extraction and passed mlUsageCollection to inference model constructors.
Other model files (text_embedding, ner, text_classification, lang_ident, question_answering, zero_shot_classification, text_expansion, fill_mask) Updated constructors to accept the mlUsageCollection dependency and pass it on to their super class.

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

protected readonly inputType: INPUT_TYPE,
protected readonly deploymentId: string
protected readonly deploymentId: string,
protected readonly mlUsageCollection: MlUsageCollection
Copy link
Member

Choose a reason for hiding this comment

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

This isn't used in any of the derived classes and so could be private

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 5704fb9

DEFAULT_INFERENCE_TIME_OUT
)) as unknown as TRawInferResponse;

this.mlUsageCollection.count('tested_trained_model');
Copy link
Member

@jgowdyelastic jgowdyelastic Mar 4, 2025

Choose a reason for hiding this comment

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

Although it's good to have counts for when testing has been performed. I think it would be a lot more valuable to also track additional information, such as the model type and pytorch task type.

Copy link
Contributor

Choose a reason for hiding this comment

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

I assume we need event-based telemetry for that

Copy link
Contributor Author

@rbrtj rbrtj Mar 4, 2025

Choose a reason for hiding this comment

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

After short discussion with @peteharverson, we agreed to collect EBT events with all relevant data, updated in: 5704fb9

@rbrtj rbrtj marked this pull request as draft March 4, 2025 13:58
@rbrtj rbrtj marked this pull request as ready for review March 4, 2025 14:44
@rbrtj rbrtj requested a review from jgowdyelastic March 4, 2025 15:10
Copy link
Member

@jgowdyelastic jgowdyelastic left a comment

Choose a reason for hiding this comment

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

LGTM

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
ml 5.3MB 5.3MB +415.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
ml 79.0KB 79.6KB +588.0B

History

cc @rbrtj

Copy link
Contributor

@darnautov darnautov left a comment

Choose a reason for hiding this comment

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

LGTM

@rbrtj rbrtj merged commit 6a184b4 into elastic:main Mar 10, 2025
9 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/13764925902

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Mar 10, 2025
…212927)

Part of: elastic#200725
This PR adds UI Counters for tests (success and failed) run against
trained models.

(cherry picked from commit 6a184b4)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Mar 10, 2025
…12927) (#213727)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[ML] Trained Models: Count tests run against trained models
(#212927)](#212927)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Robert
Jaszczurek","email":"92210485+rbrtj@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-03-10T12:42:30Z","message":"[ML]
Trained Models: Count tests run against trained models (#212927)\n\nPart
of: https://github.com/elastic/kibana/issues/200725\nThis PR adds UI
Counters for tests (success and failed) run against\ntrained
models.","sha":"6a184b4b4bda6a510f07bf66faa4478c7fe9eb05","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":[":ml","release_note:skip","Feature:3rd
Party
Models","Team:ML","backport:version","v9.1.0","v8.19.0"],"title":"[ML]
Trained Models: Count tests run against trained
models","number":212927,"url":"https://github.com/elastic/kibana/pull/212927","mergeCommit":{"message":"[ML]
Trained Models: Count tests run against trained models (#212927)\n\nPart
of: https://github.com/elastic/kibana/issues/200725\nThis PR adds UI
Counters for tests (success and failed) run against\ntrained
models.","sha":"6a184b4b4bda6a510f07bf66faa4478c7fe9eb05"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/212927","number":212927,"mergeCommit":{"message":"[ML]
Trained Models: Count tests run against trained models (#212927)\n\nPart
of: https://github.com/elastic/kibana/issues/200725\nThis PR adds UI
Counters for tests (success and failed) run against\ntrained
models.","sha":"6a184b4b4bda6a510f07bf66faa4478c7fe9eb05"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Robert Jaszczurek <92210485+rbrtj@users.noreply.github.com>
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Mar 22, 2025
…212927)

Part of: elastic#200725
This PR adds UI Counters for tests (success and failed) run against
trained models.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels Feature:3rd Party Models ML 3rd party models :ml release_note:skip Skip the PR/issue when compiling release notes Team:ML Team label for ML (also use :ml) t// v8.19.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants