Convert SmoothQuant test to unittest - #2659
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/2659
Note: Links to docs will display an error until the docs builds have been completed. ❌ 2 New Failures, 1 Cancelled JobAs of commit 7217f8f with merge base 8d4a5d8 ( NEW FAILURES - The following jobs have failed:
CANCELLED JOB - The following job was cancelled. Please retry:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@namgyu-youn if you are interested in contributing more, making smoothquant API similar to AWQ (#2400) is a good task we are planning to graduate these two features to official support |
@jerryzh168 Thanks for your suggestion. I will look into it before resolving more #1621 . Also, could you check #2644? It fixes part of #1621 (same as this PR). |
| cls.quant_mode_options = ["static", "dynamic"] | ||
| cls.devices = ["cpu"] + (["cuda"] if torch.cuda.is_available() else []) | ||
| cls.input_dtypes = (torch.float, torch.bfloat16, torch.half) | ||
| def _setup_quantized_model(self, model, alpha, quant_mode, calibration_data): |
There was a problem hiding this comment.
I feel it's probably fine to inline these as well, there are not many lines of code here
| """Test the margin error of SmoothQuant across bias, alpha, dtype, etc.""" | ||
| self._run_compute_accuracy_test(bias, alpha, quant_mode, device, input_dtype) | ||
|
|
||
| def _run_compute_accuracy_test(self, bias, alpha, quant_mode, device, input_dtype): |
There was a problem hiding this comment.
nit: can also remove this function, seems no need to define a function here
There was a problem hiding this comment.
Thanks, those functions are undefined for more brevity in 3ffdd10 .
| f"device={device}, dtype={input_dtype}", | ||
| ) | ||
|
|
||
| def _compute_reference_out(self, m_ref, data, alpha, quant_mode, bias, input_dtype): |
There was a problem hiding this comment.
if it's used only once, I'd suggest not to define new functions
| """Test save/load recipe functionality.""" | ||
| self._run_save_load_recipe_test(alpha, quant_mode, device, input_dtype) | ||
|
|
||
| def _run_save_load_recipe_test(self, alpha, quant_mode, device, input_dtype): |
- Uncorrect API usage ( `common_utils`) is fixed
| """Set up class-level configuration for tests.""" | ||
| # Skip tests on ROCm (AMD GPU) due to compatibility issues | ||
| if torch.version.hip is not None: | ||
| raise unittest.SkipTest("Skipping the tests in ROCm") |
There was a problem hiding this comment.
nit: does unittest.skip(...) work?
There was a problem hiding this comment.
@jerryzh168 https://docs.pytorch.org/docs/stable/notes/hip.html shows how torch.version.hip works. It is None in CUDA, str (ROCm version) in ROCm, and None in CPU-only. That is, this test is skipped only when ROCm available.
There was a problem hiding this comment.
oh I mean using unittest.skip instead of raise the SkipTest error
There was a problem hiding this comment.
I see, but there is no conditioner in the unittest.skip . How about using unittest.skipif? See https://docs.python.org/3/library/unittest.html#unittest.skipIf for the reference, and I like this change because the code can be more brevity
There was a problem hiding this comment.
yeah sounds good, thanks
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Merge failedReason: 3 jobs have failed, first few of them are: Run Regression Tests / test-nightly (CPU Nightly, linux.4xlarge, --pre torch --index-url https://download.pytorch.org/wh... / linux-job, Run Regression Tests / test-nightly (CUDA Nightly, linux.g5.12xlarge.nvidia.gpu, --pre torch --index-url https://downloa... / linux-job, Run 1xH100 Tests / test (H100, linux.aws.h100, --pre torch torchvision torchaudio --index-url https://download.pytor... / linux-job Details for Dev Infra teamRaised by workflow job |
* Convert SmoothQuant test to unittest * refactor using `common_utils.parametrize` decorator * incline quantizaztion setup function * undefine only-one time used functions - Uncorrect API usage ( `common_utils`) is fixed * replace unittest.SkipTest with unittest.skipIf
Fix part of #1621
Migrate test file (
test/prototype/test_smoothquant.py) framework from pytest to unittest.