Skip to content

remove scheme flag from openfhe emitter#1302

Merged
copybara-service[bot] merged 1 commit into
google:mainfrom
AlexanderViand:openfhe-emitter
Jan 24, 2025
Merged

remove scheme flag from openfhe emitter#1302
copybara-service[bot] merged 1 commit into
google:mainfrom
AlexanderViand:openfhe-emitter

Conversation

@AlexanderViand-Intel

@AlexanderViand-Intel AlexanderViand-Intel commented Jan 23, 2025

Copy link
Copy Markdown

As mentioned in today's meeting, no longer needing to specify the scheme as a flag makes building the compilation/translation pipeline much nicer, especially in the Python frontend.

The scheme flag was really only used for two decisions:

  • in getModulePrelude, to decide whether to emit CryptoContextBGVRNS or CryptoContextCKKSRNS
  • around encode/decode, to decide whether to use getPackedPlaintext or getCKKSPackedPlaintext and to check consistency

The latter use was entirely redundant, as the encoding info on the op (or on the plaintext type of the result/operand) already clearly indicates what should be used. Ensuring consistency is now achieved via verifiers on openfhe.make_packed_plaintext and openfhe.make_ckks_packed_plaintext.

Unfortunately, the first use wasn't quite as easy to get rid of and required introducing a (hopefully somewhat temporary) helper attribute: the --secret-to-<scheme> passes now add an attribute to the module (e.g., {bgv.scheme}) which the openfhe emitter inspects.

@AlexanderViand-Intel AlexanderViand-Intel added the dialect: openfhe Issues related to the openfhe dialect label Jan 23, 2025

@j2kun j2kun 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.

Looks great!

Comment thread lib/Dialect/Secret/Conversions/SecretToBGV/SecretToBGV.cpp Outdated
Comment thread lib/Target/OpenFhePke/OpenFhePkeHeaderEmitter.cpp Outdated
@j2kun j2kun added the pull_ready Indicates whether a PR is ready to pull. The copybara worker will import for internal testing label Jan 24, 2025
@copybara-service copybara-service Bot merged commit 2a4d61c into google:main Jan 24, 2025
@AlexanderViand-Intel AlexanderViand-Intel deleted the openfhe-emitter branch January 28, 2025 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dialect: openfhe Issues related to the openfhe dialect pull_ready Indicates whether a PR is ready to pull. The copybara worker will import for internal testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants