Skip to content

Validate before creating IR in the lwe.rlwe_encrypt lowering - #3678

Merged
copybara-service[bot] merged 1 commit into
mainfrom
test_1026833593
Nov 24, 2026
Merged

copybara-service[bot] merged 1 commit into
mainfrom
test_1026833593

Conversation

@copybara-service

Copy link
Copy Markdown
Contributor

Validate before creating IR in the lwe.rlwe_encrypt lowering

--lwe-to-polynomial disables pattern rollback, so IR created by a pattern
that then fails is not removed. The lowering of lwe.rlwe_encrypt checked
the plaintext coefficient type, the secret key size, and the ciphertext
ring only after it had started creating ops.

Move those checks ahead of all IR creation. The helper that builds the
plaintext modulus no longer validates its input; the pattern checks the
plaintext coefficient type itself. The plaintext cast and the plaintext
modulus are now created once, before the public/secret key branches,
instead of once in each branch.

This is relatively minor cleanup in preparation for lowering CKKS ops to polynomial

--lwe-to-polynomial disables pattern rollback, so IR created by a pattern
that then fails is not removed. The lowering of `lwe.rlwe_encrypt` checked
the plaintext coefficient type, the secret key size, and the ciphertext
ring only after it had started creating ops.

Move those checks ahead of all IR creation. The helper that builds the
plaintext modulus no longer validates its input; the pattern checks the
plaintext coefficient type itself. The plaintext cast and the plaintext
modulus are now created once, before the public/secret key branches,
instead of once in each branch.

This is relatively minor cleanup in preparation for lowering CKKS ops to polynomial

PiperOrigin-RevId: 1028593814
@copybara-service
copybara-service Bot merged commit f200a15 into main Nov 24, 2026
6 of 7 checks passed
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.

1 participant