Skip to content

Feature/heir cross integration#2946

Merged
copybara-service[bot] merged 1 commit into
google:mainfrom
Zohaib58:feature/heir-cross-integration
May 18, 2026
Merged

Feature/heir cross integration#2946
copybara-service[bot] merged 1 commit into
google:mainfrom
Zohaib58:feature/heir-cross-integration

Conversation

@Zohaib58
Copy link
Copy Markdown
Contributor

@Zohaib58 Zohaib58 commented May 13, 2026

Adds end-to-end support for lowering JaxiteWord IR to CROSS (Google’s CKKS backend for TPU), including dialect ops, a crypto-context setup pass, and an expanded Python emitter.

This completes the JaxiteWord → CROSS path that was started in earlier JaxiteWord work. The LWE → JaxiteWord conversion pass is intentionally out of scope here and tracked separately in #2964.

Changes

JaxiteWord dialect

  • Extend JaxiteWordOps.td with CROSS-oriented ops (e.g. gen_params, program_initialization, mul/relin/rot helpers aligned with the CROSS API).
  • Simplify dialect verification by removing redundant MulOp / RotOp verifiers where TableGen already enforces types/attributes.

jaxiteword-configure-crypto-context pass

  • New transform pass that analyzes an entry function and synthesizes helper functions to generate and configure the CROSS crypto context.
  • Infers CKKS parameters such as mul depth, rotation indices, and relinearization needs from the IR.
  • Exposes pass options for manual overrides (mul depth, TPU tiling r/c, batch size, composite rescaling, scaling factor, etc.).
  • JaxiteWord emitter (heir-translate --emit-jaxiteword)
  • Substantially expand JaxiteWordEmitter and templates to emit CROSS-compatible Python.
  • Cover homomorphic ops (add/sub/mul/relin/rot/mod_reduce, etc.) and crypto setup (gen_params, keygen, eval keys).

@google-cla
Copy link
Copy Markdown

google-cla Bot commented May 13, 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.

Comment thread MODULE.bazel.lock Outdated
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.

Let's leave out the MODULE.bazel.lock change. I think you can add it to .git/info/exclude to exclude it from your local git.

Comment thread WORKSPACE Outdated
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.

Remove this file. It should not be needed anymore now that we have MODULE.bazel

Comment on lines +39 to +48
LogicalResult MulOp::verify() {
// Types (ciphertext,ciphertext)->ciphertext are already enforced by TableGen.
return success();
}

LogicalResult RotOp::verify() {
// 'index' is an i64 attr enforced by Td
return success();
}

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.

You should not need these, and you can remove the corresponding hasVerifier from the ops tablegen.

Comment thread lib/Target/JaxiteWord/JaxiteWordEmitter.cpp
@Zohaib58 Zohaib58 force-pushed the feature/heir-cross-integration branch 2 times, most recently from cf9b9f8 to 46222c8 Compare May 13, 2026 16:28
@Zohaib58 Zohaib58 marked this pull request as draft May 13, 2026 16:29
@Zohaib58 Zohaib58 force-pushed the feature/heir-cross-integration branch from 46222c8 to d346aa2 Compare May 13, 2026 16:34
@Zohaib58 Zohaib58 marked this pull request as ready for review May 13, 2026 19:03
@j2kun
Copy link
Copy Markdown
Collaborator

j2kun commented May 14, 2026

@Zohaib58 I think there are still some issues with the rebase.

One thing you could try is, from a fresh branch rebased over main, run wget https://github.com/google/heir/pull/2934.patch to save the prior PR to a patch file, then git apply 2934.patch to apply it to your workspace. Make any additional changes from there and force push to this branch.

@Zohaib58 Zohaib58 force-pushed the feature/heir-cross-integration branch from d346aa2 to f0069ef Compare May 14, 2026 23:47
@Zohaib58
Copy link
Copy Markdown
Contributor Author

Zohaib58 commented May 15, 2026

@Zohaib58 I think there are still some issues with the rebase.

One thing you could try is, from a fresh branch rebased over main, run wget https://github.com/google/heir/pull/2934.patch to save the prior PR to a patch file, then git apply 2934.patch to apply it to your workspace. Make any additional changes from there and force push to this branch.

Hi Jeremy,

The current PR is missing LWEToJaxiteWord pass. Should I make another commit including that pass? Is there any issue with the LWEToJaxiteWord pass that I need to fix?

@j2kun
Copy link
Copy Markdown
Collaborator

j2kun commented May 15, 2026

I think I just missed LWEToJaxiteWord in my initial work. Let's put it into a separate PR.

@j2kun j2kun added the pull_ready Indicates whether a PR is ready to pull. The copybara worker will import for internal testing label May 15, 2026
@Zohaib58
Copy link
Copy Markdown
Contributor Author

I think I just missed LWEToJaxiteWord in my initial work. Let's put it into a separate PR.

Would you prefer I wait until PR #2946 merges and then open the conversion pass against main, or is it OK to open a separate PR now (stacked on top of this branch / or rebased once this lands)?

@j2kun
Copy link
Copy Markdown
Collaborator

j2kun commented May 16, 2026

Generally OK to add additional stacked PRs. Keeping the individual PRs smaller makes it easier for me to review them.

@copybara-service copybara-service Bot merged commit 74cb0d9 into google:main May 18, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

2 participants