-
Notifications
You must be signed in to change notification settings - Fork 28
Conversation
12ebb46
to
a046434
Compare
Codecov Report
@@ Coverage Diff @@
## master #712 +/- ##
==========================================
+ Coverage 61.51% 61.99% +0.47%
==========================================
Files 102 104 +2
Lines 4563 4581 +18
==========================================
+ Hits 2807 2840 +33
+ Misses 1756 1741 -15
Continue to review full report at Codecov.
|
a046434
to
231e875
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, i'm glad that this fixes the precision issues 👍
i left some comments mostly regarding trait streamlining.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A great improvement👍 The code looks much cleaner.
I just added a small note on the Settings
.
8c612eb
to
e8cc298
Compare
e8cc298
to
fba67d2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
expose helpers from model expose more scalar types minor masking adjustment
update set_scalar docstring
fix clippy complaint: ok_or_else remove unnecessary type annotations
regenerate C header file update command for compiling FFI tests
d6fee66
to
1c9dfb6
Compare
The purpose of this PR is two-fold:
test_masking_and_aggregation!
tests, discovered in fix extended coverage of masking tests #542.Currently, scalars are represented as
f64
floats. But since scalars are (since #496) an integral part of the (un)masking process, they should be represented similarly to model weights, namely in "exact" form asRatio
s of big integers.Indeed, the bug mentioned above arises from the inexact nature of scalars: in the
test_masking_and_aggregation!
tests, we take scalars to be a fraction (morally1 / model_count
) which as per the usual limitations of floating point, cannot be represented exactly asf64
in many cases. Subsequently, the error this introduces propagates through the (un)masking process, and leads to failing closeness checks. #542 introduced a workaround by essentially adjustingmodel_count
to a known "good" value.OTOH by working with
f64
scalars, it is easy for clients to construct imprecise (or worse, invalid e.g. negative, NaN) scalars, whether accidentally or maliciously. This could be prevented by insisting that scalars be constructed (or converted) via a safe API that statically guarantees their validity, similar to that ofModel
.Summary of changes:
Scalar
type:Masker::mask
to take ascalar: Scalar
(instead ofscalar: f64
).Scalar
API:Scalar::new(1, model_count)
creates an exact rational scalar1 / model_count
.Scalar::unit()
instead of1.0
.test_masking_and_aggregation!
tests by usingScalar
, and removes workaround.test_xyz_scalar!
families of randomized scalar tests (introduced in randomized scalar tests #589).