Skip to content

Commit 9ed33df

Browse files
CKKS Bug Fixes for Relin/Rotate/Mod/Rescale (RNS > 3)
* fixed issues with mod with RNS > 3 for CKKS * fixed issue with rescale for rns > 3 * Added new option in Polys.from_polys to set RNS=1 to support the bug fixes.
1 parent dfd7429 commit 9ed33df

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

kerngen/high_parser/types.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ def from_polys(cls, poly: "Polys", *, mode: str | None = None) -> "Polys":
5757
case "last_rns":
5858
copy.start_rns = copy.rns - 1
5959
return cls(**vars(copy))
60+
case "single_rns":
61+
copy.rns = 1
62+
return cls(**vars(copy))
6063
case "last_part":
6164
copy.start_parts = copy.parts - 1
6265
return cls(**vars(copy))

kerngen/pisa_generators/mod.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def generate_mod_stages() -> list[Stage]:
123123
temp_input_last_rns,
124124
p_half,
125125
Polys.from_polys(
126-
input_remaining_rns, mode="drop_last_rns"
126+
input_remaining_rns, mode="single_rns"
127127
),
128128
last_q,
129129
),

kerngen/pisa_generators/rescale.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def to_pisa(self) -> list[PIsaOp]:
6262
temp_input_last_rns,
6363
temp_input_last_rns,
6464
q_last_half,
65-
input_remaining_rns,
65+
Polys.from_polys(input_remaining_rns, mode="single_rns"),
6666
last_q,
6767
),
6868
Comment("Subtract q_i (last half/last rns) from y"),

0 commit comments

Comments
 (0)