test: direct unit suite for TensorQuantizer with exact-value fake-quant checks (90 tests)#1905
test: direct unit suite for TensorQuantizer with exact-value fake-quant checks (90 tests)#1905arham766 wants to merge 2 commits into
Conversation
…-quant checks Hermetic CPU-only unit tests; adversarially reviewed and verified to kill seeded mutations of the target module. Part of the coverage initiative in NVIDIA#1902. Signed-off-by: arham766 <arhamislam766@yahoo.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR adds a new CPU-only unit test module for ChangesTensorQuantizer test suite
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related issues
🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/unit/torch/quantization/test_tensor_quantizer.py (1)
766-810: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider a fixture for backend registry register/unregister cleanup.
test_register_forward_unregisterandtest_reregister_warnseach hand-roll try/finally registration cleanup forregister_quant_backend/unregister_quant_backend. A small pytest fixture yielding a registered-name helper (with teardown always callingunregister_quant_backend) would remove the duplicated try/finally boilerplate across these tests.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/unit/torch/quantization/test_tensor_quantizer.py` around lines 766 - 810, The backend registry tests duplicate register/unregister cleanup logic in test_register_forward_unregister and test_reregister_warns. Introduce a small pytest fixture in TestQuantBackendRegistry that registers a backend name for each test and always unregisters it in teardown, then update those tests to use the fixture instead of hand-written try/finally blocks around register_quant_backend and unregister_quant_backend.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/unit/torch/quantization/test_tensor_quantizer.py`:
- Around line 766-810: The backend registry tests duplicate register/unregister
cleanup logic in test_register_forward_unregister and test_reregister_warns.
Introduce a small pytest fixture in TestQuantBackendRegistry that registers a
backend name for each test and always unregisters it in teardown, then update
those tests to use the fixture instead of hand-written try/finally blocks around
register_quant_backend and unregister_quant_backend.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 9bc62e74-ebe0-4ae7-a491-b8bfc7bf77f8
📒 Files selected for processing (1)
tests/unit/torch/quantization/test_tensor_quantizer.py
…date header year Signed-off-by: arham766 <arhamislam766@yahoo.com>
What does this PR do?
Type of change: new tests
Part of the unit-coverage initiative in #1902 (one PR per module; this one is self-contained). Covers: the TensorQuantizer class contract directly: 10 hand-computed INT8 exact-value forwards (narrow/unsigned/per-channel/int4/zero-amax), 4 exact FP8 E4M3 cases incl. RNE ties, block quant, fp16/bf16 round-trips, amax/pre_quant_scale get-set semantics, calibration choreography, modelopt_state+state_dict round-trip, STE backward variants, backend registry error paths. All rounding operands verified tie-safe for platform determinism.
Usage
N/A — tests only.
Testing
Suite is hermetic (CPU-only, no network, deterministic, <3s) and passes locally; the full collectable tests/unit tree passes with it (1999 passed). The suite was adversarially reviewed and verified to kill seeded mutations of the target module (details in #1902).
Before your PR is "Ready for review"
Additional Information
Issue: #1902
Summary by CodeRabbit
amaxand pre-quant scale semantics (including state persistence and shape-change safeguards).