LWE: add evaluation key type and technique#1067
LWE: add evaluation key type and technique#1067ZenithalHourlyRate wants to merge 1 commit intogoogle:mainfrom
Conversation
|
Hey! Sorry for the delay - I'm finally back online for development now. |
asraa
left a comment
There was a problem hiding this comment.
Thanks for starting this!
I will explore replacing the BGV / CKKS dialects with the new lwe types in a PR EOW
| } | ||
|
|
||
| def LWE_BVKeySwitchAttr : AttrDef<LWE_Dialect, "BVKeySwitch"> { | ||
| let mnemonic = "bv_keyswitch_technique"; |
There was a problem hiding this comment.
nit: just remove the _technique here and below
| let description = [{ | ||
| An attribute describing the BV technique for keyswitch. | ||
|
|
||
| `base` is the radix base used in decomposition of the coefficient modulus |
There was a problem hiding this comment.
| `base` is the radix base used in decomposition of the coefficient modulus | |
| `base` is the radix base used in the digit decomposition of the coefficient modulus |
|
|
||
| let parameters = (ins | ||
| "IntegerAttr":$base, | ||
| "IntegerAttr":$dnum |
There was a problem hiding this comment.
thank you for considering the RNS variants! I understand it's important to know the dnums so that the type converter knows the type / shape of the key switching key. For the lowering, we'll need the actual RNS moduli, which we'll pull from the RNS modulus of the ring in the keyswitching key, right?
|
|
||
| let assemblyFormat = "`<` struct(params) `>`"; | ||
|
|
||
| // let genVerifyDecl = 1; |
There was a problem hiding this comment.
we could implement the type constraint here.
|
|
||
| let parameters = (ins | ||
| "IntegerAttr":$base, | ||
| "IntegerAttr":$dnum |
There was a problem hiding this comment.
OptionalParameter? (can also update the assembly format for an optional print)
| "KeyAttr":$to_key, | ||
| "::mlir::polynomial::RingAttr":$ring, | ||
| // can not be ArrayRefParameter<"KeySwitchAttr"> | ||
| ArrayRefParameter<"Attribute">:$keyswitch_techniques |
There was a problem hiding this comment.
Why is this an array ref parameter? Wouldn't only a sinlgle technique apply to a given key?
There was a problem hiding this comment.
I intentionally left the HYBRID keyswitching technique as a combination of BV attr and GHS attr, so that we do not have to define another LWE_HYBRIDKeySwitchAttr where all base/dnum/extra_modulus will be included. If we accept such elaboration, then we can define it and here can be a single technique.
|
Please take a moment to let me know the current state of this PR. Is it blocked, or obsolete/closeable? If blocked, please briefly say what needs to be done to unblock it. |
I was thinking of coming back to this when we are going to do some serious thing for the lwe-to-poly pipeline, but did not get the time. Also I think this is somewhat related to #1274, namely how should we design a lwe-level interface for eval keys. If we has lwe types and ops describing eval key related stuff, we do not need that relin/rotate op interface. |
|
There is a Googler who wants to do some 20% project on lowering some schemes to polynomial, so I will ensure he's aware of this work. |
|
We may come back to visit this because we have concrete scheme parameter now (#1379). The current LWE type can not model the evaluation key part so we can not get rid of the I'll rebase this. |
Related to #1057.
I roughly prototyped it from openfhe/pke/keyswitch (BGV/CKKS), yet I do not know if this is accurate for binfhe schemes (CGGI).
Example: