Skip to content
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

Enhanced testing of minifloat formats #1136

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from

Conversation

nickfraser
Copy link
Collaborator

Reason for this PR

An enhanced test suite of minifloat formats to address #1126.

Changes Made in this PR

The enhanced test suite generates 10000 random valid minifloat formats / values and checks that Brevitas produces the identical output. Float64 is used for arithmetic to avoid rounding errors in log2, exp2 computations.

Testing Summary

Tests run and pass locally, e.g.:

pytest --hypothesis-verbosity=verbose --hypothesis-show-statistics -n logical tests/brevitas/core/test_float_quant.py::test_valid_float_values
tests/brevitas/core/test_float_quant.py::test_valid_float_values
[gw0] [100%] PASSED tests/brevitas/core/test_float_quant.py::test_valid_float_values
tests/brevitas/core/test_float_quant.py::test_valid_float_values:

  - during generate phase (25.89 seconds):
    - Typical runtimes: ~ 1-2 ms, of which < 1ms in data generation
    - 10000 passing examples, 0 failing examples, 0 invalid examples

  - Stopped because settings.max_examples=10000

Risk Highlight

Only tests added. No change in brevitas code itself. Zero risks IMO.

Checklist

  • Code comments added to any hard-to-understand areas, if applicable.
  • Changes generate no new warnings.
  • Updated any relevant tests, if applicable.
  • No conflicts with destination dev branch.
  • I reviewed my own code changes.
  • Initial CI/CD passing.
  • 1+ reviews given, and any review issues addressed and approved.
  • Post-review full CI/CD passing.

@given(
minifloat_format_and_value=random_minifloat_format_and_value(
min_bit_width=4, max_bit_with=10, rand_exp_bias=True))
@settings(max_examples=10000)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Giuseppe5, any thoughts on a good value here? Maybe 1000 is a good compromise between confidence and test time...

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