Fideslib ps chebychev refactor - #1284
Draft
carlostriste wants to merge 13 commits into
Draft
Conversation
…Sum, Horner CtS/StC, and scheme-switching linear transforms
fideslib-ref: AccumulateSumInPlace/EvalPartialSumInPlace radix configurability
…rescale, improved input range adjustment preamble - Potential fix for Issue openfheorg#1104
…k the *Many operations Renames CKKS_PARTIAL_SUM_RADIX to PARTIAL_SUM_RADIX: the knob is no longer CKKS-specific because it now also drives the scheme-generic EvalSum/EvalSumRows/EvalSumCols family. All four folds route through one EvalSumRadixFold that, under HYBRID key switching, accumulates lazily in the extended basis exactly like EvalPartialSumInPlace (one deferred ApproxModDown for element 0, per-level settle for element 1, one digit decomposition per level); a hoisted eager fallback covers non-HYBRID via a new SchemeBase::EvalAutomorphismCore wrapper, needed because EvalSum keys live in their own key map. EvalAddMany becomes a null-tolerant left fold with a single clone (addition is exact and associative, so the pairing tree bought nothing; ~1.5-2x vs dev, growing with tower count) and EvalAddManyInPlace an actually-in-place serial fold with zero allocations (~1.8-2.3x); its result lands in slot 0 per the in-place contract, and null-leading vectors work for the first time. Fixes a size-1 aliasing bug in the cryptocontext wrappers: EvalAddMany/EvalMultMany returned the caller's input handle for single-element vectors, so mutating the result silently corrupted the input; results never alias inputs now (EvalAddMany's early return is dropped, EvalMultMany's becomes a keyless Clone). Unifies EvalMultMany: the base tree picks levelsToDrop from GetCompositeDegree() (1 everywhere except composite-scaling CKKS), making the AdvancedSHECKKSRNS override redundant; it is removed. The unified fold keeps the three-phase structure, clones for size 1 (also fixing an empty-scratch-vector UB at the scheme layer), and frees each consumed partial immediately: live intermediates drop from n-1 to ~n/2, measured -46% peak scratch at n=32 with unchanged runtime and pairing order (bit-identical).
The fully-packed BFV/BGV branch kept the legacy doubling index set, which no longer covers EvalSum calls at smaller batch sizes once those fold at the configured radix (radix-2 sets were nested across all batch sizes; e.g. EvalInnerProduct with default keygen requested key 5^3). The fully-packed path now radix-folds its first phase (covering batchSize/2) with only the m-1 conjugation tail kept special, in both keygen and the fold, making the fully-packed key set a superset of every smaller batch's set again.
…rescale, improved input range adjustment preamble - Potential fix for Issue openfheorg#1104
fideslib-ref: radix EvalSum folds (PARTIAL_SUM_RADIX), multiparty keygen dedup, EvalAddMany/EvalMultMany cleanups
…th FIDESlib and allow further optimizations (detailed comments added in ckksrns-advancedshe.cpp)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes and optimizations on chebychev evaluation to match FIDESlib bit behaviour (pending to push) and allow for future improvements.
Treat the changes as a prototype pending for cleanup, also, the fideslib compatibility patch is pre-applied.