Skip to content

Update lower-polynomial-eval to lower to kernel.eval_chebyshev if the backend supports it - #3288

Open
copybara-service[bot] wants to merge 1 commit into
mainfrom
test_958763395
Open

Update lower-polynomial-eval to lower to kernel.eval_chebyshev if the backend supports it#3288
copybara-service[bot] wants to merge 1 commit into
mainfrom
test_958763395

Conversation

@copybara-service

@copybara-service copybara-service Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

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.

@copybara-service
copybara-service Bot force-pushed the test_958763395 branch 5 times, most recently from 1dde8bf to c433480 Compare August 5, 2026 04:38
… 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

@AlexanderViand AlexanderViand left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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 ||

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't understand why we start emitting Sqrt. How is this linked to Chebyshev? Is this how Lattigo approximates it?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Polynomial approximation stopped approximating cleartext ops, and some of our internal test models have cleartext sqrt ops.

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.

3 participants