Repository navigation
test: stop the harness pinning PYTORCH_ALLOC_CONF over the backend default (#4821) - #4838
Merged
Qubitium merged 1 commit intoNov 17, 2026
Merged
Conversation
…fault (ModelCloud#4821) `tests/models/model_test.py` assigned `PYTORCH_ALLOC_CONF=expandable_segments:True,max_split_size_mb:256,garbage_collection_threshold:0.7` unconditionally at import, and `tests/test_awq_weight_mean.py` / `tests/test_quant_formats.py` did the same. About 250 test modules import `ModelTest`, directly or through `tests/awq_test_utils.py`, so a plain `pytest` run replaced the allocator configuration before CUDA was initialised. That overrode two things it should not have: - the value a caller already set, and - `gptqmodel/_alloc_conf.py`, which installs the documented per-backend default at import and is the only place that knows ROCm must never enable `expandable_segments`. On ROCm 10.1 / gfx1201 the VMM segment release/remap inside `empty_cache()` corrupts ordinary Torch results, so every ROCm test that touches `ModelTest` ran with the configuration the project documents as unsafe. `tests/test_qqq.py` was one of them. The harness now leaves the variable alone; `gptqmodel`'s import hook applies the CUDA default on CUDA, the ROCm default on ROCm, and defers to the caller either way. `tests/benchmark/benchmark_test.py` keeps its explicit pin: benchmark runs compare allocator settings on purpose, and changing a recorded baseline is a separate decision. Tests - `test_harness_import_preserves_the_caller_alloc_conf` fails on the parent commit (`assert 'expandable_s...threshold:0.7' == 'max_split_size_mb:512'`) and passes here; it runs on any backend. - `test_harness_import_keeps_the_rocm_safe_default` asserts the harness import leaves `ROCM_DEFAULT_ALLOC_CONF` in place on a real ROCm build. - On an idle R9700 (gfx1201, ROCm 10.1, torch 2.16.0.dev+rocm10.1), `tests/test_rocm_default_env.py -k "harness or import_installs"` is 3 passed, including the two new harness tests. - On CUDA, importing the harness now yields the documented default (`expandable_segments:True`) instead of the old three-knob string.
Collaborator
Author
|
Real-hardware confirmation of the root cause, on an idle Radeon AI PRO R9700 (gfx1201, ROCm 10.1, torch 2.16.0.dev+rocm10.1): On the parent commit the same test, alone on the same idle card, fails in ~34 s with which is the allocator-corruption signature #4821 section 4 describes. With the harness no longer pinning Also confirmed the two directions of the deferral on the card:
This should also clear the |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #4821.
tests/models/model_test.pyassignedunconditionally at import;
tests/test_awq_weight_mean.pyandtests/test_quant_formats.pydid the same. Roughly 250 test modules importModelTest(directly or viatests/awq_test_utils.py), so a plainpytestrun replaced the allocator configuration before CUDA was initialised.That overrode two things it should not have:
gptqmodel/_alloc_conf.pydeliberately defers to a configuration the caller already set.gptqmodel/_alloc_conf.pyis the only place that knows ROCm must never enableexpandable_segments(on ROCm 10.1 / gfx1201 the VMM segment release/remap insideempty_cache()corrupts ordinary Torch results). Every ROCm test that touchesModelTesttherefore ran with the configuration the project documents as unsafe —tests/test_qqq.pyamong them.The harness now leaves the variable alone.
gptqmodel's import hook applies the CUDA default on CUDA, the ROCm default on ROCm, and defers to the caller either way.tests/benchmark/benchmark_test.pykeeps its explicit pin: benchmark runs compare allocator settings on purpose, and changing a recorded baseline is a separate decision.Verification
test_harness_import_preserves_the_caller_alloc_confassert 'expandable_s...threshold:0.7' == 'max_split_size_mb:512')test_rocm_default_env.py(CUDA host)test_alloc_conf.py(CUDA host)test_rocm_default_env.py -k "harness or import_installs"(idle R9700)expandable_segments:True,max_split_size_mb:256,garbage_collection_threshold:0.7expandable_segments:True(DEFAULT_ALLOC_CONF)expandable_segments:True,...max_split_size_mb:256,garbage_collection_threshold:0.7(ROCM_DEFAULT_ALLOC_CONF)The two new tests are in
tests/test_rocm_default_env.py:test_harness_import_preserves_the_caller_alloc_conf— backend-independent; the child process setsPYTORCH_ALLOC_CONF=max_split_size_mb:512, importstests.models.model_test, and asserts the value survives.test_harness_import_keeps_the_rocm_safe_default— ROCm-only; asserts the harness import leavesROCM_DEFAULT_ALLOC_CONFin place with noexpandable_segments.🤖 Generated with Claude Code