Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert polynomial coefficient type to use modarith #1096

Merged
merged 1 commit into from
Nov 26, 2024

Conversation

j2kun
Copy link
Collaborator

@j2kun j2kun commented Nov 16, 2024

Major changes in this PR:

  • coefficientModulus attribute removed from ring attribute
  • coefficientType relaxed to allow AnyType
  • polynomial op verifiers enhanced to ensure scalar and polynomial coefficient types agree
  • polynomial-to-standard renamed to polynomial-to-mod-arith, and most lowerings emit mod_arith ops
  • SubAsAdd canonicalization pattern removed; lowering subtraction directly is more efficient.
  • Copied additional upstream polynomial tests that I forgot to in my last PR (e..g, tests/Dialect/Polynomial/IR/errors.mlir)

Shortcomings:

  • polynomial-to-mod-arith will fail for basically all polynomial types with non-mod-arith coefficient types. Since we don't have a use case for lowering int/float polynomials, I'm OK with this state of affairs indefinitely.
  • The NTT lowering is mostly unchanged, and I just take the mod-arith types, unpack them to their underlying integer type/value, and repack it back up as a mod-arith at the end. I just didn't have it in me to re-write the entire NTT lowering in this already gargantuan PR.

@j2kun j2kun marked this pull request as draft November 16, 2024 01:16
@j2kun j2kun force-pushed the polynomial-anytype branch 2 times, most recently from 3b3cff8 to f962e3e Compare November 19, 2024 05:13
@j2kun j2kun force-pushed the polynomial-anytype branch 3 times, most recently from beab499 to 5c7f63e Compare November 20, 2024 22:13
@j2kun j2kun force-pushed the polynomial-anytype branch 2 times, most recently from 1878b21 to be3ef1a Compare November 25, 2024 23:02
@j2kun j2kun marked this pull request as ready for review November 25, 2024 23:03
@j2kun j2kun force-pushed the polynomial-anytype branch from be3ef1a to be8b520 Compare November 25, 2024 23:04
@j2kun j2kun requested a review from asraa November 25, 2024 23:04
@WoutLegiest WoutLegiest self-requested a review November 26, 2024 17:14
Copy link
Collaborator

@WoutLegiest WoutLegiest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, lot is boilerplate changes of types, namespaces and conversion to the new types

@j2kun j2kun force-pushed the polynomial-anytype branch from be8b520 to 39d84a1 Compare November 26, 2024 19:28
@j2kun j2kun added the pull_ready Indicates whether a PR is ready to pull. The copybara worker will import for internal testing label Nov 26, 2024
@copybara-service copybara-service bot merged commit 52a5ccd into google:main Nov 26, 2024
7 of 8 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.

3 participants