-
-
Notifications
You must be signed in to change notification settings - Fork 21k
[XPU][UT] Fix OOM and skip graph case #49287
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
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
fe186d6
Fix OOM and skip graph case
mayuyuace 618d49f
Merge branch 'main' into qiming/fix_oom
mayuyuace cf3a149
Merge branch 'main' into qiming/fix_oom
mayuyuace 85925ce
skip ut if graph is disabled
mayuyuace f13394a
merge wait function
mayuyuace 8a5b1d9
Merge branch 'main' into qiming/fix_oom
mayuyuace cd874ca
Merge branch 'main' into qiming/fix_oom
jikunshang 9f3cc3b
Merge branch 'main' into qiming/fix_oom
mayuyuace 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -967,6 +967,21 @@ def __init__( | |
| from tests.utils import wait_for_rocm_memory_to_settle | ||
|
|
||
| wait_for_rocm_memory_to_settle(threshold_ratio=1.0 - gpu_memory_utilization) | ||
| elif current_platform.is_xpu(): | ||
| # The XPU/oneAPI runtime keeps ~1 GiB of context resident in the | ||
| # parent pytest process for its whole lifetime (grown by in-process | ||
| # HfRunner models), and distributed tests additionally allocate a | ||
| # CCL context in the engine subprocess. The default utilization of | ||
| # 0.92 leaves too little headroom for both, so lower it on XPU when | ||
| # the caller did not request an explicit value. | ||
| if "gpu_memory_utilization" not in kwargs: | ||
| kwargs["gpu_memory_utilization"] = 0.9 | ||
| gpu_memory_utilization = kwargs["gpu_memory_utilization"] | ||
| # XPU (Level Zero) can also release device memory lazily after a | ||
| # previous engine shuts down, so wait before constructing LLM. | ||
| from tests.utils import wait_for_xpu_memory_to_settle | ||
|
|
||
| wait_for_xpu_memory_to_settle(threshold_ratio=1.0 - gpu_memory_utilization) | ||
|
|
||
| with init_ctx: | ||
| self.llm = LLM( | ||
|
|
@@ -1301,6 +1316,15 @@ def _wait_for_rocm_memory_release(self, gpu_memory_utilization: float) -> None: | |
| # wait is bounded so cleanup failures fail this test instead of hanging. | ||
| wait_for_rocm_memory_to_settle(threshold_ratio=1.0 - gpu_memory_utilization) | ||
|
|
||
| def _wait_for_xpu_memory_release(self, gpu_memory_utilization: float) -> None: | ||
| from tests.utils import wait_for_xpu_memory_to_settle | ||
|
|
||
| # V1 startup requires free_memory >= total * gpu_memory_utilization. | ||
| # XPU (Level Zero) releases device memory lazily after an engine shuts | ||
| # down, so wait for the complementary used-memory ratio to settle before | ||
| # the next allocation. Bounded so cleanup failures do not hang the suite. | ||
| wait_for_xpu_memory_to_settle(threshold_ratio=1.0 - gpu_memory_utilization) | ||
|
|
||
| def __exit__(self, exc_type, exc_value, traceback): | ||
| # Explicitly shutdown the engine core to release GPU resources | ||
| # This is needed because when executing consecutive tests, the GC | ||
|
|
@@ -1326,6 +1350,7 @@ def __exit__(self, exc_type, exc_value, traceback): | |
| torch._dynamo.reset() | ||
| cleanup_dist_env_and_memory() | ||
| self._wait_for_rocm_memory_release(gpu_memory_utilization) | ||
| self._wait_for_xpu_memory_release(gpu_memory_utilization) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can merge
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Merged. |
||
|
|
||
|
|
||
| @pytest.fixture(scope="session") | ||
|
|
||
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we merge
wait_for_xpu_memory_to_settleand wait_for_rocm_memory_to_settle to single functionwait_for_memory_to_settle?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merged.