-
Notifications
You must be signed in to change notification settings - Fork 201
Support xpu timer metric collection. #1285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
samplise
merged 20 commits into
intelligent-machine-learning:master
from
BalaBalaYi:support_xpu_timer_metric_collection
Oct 10, 2024
Merged
Changes from 8 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
e553713
stash
BalaBalaYi 43e6fa0
Merge remote-tracking branch 'origin/master' into support_xpu_timer_m…
BalaBalaYi ae35035
stash
BalaBalaYi 45265cd
done agent metric report
BalaBalaYi c466722
merge training log impl
BalaBalaYi 699e34c
done agent metric report
BalaBalaYi ef5b6b0
Merge remote-tracking branch 'origin/master' into support_xpu_timer_m…
BalaBalaYi d9986ab
revert
BalaBalaYi 15682a3
optimize arc
BalaBalaYi 483e347
lint
BalaBalaYi dc0b5cb
lint
BalaBalaYi f516541
optimize
BalaBalaYi 180c470
optimize
BalaBalaYi 0cdf261
fix
BalaBalaYi 831d619
revert
BalaBalaYi aa44f9c
refactored
BalaBalaYi 38ba7f5
fix ut
BalaBalaYi 993b679
lint
BalaBalaYi eee22f1
fix ut
BalaBalaYi 0613676
fix ut
BalaBalaYi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 0 additions & 32 deletions
32
dlrover/python/diagnosis/datacollector/cuda_log_collector.py
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
dlrover/python/diagnosis/datacollector/xpu_timer_metric_collector.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| # Copyright 2024 The DLRover Authors. All rights reserved. | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import requests | ||
|
|
||
| from dlrover.python.common import env_utils | ||
| from dlrover.python.common.log import default_logger as logger | ||
| from dlrover.python.diagnosis.common.constants import EnvConfigKey | ||
| from dlrover.python.diagnosis.datacollector.metrics_collector import ( | ||
| MetricsCollector, | ||
| ) | ||
|
|
||
|
|
||
| class XpuTimerMetricsCollector(MetricsCollector): | ||
| def __init__(self): | ||
| """ | ||
| MetricsCollector collects GPU metrics from xpu-timer. | ||
| """ | ||
| super().__init__() | ||
| self._metric_port = env_utils.get_env(EnvConfigKey.XPU_TIMER_PORT) | ||
| if self._metric_port: | ||
| self._metric_endpoint = ( | ||
| "http://127.0.0.1:" + self._metric_port + "/metrics" | ||
| ) | ||
| else: | ||
| self._metric_endpoint = None | ||
|
|
||
| def collect_data(self) -> str: | ||
| if not self.is_enabled(): | ||
| return "" | ||
|
|
||
| try: | ||
| response = requests.get(self._metric_endpoint) | ||
| response.raise_for_status() | ||
|
|
||
| # data preprocessing | ||
| return self._preprocess_metrics(response.text) | ||
| except requests.exceptions.RequestException as e: | ||
| logger.warning( | ||
| "Error fetching metrics from " | ||
| f"xpu-timer: {self._metric_endpoint}, error: {e}" | ||
| ) | ||
| return "" | ||
|
|
||
| def _preprocess_metrics(self, metric_str): | ||
| try: | ||
| metric_list = [ | ||
| line | ||
| for line in metric_str.splitlines() | ||
| if not line.startswith("#") and not line.startswith("exposer") | ||
| ] | ||
| return "\n".join(metric_list) | ||
| except Exception as e: | ||
| logger.warning(f"Error preprocessing metrics from xpu-timer: {e}") | ||
| return "" | ||
|
|
||
| def is_enabled(self) -> bool: | ||
| return self._metric_endpoint is not None |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.