-
Notifications
You must be signed in to change notification settings - Fork 32
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
Safe sampling feature #801
Conversation
(vector-copy! vprecs 0 vprecs-new) | ||
|
||
; Step 5. If precisions have not changed but the point didn't converge. A problem exists - add slack to every op | ||
(when (false? (vector-member #f vrepeats)) |
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.
if all the precisions are not higher than from previous run
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.
The code is odd but whatever.
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.
I'm OK with merging this, clearly a good PR on net and I don't really want to slow down to fix the mixed-precision bug or add logging. (Though if logging is easy please do add some, just issue a warning with warn
for example.)
(vector-copy! vprecs 0 vprecs-new) | ||
|
||
; Step 5. If precisions have not changed but the point didn't converge. A problem exists - add slack to every op | ||
(when (false? (vector-member #f vrepeats)) |
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.
The code is odd but whatever.
[n (in-range (vector-length vprecs))]) | ||
(define prec* (min (*max-mpfr-prec*) (+ prec slack))) | ||
(when (equal? prec* (*max-mpfr-prec*)) (*sampling-iteration* (*max-sampling-iterations*))) | ||
(vector-set! vprecs n prec*)))) |
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.
I would love it if this logged somewhere, but fine.
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.
Added
@@ -26,7 +26,7 @@ | |||
;; The first element of that function's output tells you if the input is good | |||
;; The other elements of that function's output tell you the output values | |||
(define (make-search-func pre specs ctxs) | |||
(define fns (compile-specs (cons pre specs) (context-vars (car ctxs)))) | |||
(define fns (compile-specs (cons pre specs) (context-vars (car ctxs)) (context-repr (car ctxs)))) |
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.
I think this actually also maybe isn't quite right, since it assumes all outputs use the same repr
. This won't be correct if an expression uses mixed binary32/binary64 code. That said, I'm not too worried about this because I think it'll need to be fixed a different way anyway.
This branch introduces a new feature for sampling which makes sampling safer if an unknown problem exists.
This feature checks whether all the precisions of an expressions have not increased. If this is true - then add slack to every operation.
The feature is pretty simple but can save few points where an unhandled problem occurred.
The branch also fixes small issues as: measuring ulp distance in backward pass with respect to
repr
instead of relying onfloat
, and miscalculating exponent ofmin.bf
inlog2-approx