From 6cd1096281706febe629b5f5087154987ec5aa11 Mon Sep 17 00:00:00 2001 From: christopherngutierrez Date: Tue, 5 Nov 2024 14:39:05 -0800 Subject: [PATCH 1/2] fixed issues with mod with RNS > 3 for CKKS --- kerngen/high_parser/types.py | 3 +++ kerngen/pisa_generators/mod.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/kerngen/high_parser/types.py b/kerngen/high_parser/types.py index c1103503..5cca8d7c 100644 --- a/kerngen/high_parser/types.py +++ b/kerngen/high_parser/types.py @@ -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)) diff --git a/kerngen/pisa_generators/mod.py b/kerngen/pisa_generators/mod.py index f99bf20d..d2496632 100644 --- a/kerngen/pisa_generators/mod.py +++ b/kerngen/pisa_generators/mod.py @@ -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, ), From 3dd4c99a7a91e1193b933e7784833420fe9bd8be Mon Sep 17 00:00:00 2001 From: christopherngutierrez Date: Tue, 5 Nov 2024 15:47:15 -0800 Subject: [PATCH 2/2] fixed issue with rescale for rns > 3 --- kerngen/pisa_generators/rescale.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kerngen/pisa_generators/rescale.py b/kerngen/pisa_generators/rescale.py index 951de892..3bfe56b3 100644 --- a/kerngen/pisa_generators/rescale.py +++ b/kerngen/pisa_generators/rescale.py @@ -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"),