Skip to content

test: direct unit suite for the bias calibrator (42 tests)#1922

Closed
arham766 wants to merge 1 commit into
NVIDIA:mainfrom
arham766:tests/bias-calibrator
Closed

test: direct unit suite for the bias calibrator (42 tests)#1922
arham766 wants to merge 1 commit into
NVIDIA:mainfrom
arham766:tests/bias-calibrator

Conversation

@arham766

@arham766 arham766 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Type of change: new tests

Part of the unit-coverage initiative in #1902. Direct unit suite for modelopt/torch/quantization/calib/bias.py — the last calibrator without one (test_calibrator.py covers Max/Histogram/Entropy/Percentile, test_mse_calibrator.py covers MSE; test_affine_quant.py exercises bias end-to-end but asserts shapes only). Pins the numeric contract with hand-derivations in comments: per-axis maxmin/mean reductions, the call-weighted running average (2→3→5 sequence distinguishing it from element-weighting), running extrema, fp16/bf16 dtype-stabilized aggregation, reset semantics, dynamic-bias statelessness, and TensorQuantizer integration (centered amax = 2 not 9; exact FP8 round-trip of [[99,101],[-101,-99]]). Adversarial review: all derivations re-verified, 3/3 seeded mutations killed (incl. deleting the centering line in tensor_quantizer's collect). Four doc/API inconsistencies documented for follow-up: the axis docstring says dims are kept while the code reduces them; the int|tuple annotation contradicts an iterable-only implementation; compute_bias silently falls through to max_min on unknown methods while its siblings raise; and the config.py bias docstring examples fail their own validate_bias validator (non-int keys rejected) — the documented schema is unusable as written.

Usage

N/A — tests only.

Testing

Hermetic, CPU-only, deterministic, <2s. Combined run with the sibling calib/distill suites green; full tests/unit/torch/quantization dir unaffected. Adversarially reviewed with mutation testing as described above.

Before your PR is "Ready for review"

  • Is this change backward compatible?: ✅
  • If you copied code from any other sources or added a new PIP dependency, did you follow guidance in CONTRIBUTING.md: N/A
  • Did you write any new necessary tests?: ✅
  • Did you update Changelog?: N/A
  • Did you get Claude approval on this PR?: N/A (external contributor)

Additional Information

Issue: #1902

The only prior coverage (test_affine_quant.py) asserts shapes; this
pins the numeric contract: per-axis maxmin/mean reductions, the
call-weighted (not element-weighted) running average, running extrema,
dtype-stabilized aggregation, reset semantics, dynamic-bias
statelessness, and TensorQuantizer integration with hand-computed
centered-amax and an exact FP8 round-trip. Adversarially reviewed:
hand-derivations verified, 3/3 seeded mutations killed.

Documents four doc/API inconsistencies found along the way (axis
docstring says keep, code reduces; int axis contradicts its own
annotation; compute_bias silently falls through on unknown methods;
the config.py bias examples fail their own validator) - reported for
follow-up rather than asserted as desired behavior.

Part of the coverage initiative in NVIDIA#1902.

Signed-off-by: arham766 <arhamislam766@yahoo.com>
@arham766 arham766 requested a review from a team as a code owner July 6, 2026 02:38
@copy-pr-bot

copy-pr-bot Bot commented Jul 6, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@arham766, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 10 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: f94b28d0-f72e-4f46-8c02-86351599dc9c

📥 Commits

Reviewing files that changed from the base of the PR and between b96a785 and 9530da9.

📒 Files selected for processing (1)
  • tests/unit/torch/quantization/test_bias_calib.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@arham766

arham766 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Consolidated into #1927 per maintainer feedback in #1902 — the suite was trimmed to only the lines codecov reports uncovered, with parametrization clusters deduplicated. Closing in favor of that PR.

@arham766 arham766 closed this Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant