-
Notifications
You must be signed in to change notification settings - Fork 202
[Tests] Add tests for "quantization_w4a4_fp4" examples #1715
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
+53
−0
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ebab63f
add TestQuantizationW4A4_FP4 test cases
derekk-nm 9c673b2
str to json!
derekk-nm 71d2e79
Look for generated data in tmp_path
dbarbuzzi ad11b26
Simplify parametrization
dbarbuzzi bd3cfaf
Filter out files from rglob results
dbarbuzzi 273a7d3
Merge branch 'main' into derekk/nvfp4-example-tests
dbarbuzzi 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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import json | ||
from pathlib import Path | ||
from typing import List | ||
|
||
import pytest | ||
|
||
from tests.examples.utils import ( | ||
copy_and_run_script, | ||
gen_cmd_fail_message, | ||
requires_gpu_count, | ||
) | ||
|
||
|
||
@pytest.fixture | ||
def example_dir() -> str: | ||
return "examples/quantization_w4a4_fp4" | ||
|
||
|
||
@requires_gpu_count(1) | ||
@pytest.mark.example | ||
class TestQuantizationW4A4_FP4: | ||
""" | ||
Tests for examples in the "quantization_w4a4_fp4" example folder. | ||
""" | ||
|
||
@pytest.mark.parametrize( | ||
("script_filename"), | ||
[ | ||
pytest.param("llama3_example.py"), | ||
pytest.param("llama4_example.py"), | ||
pytest.param("qwen_30b_a3b.py"), | ||
], | ||
) | ||
def test_quantization_w4a4_fp4_example_script( | ||
self, script_filename: str, example_dir: str, tmp_path: Path | ||
): | ||
""" | ||
Tests the example scripts in the folder. | ||
""" | ||
command, result = copy_and_run_script(tmp_path, example_dir, script_filename) | ||
|
||
assert result.returncode == 0, gen_cmd_fail_message(command, result) | ||
|
||
# verify the expected directory was generated | ||
nvfp4_dirs: List[Path] = list(tmp_path.rglob("*-NVFP4")) | ||
dbarbuzzi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
assert ( | ||
len(nvfp4_dirs) | ||
) == 1, f"did not find exactly one generated folder: {nvfp4_dirs}" | ||
|
||
# verify the format in the generated config | ||
config_json = json.loads((nvfp4_dirs[0] / "config.json").read_text()) | ||
config_format = config_json["quantization_config"]["format"] | ||
assert config_format == "nvfp4-pack-quantized" |
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.