Skip to content

CKKS: Use prime selection logic from OpenFHE#2402

Merged
copybara-service[bot] merged 1 commit into
google:mainfrom
ZenithalHourlyRate:ckks-param-fixedmanual
Nov 18, 2025
Merged

CKKS: Use prime selection logic from OpenFHE#2402
copybara-service[bot] merged 1 commit into
google:mainfrom
ZenithalHourlyRate:ckks-param-fixedmanual

Conversation

@ZenithalHourlyRate

@ZenithalHourlyRate ZenithalHourlyRate commented Nov 10, 2025

Copy link
Copy Markdown
Collaborator

The prime selection logic from #1400 for CKKS just uses the same prime selection logic as BGV, and might cause some severe scaling factor mismatch issue / rescaling noise due to the nature of RNS-CKKS instantiation.

To better mitigate the issue, CKKS should have its own prime selection logic, and OpenFHE is the standard reference.

This also helps #2364 and #2379. I believe with this PR, the high-precision level-specific scaling factor in populate-scale-ckks can be safely instantiated after the "reduced error" prime selection logic in generate-param-ckks.

Relates to #1640 but that issue has lots of TODO related to high precision scaling factor so it can not be closed.

For @j2kun: Can the specific issue in #2364 be reproduced with these prime selection logic?

@j2kun j2kun left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM!

Comment thread lib/Parameters/CKKS/Params.cpp Outdated

/// By original we mean the method in RNS-CKKS implementation
/// Corresponds to FIXED* in OpenFHE
static std::vector<int64_t> moduliQGenerationOriginal(int logFirstMod,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

maybe just call it moduliQGenerationOpenFHEFixed?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Name changed.

@j2kun

j2kun commented Nov 13, 2025

Copy link
Copy Markdown
Collaborator

For @j2kun: Can the specific issue in #2364 be reproduced with these prime selection logic?

The problem in that situation was that the parameters were selected before HEIR, so I don't get to select parameters.

@j2kun j2kun added the pull_ready Indicates whether a PR is ready to pull. The copybara worker will import for internal testing label Nov 13, 2025
@copybara-service copybara-service Bot merged commit 0d623e9 into google:main Nov 18, 2025
10 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.

2 participants