Skip to content

Conversation

@crockeea
Copy link
Collaborator

This commit reorganizes CKKS lowerings a bit in preparation for a full implementation of CKKS in HEIR.

As a warm up (for me; this is my first PR) I change the RelinearizeOp lowering (CKKS->Polynomial) into a CKKS transform. This required the addition of a few new CKKSOps. KeySwitchInner was raised from Polynomial dialect to the CKKS dialect.

I also introduced a new LWE type: LWERingElt representing an (abstract) ring element. This allows ops to deal with ring elements without worrying about their representation (e.g., as a polynomial or in evaluation form).

Since my next PR will focus on a transformation for KeySwitchInner, I didn't bother fixing up what we had written before; I just deleted it.

As this is my first PR, I strongly encourage nits. Pay special attention to build files, as I have no idea what I'm doing.

@crockeea crockeea requested a review from j2kun January 30, 2026 23:56
@google-cla
Copy link

google-cla bot commented Jan 30, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@crockeea
Copy link
Collaborator Author

crockeea commented Jan 31, 2026

I'm working on the CLA. I copied the structure of the transform (using Passes.*, Patterns.*, and <MyTransform>.* from TensorExt/Transforms, but I can't say I entirely understand the purpose of splitting it up this way. In particular, it's not clear that Patterns.* adds anything, and maybe that code should be incorporated directly into <MyTransform>.*. Thoughts?

…stead being transformed within the CKKS dialect
@AlexanderViand
Copy link
Collaborator

Woohoo, nice to see your first PR 🎉 Since you’re asking for nits: I noticed that the pre-commit checks are failing, so you probably need to do https://heir.dev/docs/development/#pre-commit :)

I'm working on the CLA. I copied the structure of the transform (using Passes., Patterns., and .* from TensorExt/Transforms, but I can't say I entirely understand the purpose of splitting it up this way. In particular, it's not clear that Patterns.* adds anything, and maybe that code should be incorporated directly into .*. Thoughts?

The separate files are mostly an artifact of the TableGen (*.td) to C++ conversion, where it’s usually easier to have every type of TableGen definable thing (Dialect(s), Operations, Types, Passes, Patterns, etc) in their own file, since they all need to be passed through the generator slightly differently and will each generate a .h.inc/.cpp.inc file. Even then it’s not technically necessary, and in your case where you don’t use Patterns.td since everything is defined directly in C++, it really is a bit redundant.

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.

2 participants