Skip to content

Commit

Permalink
CKKS Bug Fixes for Relin/Rotate/Mod/Rescale (RNS > 3)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
christopherngutierrez authored Nov 13, 2024
1 parent dfd7429 commit 9ed33df
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions kerngen/high_parser/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ def from_polys(cls, poly: "Polys", *, mode: str | None = None) -> "Polys":
case "last_rns":
copy.start_rns = copy.rns - 1
return cls(**vars(copy))
case "single_rns":
copy.rns = 1
return cls(**vars(copy))
case "last_part":
copy.start_parts = copy.parts - 1
return cls(**vars(copy))
Expand Down
2 changes: 1 addition & 1 deletion kerngen/pisa_generators/mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def generate_mod_stages() -> list[Stage]:
temp_input_last_rns,
p_half,
Polys.from_polys(
input_remaining_rns, mode="drop_last_rns"
input_remaining_rns, mode="single_rns"
),
last_q,
),
Expand Down
2 changes: 1 addition & 1 deletion kerngen/pisa_generators/rescale.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def to_pisa(self) -> list[PIsaOp]:
temp_input_last_rns,
temp_input_last_rns,
q_last_half,
input_remaining_rns,
Polys.from_polys(input_remaining_rns, mode="single_rns"),
last_q,
),
Comment("Subtract q_i (last half/last rns) from y"),
Expand Down

0 comments on commit 9ed33df

Please sign in to comment.