Skip to content

Fideslib ps chebychev refactor - #1284

Draft
carlostriste wants to merge 13 commits into
openfheorg:devfrom
carlostriste:fideslib-PS-chebychev-refactor
Draft

Fideslib ps chebychev refactor#1284
carlostriste wants to merge 13 commits into
openfheorg:devfrom
carlostriste:fideslib-PS-chebychev-refactor

Conversation

@carlostriste

Copy link
Copy Markdown
Collaborator

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.

pascoec and others added 13 commits July 16, 2026 17:55
…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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Changes and optimizations on chebychev evaluation to match FIDESlib bit behaviour

2 participants