You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Coverage] Direct unit-test suites for five untested core modules (conversion, core_utils, tensor_quantizer, model_calib, export/postprocess) — plus bugs found along the way #1902
While auditing test coverage, we found that several load-bearing modules have no direct unit-test file — they are exercised only incidentally through higher-level flows. We wrote hermetic, CPU-only unit suites (per CONTRIBUTING's tests/unit rules: fast, no network, no GPU) for five of them, adversarially reviewed and mutation-checked each suite, and will attach one PR per module so each is reviewable in isolation:
397 tests, ~4.2k lines, total runtime ~5s. Each suite was verified to kill seeded mutations of its target (wrong scale direction, flipped split axes, broken running-max, etc.), so this is regression-detection capacity, not line-count.
Bugs found while writing these (documented in-test with NOTE: documents current behavior comments; happy to file/fix separately as preferred)
_normalize_fused_experts_quantizer_name collides with SequentialQuantizer child names (introduced in [NVBug 6108145] Fix PTQ calibration and export for fused-experts MoE (Qwen3.5-MoE VLM) #1340: the singular weight_quantizer.<N> pattern matches sequential children). Two consequences, both reproduced: (a) applying the same list-of-configs twice via set_quantizer_attributes_full nests SequentialQuantizers inside sub-slots (non-idempotent, corrupt state); (b) set_quantizer_attributes_partial with a list and a *weight_quantizer wildcard now raises ValueError mid-iteration for targets that are already sequential — a regression against its own docstring. Suggested fix: skip normalization when the matched quantizer's parent is a SequentialQuantizer.
awq() silently no-ops on an unknown algorithm string (public __all__ API; only the mtq.quantize config layer validates the literal). One-line raise ValueError in an else would match the module's fail-fast style.
TensorQuantizer.extra_repr dead code: the disabled branch builds a detailed string, then returns the literal "disabled", discarding it.
update_lm_head_quantization warns "Enable lm_head quantization" even when quantizers are already disabled, and its sole call site (model_config_export.py:323) appears to pass inference_pipeline_parallel into the inference_tensor_parallel parameter.
Minor exception-safety inconsistencies: replace_function/calibrate_with_adapters/enable_fake_quant yield without try/finally (unlike export_torch_mode et al.), so an exception mid-context leaks the patched state.
The behavior-documenting tests are written to fail-and-force-update when these are fixed.
PRs
Will be linked below, one per module, each self-contained.
Summary
While auditing test coverage, we found that several load-bearing modules have no direct unit-test file — they are exercised only incidentally through higher-level flows. We wrote hermetic, CPU-only unit suites (per CONTRIBUTING's tests/unit rules: fast, no network, no GPU) for five of them, adversarially reviewed and mutation-checked each suite, and will attach one PR per module so each is reviewable in isolation:
torch/quantization/conversion.pytorch/quantization/utils/core_utils.pytorch/quantization/nn/modules/tensor_quantizer.pytorch/quantization/model_calib.pytorch/export/postprocess.py397 tests, ~4.2k lines, total runtime ~5s. Each suite was verified to kill seeded mutations of its target (wrong scale direction, flipped split axes, broken running-max, etc.), so this is regression-detection capacity, not line-count.
Bugs found while writing these (documented in-test with
NOTE: documents current behaviorcomments; happy to file/fix separately as preferred)_normalize_fused_experts_quantizer_namecollides withSequentialQuantizerchild names (introduced in [NVBug 6108145] Fix PTQ calibration and export for fused-experts MoE (Qwen3.5-MoE VLM) #1340: the singularweight_quantizer.<N>pattern matches sequential children). Two consequences, both reproduced: (a) applying the same list-of-configs twice viaset_quantizer_attributes_fullnestsSequentialQuantizers inside sub-slots (non-idempotent, corrupt state); (b)set_quantizer_attributes_partialwith a list and a*weight_quantizerwildcard now raisesValueErrormid-iteration for targets that are already sequential — a regression against its own docstring. Suggested fix: skip normalization when the matched quantizer's parent is aSequentialQuantizer.awq()silently no-ops on an unknown algorithm string (public__all__API; only themtq.quantizeconfig layer validates the literal). One-lineraise ValueErrorin an else would match the module's fail-fast style.TensorQuantizer.extra_reprdead code: the disabled branch builds a detailed string, then returns the literal"disabled", discarding it.update_lm_head_quantizationwarns "Enable lm_head quantization" even when quantizers are already disabled, and its sole call site (model_config_export.py:323) appears to passinference_pipeline_parallelinto theinference_tensor_parallelparameter.replace_function/calibrate_with_adapters/enable_fake_quantyield without try/finally (unlikeexport_torch_modeet al.), so an exception mid-context leaks the patched state.The behavior-documenting tests are written to fail-and-force-update when these are fixed.
PRs
Will be linked below, one per module, each self-contained.