Update lower-polynomial-eval to lower to kernel.eval_chebyshev if the backend supports it - #3288
Update lower-polynomial-eval to lower to kernel.eval_chebyshev if the backend supports it#3288copybara-service[bot] wants to merge 1 commit into
Conversation
1dde8bf to
c433480
Compare
… backend supports it In working on this I also realized that polynomial-approximation was being applied to cleartext ops as well, so I restricted it to just apply to secret values, and this required a handful of downstream changes. This is change 5/8 demonstrating a high-level FHE kernel preservation for eval_chebyshev. PiperOrigin-RevId: 958763395
c433480 to
565ec9d
Compare
AlexanderViand
left a comment
There was a problem hiding this comment.
In working on this I also realized that polynomial-approximation was being applied to cleartext ops as well, so I restricted it to just apply to secret values, and this required a handful of downstream changes.
Can we make this a flag? There's that Cambridge student project that used our approximation system for non-FHE/crypto related things, so it might be nice to still be able to approximate cleartext stuff.
| // level. | ||
| double domainLower = getDomainLowerAttr().getValueAsDouble(); | ||
| double domainUpper = getDomainUpperAttr().getValueAsDouble(); | ||
| if (std::abs(domainLower - -1.0) > 1e-9 || |
There was a problem hiding this comment.
I agree with @AlexanderViand in the other PR that I would prefer for the assumption to be that the range is always [-1,1], and we have other operations do the rescaling before/after. Otherwise, this 1e-9 precision could be the source of (very) subtle bugs where the scaling is wrong
| return printBinaryOp(op, op.getLhs(), op.getRhs(), "^"); | ||
| } | ||
|
|
||
| LogicalResult LattigoEmitter::printOperation(math::SqrtOp op) { |
There was a problem hiding this comment.
I don't understand why we start emitting Sqrt. How is this linked to Chebyshev? Is this how Lattigo approximates it?
There was a problem hiding this comment.
Polynomial approximation stopped approximating cleartext ops, and some of our internal test models have cleartext sqrt ops.
Update lower-polynomial-eval to lower to kernel.eval_chebyshev if the backend supports it
In working on this I also realized that polynomial-approximation was being applied to cleartext ops as well, so I restricted it to just apply to secret values, and this required a handful of downstream changes.
This is change 5/8 demonstrating a high-level FHE kernel preservation for eval_chebyshev.