Skip to content

Commit 83d2b06

Browse files
committed
test: Added MX test for default config + qmodel_prep
Signed-off-by: Brandon Groth <[email protected]>
1 parent 6e4431c commit 83d2b06

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/models/test_mx.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,30 @@ def test_residualMLP(
134134
assert module.mx_specs["a_elem_format"] == mx_format
135135

136136
assert found_qmodule_mx
137+
138+
139+
@pytest.mark.skipif(
140+
not available_packages["mx"],
141+
reason="Skipping mx_specs error test; No package found",
142+
)
143+
def test_mx_specs_after_qconfig_init(
144+
model_residualMLP: torch.nn.Module,
145+
input_residualMLP: torch.FloatTensor,
146+
config_fp32: dict,
147+
):
148+
"""
149+
Test if a default config w/ MX qmodes trigger setting mx_specs inside qmodel_prep
150+
151+
Args:
152+
model_residualMLP (torch.nn.Module): Single fp32 model.
153+
input_residualMLP (torch.FloatTensor): Random 16x128 tensor.
154+
config_fp32 (dict): Config w/ fp32 settings.
155+
"""
156+
config_fp32["qa_mode"] = "mx_fp8_e5m2"
157+
config_fp32["qw_mode"] = "mx_fp8_e5m2"
158+
159+
assert "mx_specs" not in config_fp32
160+
161+
qmodel_prep(model_residualMLP, input_residualMLP, config_fp32, use_dynamo=True)
162+
163+
assert "mx_specs" in config_fp32

0 commit comments

Comments
 (0)