Skip to content

BootstrapGPU Bench Issues (FIDESLIB Release 2.0) #21

@Xuan-Wang-Summer

Description

@Xuan-Wang-Summer

Issue 1 — Out-of-bounds read of conf[] in SSEBootstrapGPU benchmark sweep

Summary

bench/BootstrapBenchmarks.cu:614 registers a SSEBootstrapGPU sweep that
includes index 24, but the conf[] array defined at lines 231–243 only has
24 entries (indices 0–23). Reading conf[24] returns garbage memory, which is
then passed as a level-budget parameter to OpenFHE's EvalBootstrapSetup. The
garbage value triggers OpenFHE's "level budget too large, setting it to 30"
clamp warning four times, then causes a std::length_error from
vector::reserve inside lbcrypto::ILDCRTParams constructor.

Environment

  • FIDESlib 2.0.0
  • OpenFHE 1.4.2 (bundled, with patched deps/openfhe-1.4.2.patch)
  • CUDA 12.9, GCC 12, NVIDIA RTX PRO 6000 Blackwell

Reproduction

./build/fideslib-bench --benchmark_filter='GeneralFixture/SSEBootstrapGPU/18/0/100/24'
Warning, the level budget for encoding is too large. Setting it to 30
Warning, the level budget for decoding is too large. Setting it to 30
Warning, the level budget for encoding is too large. Setting it to 30
Warning, the level budget for decoding is too large. Setting it to 30
terminate called after throwing an instance of 'std::length_error'
  what():  vector::reserve
Aborted (core dumped)

Stack trace (caught with catch throw in gdb)

#10 std::vector<...ILParamsImpl<NativeIntegerT<u64>>...>::reserve(unsigned long)
#11 lbcrypto::ILDCRTParams::ILDCRTParams(uint cyclotomicOrder, moduli&, roots&)
#12 lbcrypto::FHECKKSRNS::EvalCoeffsToSlotsPrecompute(...)
#13 lbcrypto::FHECKKSRNS::EvalBootstrapSetup(...)
#14 lbcrypto::CryptoContextImpl::EvalBootstrapSetup(...)
#15 FIDESlib::Benchmarks::GeneralFixture_SSEBootstrapGPU_Benchmark::BenchmarkCase(...)

Issue 2 — GetMSB() off-by-one in createSwitchableContextBasedOnContext

Summary

src/CKKS/openfhe-interface/ParameterSwitch.cu:41 reads GetMSB() of an
already-generated prime modulus and passes it directly to
SetScalingModSize on a new CCParams. When OpenFHE picks a scaling prime
just above 2^scalingModSize (which it can do — primes are picked near the
requested bit width), GetMSB() returns scalingModSize + 1. For a source
context built with scalingModSize = 59, this yields 60, which OpenFHE's
validateParametersForCryptocontext rejects strictly:

if (MAX_MODULUS_SIZE <= parameters.GetScalingModSize() ||
    15 > parameters.GetScalingModSize()) {
    OPENFHE_THROW("scalingModSize should be greater than 15 and less than ...");
}

(MAX_MODULUS_SIZE = 60 for 64-bit native ints.)

Environment

  • Same as Issue 1.
  • Triggered by any source context with scalingModSize close to
    MAX_MODULUS_SIZE whose generated primes happen to land at the upper edge
    of the requested bit range.

Reproduction

./build/fideslib-bench --benchmark_filter='GeneralFixture/BootstrapGPU/3/0/100/0/'

Fixture 3 = gparams64_16 (multDepth=29, scaleModSize=59, ringDim=2^16, dnum=4).

Stack trace

#0  __cxa_throw (lbcrypto::OpenFHEException)
#1  lbcrypto::validateParametersForCryptocontext
#2  FIDESlib::CKKS::createSwitchableContextBasedOnContext  ← here
#3  FIDESlib::CKKS::GenBootstrapKeys
#4  FIDESlib::CKKS::AddBootstrapPrecomputation
#5  FIDESlib::Benchmarks::GeneralFixture_BootstrapGPU_Benchmark::BenchmarkCase

Actual

terminate called after throwing an instance of 'lbcrypto::OpenFHEException'
  what():  ...gen-cryptocontext-params-validation.cpp:l.73:validateParametersForCryptocontext():
           scalingModSize should be greater than 15 and less than 60
Aborted (core dumped)

Issue 3 — EvalBootstrapSetup segfaults when fixture multDepth is too shallow for the registered config

Summary

bench/BootstrapBenchmarks.cu registers BootstrapGPU and SSEBootstrapGPU
sweeps that pair fixtures 7 and 20 with conf[] entries whose level-budget /
linear-transform parameters require more multiplicative depth than the
fixture provides. OpenFHE's EvalLinearTransformPrecompute walks past the
end of the modulus chain and dereferences null, producing a segfault.

The same conf[0] runs cleanly for fixtures with adequate depth (e.g. fixture
3 with multDepth=29); only fixtures 7 (logN=13, multDepth=5) and 20
(logN=15, multDepth=9) crash.

Reproduction

./build/fideslib-bench --benchmark_filter='GeneralFixture/BootstrapGPU/7/0/100/0/'

Other crashing combinations (smallest-slot configs):

  • BootstrapGPU/(7|20)/0/100/(0|1) — confirmed crash on /0.
  • SSEBootstrapGPU/(7|20)/0/100/(0|1) — likely the same.

Stack trace

#0  lbcrypto::FHECKKSRNS::EvalLinearTransformPrecompute(...)
#1  lbcrypto::FHECKKSRNS::EvalBootstrapSetup(...)
#2  lbcrypto::CryptoContextImpl::EvalBootstrapSetup(...)
#3  FIDESlib::Benchmarks::GeneralFixture_BootstrapGPU_Benchmark::BenchmarkCase(...)
Segmentation fault (core dumped)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions