Skip to content

Conversation

@toprakmurat
Copy link

Summary

This PR adds support for extended basis operations in the OpenFHE dialect, allowing the use of an optimization technique where multiple rotations are performed in a larger (P*Q) CRT basis and combined before a single key_switch_down converts the result back to the normal (Q) basis.

This is groundwork for addressing #2519.

New Operations

Operation Description
openfhe.fast_rotation_ext Fast rotation in extended P*Q basis (defers key switching)
openfhe.key_switch_down Converts ciphertext from extended to normal basis
openfhe.add_ext Addition of ciphertexts in extended basis
openfhe.add_ext_inplace In-place addition in extended basis
openfhe.mul_ext Multiplication in extended basis (uses EvalMultNoRelin)

@toprakmurat
Copy link
Author

I'd appreciate feedback on the operation signatures in OpenfheOps.td (are the arguments and attributes appropriate?), whether we need a distinct type for extended-basis ciphertexts or can reuse Openfhe_Ciphertext, and any concerns with the overall approach before I proceed with implementing the conversion pass and optimization patterns to push key_switch_down later in the IR.

@toprakmurat toprakmurat marked this pull request as ready for review January 25, 2026 14:19
Copy link
Collaborator

@asraa asraa left a comment

Choose a reason for hiding this comment

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

Thank you so much! Great job on starting the tablegen and making a small PR

["isBatchCompatible", "buildBatchedOperation"]>
]> {
let summary = "Fast (hoisted) rotation in extended (P*Q) CRT basis.";
let arguments = (ins
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like from https://github.com/openfheorg/openfhe-development/blob/aa391988d354d4360f390f223a90e0d1b98839d7/src/pke/include/cryptocontext.h#L2438

that the arguments needed are (cryptoContext, input, index, precomputedDigitDecomp, addFirst) - in other words i don't think you neeed cyclotomicOrder anymore.

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1, I submitted the patch to remove that argument, though we should double check it's in the OpenFHE version we're depending on

Copy link
Collaborator

Choose a reason for hiding this comment

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

your patch was only for the regular evalfastrotation, this API was unchanged and i guess never had that m param

MLIRContext* context, OpBuilder& builder,
SmallVector<Value> vectorizedOperands,
SmallVector<Operation*> batchedOperations) {
SmallVector<Value> indexVals;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if you can share a function with EvalFastRotation? The code is very very similar.

@toprakmurat toprakmurat requested a review from asraa January 30, 2026 17:44
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