Skip to content

Coeff-form polynomial multiplication is broken #3061

Description

@crockeea
!Z14604445665681409_i64 = !mod_arith.int<14604445665681409 : i64>
!rns_L0 = !rns.rns<!Z14604445665681409_i64>
#ring_rns_L0_1_x4096 = #polynomial.ring<coefficientType = !rns_L0, polynomialModulus = <1 + x**4096>>
!poly = !polynomial.polynomial<ring = #ring_rns_L0_1_x4096, form=coeff>
module attributes {GSW.input_abi_signature_intgt_logN12_bits2 = ["GSW", "GSW"], GSW.output_abi_signature_intgt_logN12_bits2 = ["RLWE"]} {
  func.func @intgt_logN12_bits2(%arg0: !poly) -> !poly {
    %36 = polynomial.mul %arg0, %arg0 : !poly
    return %36 : !poly
  }
}

with --polynomial-to-mod-arith, this outputs

tmpinput.mlir:5:1: error: unsupported coefficient type: '!rns.rns<!mod_arith.int<14604445665681409 : i64>>'
module attributes {GSW.input_abi_signature_intgt_logN12_bits2 = ["GSW", "GSW"], GSW.output_abi_signature_intgt_logN12_bits2 = ["RLWE"]} {
^
tmpinput.mlir:5:1: note: see current operation: %9 = "polynomial.constant"() <{value = #polynomial<typed_int_polynomial <1 + x**4096> : !polynomial.polynomial<ring = <coefficientType = !rns.rns<!mod_arith.int<14604445665681409 : i64>>, polynomialModulus = <-1 + x**8191>>>>}> : () -> !polynomial.polynomial<ring = <coefficientType = !rns.rns<!mod_arith.int<14604445665681409 : i64>>, polynomialModulus = <-1 + x**8191>>>
tmpinput.mlir:5:1: error: failed to legalize operation 'polynomial.constant' that was explicitly marked illegal: %9 = "polynomial.constant"() <{value = #polynomial<typed_int_polynomial <1 + x**4096> : !polynomial.polynomial<ring = <coefficientType = !rns.rns<!mod_arith.int<14604445665681409 : i64>>, polynomialModulus = <-1 + x**8191>>>>}> : () -> !polynomial.polynomial<ring = <coefficientType = !rns.rns<!mod_arith.int<14604445665681409 : i64>>, polynomialModulus = <-1 + x**8191>>>
module attributes {GSW.input_abi_signature_intgt_logN12_bits2 = ["GSW", "GSW"], GSW.output_abi_signature_intgt_logN12_bits2 = ["RLWE"]} {
^
tmpinput.mlir:5:1: note: see current operation: %9 = "polynomial.constant"() <{value = #polynomial<typed_int_polynomial <1 + x**4096> : !polynomial.polynomial<ring = <coefficientType = !rns.rns<!mod_arith.int<14604445665681409 : i64>>, polynomialModulus = <-1 + x**8191>>>>}> : () -> !polynomial.polynomial<ring = <coefficientType = !rns.rns<!mod_arith.int<14604445665681409 : i64>>, polynomialModulus = <-1 + x**8191>>>

I think this should be simple to fix; we recently added support for RNS in this pass, and this code branch is likely untested after the introduction of PolyMulToNTT.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions