Why bootstrapping dominates: every multiply spends a level, and only bootstrapping (which spends many) buys them back.
FHE Accelerator Simulators — Presentation 02
Anatomy of CKKS Bootstrapping
ModRaise, CoeffToSlot (a homomorphic DFT evaluated with baby-step giant-step rotations), EvalMod (a polynomial approximation of modular reduction) and SlotToCoeff, with exact operation counts per stage, where the levels go, and the data-movement profile that makes bootstrapping a memory problem.
Concepts used here, and where they are explained. Each links to its series glossary entry: a short explanation, then links to the slides that explain it in depth, in this series, the Cryptography decks or LLM Inference Simulators.
Each multiplication consumes a level (deck 01). When a ciphertext reaches level 0 it cannot be multiplied again. Bootstrapping homomorphically evaluates (an approximation of) decryption to produce an equivalent ciphertext at a high level. For CKKS the standard pipeline is that of Cheon, Han, Kim, Kim and Song (EUROCRYPT 2018, ePrint 2018/153), refined by Han & Ki (ePrint 2019/688) and Bossuat et al. (EUROCRYPT 2021, ePrint 2020/1203):
The orange stages are rotation-heavy and key-hungry; EvalMod is multiplication-heavy and reuses one relinearisation key. That difference drives everything in decks 03–05.
02
ModRaise
What: reinterpret a level-0 ciphertext (one limb, modulus q0) modulo the full Q. Decrypting it now gives m + q0·I for a small integer polynomial I; the rest of bootstrapping exists to remove q0·I.
Cost: cheap. iNTT the single limb of both polynomials, then NTT the coefficients into all L+1 limbs: 2 + 2(L+1) = 50 limb transforms for the ark set, no key switch.
Sparse packing: with fewer slots than N/2, a SubSum of log2(N/2 / slots) rotations follows. OpenFHE's 8-slot configuration in our calibration does 12 of them.
Ordering variants: SlotToCoeff first
SlotToCoeff can run first, on the nearly exhausted input, before ModRaise (OpenFHE's BTSlotsEncoding option). Its rotations then use keys with few limbs, its levels are no longer taken from the top of the chain, and for real-valued data EvalMod runs once instead of twice. In the companion model (option stc_first) the ark-set bootstrap leaves 10 levels instead of 7 and takes 11.51 ms instead of 13.94 ms on the ARK-class design. OpenFHE's own StC-first trace shows the same shape (examples/results.md §19 in the code repo).
03
CoeffToSlot: A Homomorphic DFT
Encoding uses a DFT-like map (the canonical embedding). To operate on the polynomial's coefficients, which is where q0·I lives, bootstrapping applies the inverse encoding map homomorphically.
As a matrix, the map is dense, (N/2)×(N/2). Evaluated naively through its diagonals it would need N/2 rotations.
FFT factorisation: like any FFT it factors into log2(N/2) = 15 sparse stages. Merging stages into a radix-2k step gives 2k+1−1 non-zero diagonals per step, at one level per step.
The trade-off: the ark set merges 15 stages into 3 levels of radix 25, giving 63 diagonals per level. Fewer levels means more rotations per level; more levels means fewer rotations but fewer levels left for the application.
Each diagonal is a plaintext (12 MiB at the top level) that is multiplied in, and each rotation needs its own evaluation key.
ARK (arXiv:2205.00922) quotes the same structure: with k = 5 over 3 levels, "40 HRots and 158 PMults" per homomorphic DFT. The companion model, without ARK's further optimisations, does 43 and 189.
04
Baby-Step Giant-Step Rotations
A matrix-vector product with d diagonals needs d rotations if done directly. BSGS splits d = n1 × n2: rotate the input n1−1 times (baby steps), form n2 inner sums with pre-rotated diagonals, and rotate each sum once (giant steps).
Hoisting (Halevi & Shoup, CRYPTO 2018, ePrint 2018/244): the baby steps rotate the same ciphertext, so its decomposition and ModUp are done once and shared, which saves NTTs. The keys are still all different.
Every rotation amount is a distinct key: 14 keys per level here, 43 across CoeffToSlot. This is the pattern ARK's Min-KS attacks (slide 11).
05
EvalMod: Modular Reduction as a Polynomial
After CoeffToSlot the slots hold the coefficients t = m + q0·I (scaled). EvalMod computes t mod q0, which is not a polynomial, so it is approximated: (q0/2π)·sin(2πt/q0) is close to t mod q0 when m is small. In practice this means a scaled cosine evaluated with Chebyshev polynomials, followed by double-angle steps cos(2x) = 2cos2x − 1.
Step (one copy, ark set)
HMults
Levels
Scale into the approximation interval (a constant multiply)
0
1
Baby powers T2…T8 (degree 59 → b = 8)
7
3
Giant powers T16, T32
2
(in parallel)
8 baby polynomials (constant multiply-adds), then combine (g = 8)
7
1 + 3
2 double-angle steps
2
2
Total per copy
18
10
Two copies for full slots. After CoeffToSlot a conjugation (one more rotation) splits the real and imaginary parts, and EvalMod runs on each: 36 HMults in total.
One key, reused 36 times: the relinearisation key. EvalMod is NTT-heavy and cache-friendly, the opposite of the DFT stages.
The degree, the double-angle count and the use of a sine or cosine are accuracy choices; libraries differ. OpenFHE v1.5.1 with uniform ternary keys uses an 89-coefficient (degree-88) Chebyshev series and six double-angle steps, read from its source and confirmed by its recorded trace (slide 12).
06
SlotToCoeff
What: the forward encoding DFT, homomorphically, taking the corrected coefficients back to slots. It has the same BSGS structure as CoeffToSlot: 3 levels, 42 rotations (no conjugation) and 189 plaintext multiplies in the ark set.
Cheaper per operation: it runs after EvalMod, at levels 10 down to 8, where a key needs only 2 of its 4 digits and 15–17 of its 30 limbs. Its key traffic is 1.41 GB against 5.22 GB for CoeffToSlot.
Why ordering matters: moving the expensive DFT to the bottom of the level ladder is a standard optimisation. It changes the data-movement profile far more than it changes the operation count.
07
Where the Levels Go
Parameter set
L
CoeffToSlot
EvalMod
SlotToCoeff
Used by bootstrap
Left for the application
ark
23
3
10
3
16
7
lattigo
24
3
10
3
16
8
gpu100x
34
3
10
3
16
18
openfhe-sparse (8 slots)
18
1
14
1
16
2
openfhe-full14 (N = 214)
30
3
14
3
20
10
Bootstrapping is expensive per useful level. With 7 levels left, a deep computation bootstraps every 7 multiplications. The cost per useful level is the number that matters to applications (ARK and 100x use an amortised metric, TA.S., for this reason).
Bigger L buys more useful levels but makes every ciphertext, key and transform bigger, and pushes up PQ against the security bound.
These level counts come from the companion trace generator. A test checks them against the closed form CtS + (2 + ⌈log2(b−1)⌉ + ⌈log2g⌉ + r) + StC where g is a power of two; for the two OpenFHE rows they equal the bootstrap depth OpenFHE itself reports (16 and 20).
08
Operation Counts per Stage
One full-slot bootstrap of the ark set, baseline algorithm (hoisted BSGS). "Requested" bytes are what the operations need, before any on-chip reuse; deck 03 turns them into actual HBM traffic.
Stage
HE ops
HMult
HRot
PMult
Distinct keys
NTT + iNTT limbs
Key GB requested
Plaintext GB requested
ModRaise
1
0
0
0
0
50
0.00
0.00
CoeffToSlot
75
0
43
189
43
5,520
5.22
2.28
EvalMod
55
36
0
0
1
5,968
2.66
0.00
SlotToCoeff
72
0
42
189
42
2,172
1.41
0.99
203 HE operations, 85 rotations, 36 multiplications, 378 plaintext multiplies and 13,710 limb transforms (7.2 billion butterflies) per bootstrap.
EvalMod has the most transforms, but its 2.66 GB of key requests are all the same key; the DFT stages' 6.6 GB are 85 different keys.
09
The Data-Movement Profile
DFT stages: streaming
Every key is used once per bootstrap: compulsory traffic, whatever the SRAM size.
Every diagonal plaintext is used once: more compulsory traffic, unless it is generated on chip.
Arithmetic per byte is low. On the ARK-class model CoeffToSlot takes 72% of the bootstrap and is HBM-bound (deck 03).
EvalMod: compute
One key, reused; ciphertexts are reused across the polynomial evaluation tree.
NTT- and base-conversion-heavy. On the same model it takes 10% of the time and its hot-spot is the multiply-add lanes.
The 2–3 live ciphertexts and the key fit in a few hundred MiB of SRAM.
The consequence
A bootstrap alternates between a bandwidth-bound phase and a compute-bound phase, so no single roofline point describes it. That is the reason to simulate it as a sequence of operations rather than estimate it from totals. The analytic bound in deck 03 is 28% below the simulated time for exactly this reason.
10
Interactive: Stage Breakdown
"All three" is Min-KS + seeded keys + on-the-fly plaintexts (slide 11). This runs the simulator's trace generator in the browser (the same JavaScript that powers deck 03) and counts operations and requested bytes per stage. No timing here, only the workload.
16
23
4
3
3
2
per stage: limb transforms (green), key GB requested (orange), plaintext GB requested (teal); bars scaled to the largest value in each colour
11
Algorithmic Levers
Each technique changes the workload, not the hardware. Effects on one ark-set bootstrap, from the companion trace generator:
Technique
What it does
Effect on the workload
Hoisting (default)
Baby-step rotations share one ModUp
Fewer NTTs; same keys. Turning it off costs 15% more time on an NTT-starved design (deck 05)
Min-KS (ARK)
Apply baby and giant rotations iteratively by one fixed step, so a whole BSGS loop needs only 2 keys
CoeffToSlot keys: 43 → 7. Same rotation count, but hoisting is lost (more NTTs) and the rotations are serial
Seeded keys
The uniform half of each evaluation key is regenerated on chip from a seed
Key bytes halved; some PRNG work on the multiply-add lanes
On-the-fly plaintexts (in the spirit of ARK's OF-Limb)
Generate DFT diagonals on chip from a compact form instead of loading them
Plaintext bytes drop to one limb each; adds NTTs
OpenFHE's BSGS (lazy ModDown)
Keep rotations in the Q·P basis, multiply plaintexts there, ModDown once per DFT level; then baby steps cost no NTTs, so use many more of them
A third fewer transforms (13,710 → 9,234) but 109 rotations instead of 85, and plaintexts stored with the special limbs: right for a CPU, wrong for a memory-bound accelerator (deck 05)
SlotToCoeff first
Run SlotToCoeff before ModRaise, on the nearly exhausted input
18 HMults instead of 36 (one EvalMod), 9,544 transforms instead of 13,710, keys 6.95 instead of 9.29 GB requested, and 10 levels left instead of 7. The only lever here that helps every design (deck 05)
Radix / level budget
More DFT levels → fewer rotations
Fewer keys and bytes, fewer useful levels; use the interactive slide
Min-KS, seeded keys and on-the-fly plaintexts trade arithmetic for bytes; OpenFHE's BSGS trades bytes for arithmetic; SlotToCoeff first saves both. Whether that wins depends on whether the design is memory-bound or compute-bound, which is exactly what the simulator in deck 03 decides.
12
Checked Against a Real OpenFHE Bootstrap
OpenFHE v1.5.1 was instrumented (an 82-line patch) to log every NTT, base conversion, key switch, automorphism, rescale and plaintext multiply of a bootstrap. Below is N = 214, 8,192 slots, level budget {3, 3}, dnum 3, against the model at the same parameters, run with the default (balanced) BSGS split and with OpenFHE's. Each cell reads OpenFHE / model / model with OpenFHE's BSGS (HMults: OpenFHE / model).
Stage
Rotations
HMults
NTT + iNTT limbs
Key GB requested
CoeffToSlot
46 / 35 / 51
—
2,419 / 5,151 / 2,025
1.45 / 1.13 / 1.64
EvalMod
—
48 / 56
20,411 / 11,816 / 11,816
1.05 / 1.28 / 1.28
SlotToCoeff
45 / 34 / 50
—
1,025 / 2,494 / 854
0.57 / 0.43 / 0.63
Agrees exactly where the algorithms agree. Bootstrap depth is 20 in both, and in the N = 216, 8-slot recording the 12 SubSum rotations match OpenFHE on keys and key bytes exactly, and on transforms to within 3%.
The DFT split was the big difference. OpenFHE keeps rotated ciphertexts in the extended Q·P basis and uses many more baby steps (16 against 8 per radix-25 level). Modelling that (slide 11) brings transforms to within 20%.
EvalMod differs by library policy. OpenFHE's FLEXIBLEAUTO scaling rescales copies of each input before every multiplication: 542 polynomial rescales for 48 HMults, against 2 per HMult in the model. That roughly doubles its EvalMod transforms. An accelerator compiler would rescale once, so the model keeps that schedule and the difference is documented and tested.
13
What to Take Away
Four stages: ModRaise (cheap), CoeffToSlot and SlotToCoeff (homomorphic DFTs: rotations, distinct keys, plaintexts) and EvalMod (a polynomial: multiplications, one key).
BSGS turns a 63-diagonal level into 14 rotations; hoisting shares the ModUp; the keys stay distinct.
Levels: the ark set spends 16 of 23 levels bootstrapping, leaving 7.
Per bootstrap: 203 HE ops, 85 rotations, 36 HMults, 13,710 limb transforms, and about 9.3 GB of keys and 3.3 GB of plaintexts requested.
Two personalities: the DFT stages stream data, EvalMod computes. Simulate the sequence, not the totals.
Next
Deck 03 builds the accelerator model and runs this workload on it, live.