Skip to content

CKKS: basis conversion and modulus switching #2987

Description

@bencemali

While having a look at the CKKS key switch lowering, I noticed that the last step (Step 4: Remove the key-switch primes) incorrectly performs an LWE level basis conversion op from QP to Q instead of a modulus switch from QP to Q. These operations would correspond to Conv (basis conversion) and ModDown (modulus switching) in Appendix A of Faster Bootstrapping for CKKS with Less Modulus Consumption.

While investigating how ModDown could be implemented I also found the following:

I propose the following fixes:

  • Remove the LWE level basis conversion op. The direct translation from LWE basis conversion to RNS basis conversion is an indication that basis conversion should live in the RNS dialect and not the LWE one.
  • Define a ModUp (basis extension from Q to QP) and a ModDown (modulus switching from QP to Q) operation on the LWE dialect following the standard naming convention from Section 2.2 of HK19. These ops will use the RNS level base conversion when lowered.
  • Replace the usages (basis extension and modulus switching) of the current LWE level basis conversion with the newly added ModUp and ModDown ops.
  • Reimplement the RNS level basis conversion lowering to use the fast base conversion algorithm (Section 2.2), which is the standard algorithm used in CKKS (hybrid) key switching implementations. The Garner's algorithm implementation could optionally be kept as an exact basis conversion algorithm.

If you think this is a good direction I can start putting together PRs for these. I am not confident about the compiler/MLIR side of things, so any suggestions are welcome.

tagging @AlexanderViand, @crockeea, @j2kun

Metadata

Metadata

Assignees

No one assigned

    Labels

    dialect: lweIssues about the LWE dialect

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions