ESP32-S3 Bench Guide
ESP32-S3 N16R8 bench guide: live pinout, lessons, simulators and the bench log.
翻译准备中
How long does a CKKS bootstrap take on a given accelerator? Is the design bound by NTT throughput or by evaluation-key traffic? How much on-chip SRAM stops key traffic dominating, and does an optical
翻译准备中
教育HTMLGitHub @BrendanJamesLynskey在线运营者未确认
试用过了吗? 点一下就好,无需登录。
尚未检测到更新。GitHub 发布版本后会显示在这里。
个人 GitHub 账号下公开仓库的所有者可以登录并验证所有权,自行管理介绍,无需管理员批准。
登录并生成验证文件,在 30 分钟内将其提交到此仓库的默认分支。其他分支或分叉仓库中的文件无效。然后在下方检查文件,即可无需管理员批准直接管理项目。请保留文件以维持管理权限。
如需登录,将前往登录页面。登录后请回到此处,再次点击所选的验证按钮。
在项目文件夹中运行 /nomorevibe verify,即可验证所有权并自行管理介绍。
一分钟完成验证How long does a CKKS bootstrap take on a given accelerator? Is the design bound by NTT throughput or by evaluation-key traffic? How much on-chip SRAM stops key traffic dominating, and does an optical NTT engine win once conversion energy and precision corrections are counted? Five interactive decks
翻译准备中
取自仓库 README
正在加载完整 README。 以下为已保存的摘录。
How long does a CKKS bootstrap take on a given accelerator? Is the design bound by NTT throughput or by evaluation-key traffic? How much on-chip SRAM stops key traffic dominating, and does an optical NTT engine win once conversion energy and precision corrections are counted? Five interactive decks and a tested SimPy simulator work through these questions.查看完整 README ↗Brendan Lynskey · Portfolio home · Interactive sites
How long does a CKKS bootstrap take on a given accelerator? Is the design bound by NTT throughput or by evaluation-key traffic? How much on-chip SRAM stops key traffic dominating, and does an optical NTT engine win once conversion energy and precision corrections are counted? Five interactive decks and a tested SimPy simulator work through these questions. They run from CKKS as a hardware workload and the anatomy of bootstrapping, through the simulator itself (live in the browser, a bit-exact JavaScript port) and optical transform engines, to design-space results, a reading list and practice questions.
Live index: https://brendanjameslynskey.github.io/FHE_Hub_Accelerator_Simulators/
| # | Title | Status | What it covers |
|---|---|---|---|
| 01 | FHE for Hardware Engineers: CKKS as a Workload | live | CKKS seen from the datapath, not the proof: RNS polynomials in Z_q[X]/(X^N+1), how big ciphertexts and evaluation keys really are, the five primitive kernels (NTT, modular multiply-add, automorphism, base conversion, rescale), noise and levels, and why key switching dominates. Includes a live parameter calculator. |
| 02 | Anatomy of CKKS Bootstrapping | live | 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. |
| 03 | Simulating an FHE Accelerator | live | The modelled machine (NTT units, modular multiply-add lanes, an automorphism network, a scratchpad, HBM and key streaming), the operation-trace format and where traces come from (a scheme model, HEIR, OpenFHE), the SimPy engine, its metrics and its validation ladder, and the whole simulator running live in the browser. |
| 04 | Optical NTT Engines: Precision, Conversion and Power | live | Fourier transforms in optics, and what it takes to map an exact modular NTT onto an analogue complex FFT: digit decomposition, small-prime RNS, rounding and error correction, ENOB, DAC/ADC energy from a Walden figure of merit, and laser and thermal-tuning power. The simulator then shows when an optical engine wins and when it loses. |
| 05 | Results and the Design Space | live | What the simulator says: SRAM size against key traffic, the NTT-bound and memory-bound regimes, power and energy per bootstrap under a TDP, the algorithmic acceleration techniques, a design-space sweep, silicon area as a third axis (a three-way power, performance and area front), the model's limitations, a reading list (F1, CraterLake, BTS, ARK, SHARP, GPU work, HEIR, OpenFHE, Lattigo) and practice questions. |
| Repo | What's inside |
|---|---|
| FHE_Accelerator_Sim | A SimPy discrete-event simulator of an FHE accelerator running CKKS bootstrapping: a scheme model that turns bootstrapping into NTT, base-conversion, multiply-add and automorphism kernels; NTT, MAC, automorphism and optional optical units; a scratchpad whose misses become evaluation-key, plaintext and ciphertext traffic over shared HBM; bound attribution, hot-spots, Perfetto traces; a power model with a dynamic power manager under a TDP, and DVFS; an optical precision model with a functional check; OpenFHE calibration and two recorded OpenFHE bootstrap traces it replays; a front end for the HEIR compiler with three HEIR-compiled programs; algorithm options (hoisting, Min-KS, seeded keys, on-the-fly plaintexts, OpenFHE's lazy ModDown, SlotToCoeff-first ordering); an area, yield and silicon-cost model (7 nm, calibrated from ARK's published breakdown and a CACTI sweep, illustrative); 126 tests; and the JavaScript port used live in decks 03 and SimEng 13. |
Every number is read from examples/results.md when this README is built. Hardware coefficients are illustrative.
Decks 01 and 02 cover what is being simulated: CKKS as a workload, and bootstrapping stage by stage. Deck 03 is the simulator, its trace format, metrics and validation, with the live port. Deck 04 examines optical NTT engines. Deck 05 collects the results, the limitations, a reading list and practice questions. All hardware coefficients in the simulator are illustrative, and every number in the decks comes from a recorded run (examples/results.py in the code repo).
Every concept the decks rely on, with links to the slides that explain it in depth (this series, the Cryptography decks, or LLM Inference Simulators). The same glossary, with anchors each deck links to, is on the live index.
| Concept | What it is | Where it is explained |
|---|---|---|
| LWE and Ring-LWE | The hard problems FHE rests on: given noisy linear equations b = a·s + e (mod q), recovering s is hard. Ring-LWE works with polynomials instead of vectors, so one sample carries N coefficients, which is what makes NTTs the core kernel. | Cryptography 08 · LWE; Cryptography 08 · Ring-LWE |
| CKKS | The FHE scheme for approximate arithmetic on real or complex vectors. Values are encoded with a scale Δ; noise is treated as rounding error; each multiplication is followed by a rescale that consumes one level. | Cryptography 08 · CKKS; FHESim 01 · noise, scale and levels |
| RNS polynomials and limbs | The ciphertext modulus Q is a product of word-sized primes, so each polynomial is stored as one row ('limb') of N residues per prime. A ciphertext at level ℓ has ℓ+1 limbs; all arithmetic stays in 64-bit words. | FHESim 01 · the data: RNS polynomials; Cryptography 08 · RNS and NTT |
| Number-theoretic transform (NTT) | The FFT over a finite field Z_q. It moves a limb between coefficient and evaluation form in (N/2) log N butterflies, so polynomial multiplication becomes element-wise. Every key switch and rescale runs NTTs. | Cryptography 08 · RNS and NTT; Cryptography 10 · the NTT; ; |
| Modular reduction (Barrett, Montgomery) | Ways to compute a·b mod q without division, using precomputed constants. Every butterfly and multiply-add lane in an FHE accelerator contains one. | Cryptography 10 · Montgomery reduction in SystemVerilog; Cryptography 10 · the NTT |
| Levels, scale and rescale | A multiplication squares the scale; rescale divides by a prime and drops a limb. So each multiplicative level costs one prime, the level of a ciphertext sets how much work every operation on it does, and level 0 cannot be multiplied. | FHESim 01 · noise, scale and levels; Cryptography 08 · noise growth |
| Automorphism and slot rotation | Substituting X → X^(5^r) permutes a polynomial's coefficients so that the packed slots rotate by r. The permutation is free of arithmetic, but the result needs a key switch with a rotation key specific to r. | FHESim 01 · primitive kernels; FHESim 02 · BSGS rotations |
| Key switching and evaluation keys | After a multiplication (relinearisation) or a rotation, part of the ciphertext is under the wrong key; key switching fixes it using an evaluation key (78–210 MiB for the N = 2^16 sets used here). It dominates the cost of FHE. | FHESim 01 · key switching, step by step; FHESim 01 · why key switching dominates; Cryptography 08 · relinearisation and key switching |
| Hybrid key switching: dnum, special primes, ModUp and ModDown | The limbs are split into dnum digits of α limbs. Each digit is base-converted up to Q·P (ModUp, with α special primes P), multiplied by the key, and converted back (ModDown). dnum trades key size against work and security. | FHESim 01 · key switching; FHESim 01 · the dnum trade-off |
| Base conversion | Re-expresses an RNS polynomial in a different set of primes, as a matrix product over limbs. It is the heart of ModUp and ModDown and often the second-largest cost after NTTs. | FHESim 01 · primitive kernels |
| HMult, HRot, PMult, CMult | The homomorphic operations: ciphertext×ciphertext multiply (with relinearisation), rotation, ciphertext×plaintext multiply and ciphertext×constant multiply. Only HMult and HRot need a key switch. | FHESim 01 · why key switching dominates; FHESim 02 · operation counts per stage |
| Slots, packing and sparse packing | A CKKS ciphertext holds N/2 complex numbers in parallel 'slots' (SIMD). Using fewer slots (sparse packing) shrinks the bootstrap's DFTs but adds a SubSum of rotations. | FHESim 01 · RNS polynomials; FHESim 02 · ModRaise and SubSum |
| Bootstrapping | Evaluating decryption homomorphically to turn a level-0 ciphertext into one at a high level: ModRaise, CoeffToSlot, EvalMod, SlotToCoeff. It costs hundreds of key switches and gigabytes of keys. | FHESim 02 · why bootstrap; Cryptography 08 · bootstrapping |
| ModRaise | Reinterprets a level-0 ciphertext modulo the full Q, which adds a multiple of q_0 the rest of bootstrapping must remove. Cheap: transforms only. | FHESim 02 · ModRaise |
| CoeffToSlot and SlotToCoeff (homomorphic DFT) | The encoding transform and its inverse, evaluated homomorphically as a few sparse matrix-vector products (an FFT factorised into levels). Rotation- and key-heavy: the memory-bound part of bootstrapping. | FHESim 02 · CoeffToSlot; FHESim 02 · SlotToCoeff |
| Baby-step giant-step (BSGS) | Evaluates a d-diagonal matrix with about 2√d rotations instead of d: n_1 baby-step rotations of the input, n_2 inner sums, and one giant-step rotation per sum. | FHESim 02 · BSGS rotations |
| Hoisting | Several rotations of the same ciphertext share one decomposition and ModUp (Halevi and Shoup), saving NTTs; the rotation keys stay distinct. | FHESim 02 · BSGS rotations |
| EvalMod: Chebyshev series and double angle | Approximates the modular reduction with a scaled cosine evaluated as a Chebyshev series (baby-step giant-step polynomial evaluation) followed by double-angle steps cos 2x = 2cos²x − 1. Multiplication-heavy, one key. | FHESim 02 · EvalMod |
| SlotToCoeff first | Running SlotToCoeff before ModRaise, on the nearly exhausted input: cheap keys, one EvalMod for real data, and its levels are not taken from the top. OpenFHE's BTSlotsEncoding. | FHESim 02 · ordering variants; FHESim 05 · acceleration techniques |
| Min-KS, seeded keys and on-the-fly plaintexts | Algorithmic ways to cut key and plaintext traffic: rotate iteratively by one step so a BSGS loop reuses one key (Min-KS, from ARK), regenerate half of each key from a seed, and generate DFT plaintexts on chip. | FHESim 02 · algorithmic levers; FHESim 05 · acceleration techniques; ARK (arXiv:2205.00922) |
| Lazy ModDown (OpenFHE's BSGS) | Keeping rotated ciphertexts in the extended Q·P basis and doing one ModDown per DFT level, so baby steps cost no NTTs and many more of them are used. Fewer NTTs, more keys. | FHESim 02 · checked against OpenFHE; FHESim 02 · algorithmic levers |
| Amortised time per slot (T_A.S.) | Bootstrap time plus the multiplications it enables, divided by the levels left and the slots: the cost per useful operation. Used by ARK and the 100x GPU paper to compare different parameters. | FHESim 02 · where the levels go; ARK (arXiv:2205.00922) |
| FLEXIBLEAUTO rescaling (OpenFHE) | An OpenFHE mode that rescales automatically and lazily, before each multiplication, on copies of its inputs. Convenient for users; in a kernel trace it shows up as many extra rescales. | FHESim 02 · checked against OpenFHE |
| Scratchpad, LRU and spills | The accelerator's on-chip SRAM, modelled as a least-recently-used store of ciphertexts, keys and plaintexts. A miss loads from HBM; evicting a live ciphertext writes it back (a spill). | FHESim 03 · scratchpad and traffic; FHESim 05 · SRAM against key traffic |
| Silicon area and the area model | Die area in mm² per component (NTT, MAC and permutation units, scratchpad, uncore, HBM PHYs). The simulator's model is at 7 nm, calibrated from ARK's published breakdown and a CACTI sweep, and illustrative; area never changes a simulated time or energy. | FHESim 05 · SRAM against key traffic and area; SimEng 13 · what sets area; SimEng 13 · estimating area before layout |
| Die yield and silicon cost | The fraction of dies with no fatal defect: Poisson e^(−A·D_0) or Murphy's model, which is kinder to large dies. With dies per wafer it turns area into cost per good die, which grows faster than area. | SimEng 13 · why area is cost; SimEng 13 · when to split the die |
| HBM and key streaming | Off-chip high-bandwidth memory. Evaluation keys and DFT plaintexts are too big to keep on chip, so they stream from HBM, which is why bootstrapping is often memory-bound. | FHESim 03 · the modelled architecture; FHESim 01 · why key switching dominates |
| Roofline and ridge point | Performance is capped by compute or by memory bandwidth; the ridge point is the arithmetic intensity where the two meet. Work below it is memory-bound. | LLM Inference Simulators 03 · the roofline; FHESim 05 · NTT-bound against memory-bound |
| NTT-, MAC-, memory- and power-bound | The simulator's verdict: the most-utilised resource sets the bound (HBM, NTT units, multiply-add lanes), or power when the power limit throttles a compute-bound design. | FHESim 03 · metrics and hot-spots; FHESim 05 · regimes |
| Hot-spot attribution | For each stage of the workload, the resource that was busiest: where an upgrade would help. | LLM Inference Simulators 06 · hot-spot attribution; FHESim 03 · metrics and hot-spots |
| Static and dynamic power | Static power is drawn all the time (leakage, lasers, tuning); dynamic energy is paid per operation and per byte moved. Energy = static × time + Σ operations × energy each. | LLM Inference Simulators 07 · where the joules go; LLM Inference Simulators 07 · the simulator's power model; FHESim 03 · cost and power model |
| TDP, DVFS and power caps | The thermal design power is the limit the chip must not exceed. DVFS lowers clock and voltage together (energy per operation ~ clock²); a power cap throttles to stay under a limit. | LLM Inference Simulators 07 · DVFS and power caps; FHESim 03 · cost and power model |
| Dynamic power manager against worst-case clocking | Worst-case clocking picks one clock at which everything at full rate fits the TDP; a dynamic manager gives each kernel the highest clock that fits the power actually free at that moment. | FHESim 05 · power and energy per bootstrap; FHESim 03 · cost and power model |
| Fourier optics and the 4f system | A lens Fourier-transforms the light field; two lenses with a mask between them multiply in the frequency domain, which is a convolution. The transform is free; the converters and lasers around it are not. | FHESim 04 · Fourier transforms in optics; LLM Inference Simulators 07 · power in photonic compute |
| Digit decomposition (bit slicing) | Splitting each operand into d digits of b bits so that low-precision analogue products can be recombined exactly in digital logic. Narrower digits need less precision but more passes. | FHESim 04 · route 1: digit decomposition |
| Bluestein's algorithm | Rewrites a DFT as chirp multiplies around a convolution (using jk = (j² + k² − (k−j)²)/2), which lets a convolution engine compute an exact modular DFT. | FHESim 04 · route 2: a hybrid NTT |
| ENOB and exact rounding | Effective number of bits: the real precision of an analogue chain. Rounding to the exact integer needs the error below one half, which sets a minimum ENOB for each block size and digit width. | FHESim 04 · the rounding rule; FHESim 04 · checked functionally |
| Walden figure of merit | Converter energy per sample ≈ FoM × 2^ENOB, so every extra bit of precision doubles the energy of each DAC or ADC conversion. | FHESim 04 · conversion energy; LLM Inference Simulators 07 · power in photonic compute |
| Discrete-event simulation | Simulated time jumps from event to event (a kernel finishing, a transfer completing) instead of ticking every cycle, which is why a whole bootstrap simulates in tens of milliseconds. | LLM Inference Simulators 02 · anatomy of a discrete-event simulator; LLM Inference Simulators 02 · processes as coroutines |
| SimPy processes and resources | SimPy's vocabulary: processes are Python generators that yield events (timeouts, requests); a Resource is a server with a FIFO queue. Units and HBM are Resources here. | LLM Inference Simulators 02 · SimPy vocabulary; LLM Inference Simulators 02 · modelling hardware in SimPy; FHESim 03 · the SimPy engine |
| The fidelity ladder | Models from spreadsheet to RTL, each slower and more exact. This simulator sits at the transaction/discrete-event rung: one event per kernel, not per cycle. | LLM Inference Simulators 01 · the fidelity ladder; FHESim 03 · what the simulator must answer |
| Kernel-level trace | The contract between a scheme model or compiler and the hardware model: HE operations with their inputs, outputs, keys, plaintexts, levels and primitive kernels. | FHESim 03 · the trace; FHESim 03 · where traces come from |
| Perfetto and Chrome traces | A timeline format and viewer: one row per resource, one slice per kernel or transfer, for seeing overlap and idle time. | LLM Inference Simulators 06 · traces in Perfetto |
| The verification ladder | Layers of evidence: unit tests against hand formulas, invariants, analytic checks, behaviour, property-based tests, calibration and differential tests. | LLM Inference Simulators 06 · the verification ladder; FHESim 03 · validation |
| Property-based testing (Hypothesis) | Instead of fixed examples, generate many random configurations and check that invariants hold for all of them; Hypothesis shrinks any failure to a minimal case. | LLM Inference Simulators 06 · testing frameworks; FHESim 03 · validation |
| Flow-shop makespan | An analytic check: n identical jobs, each a load of time a then a compute of time b on two machines, finish at a + b + (n−1)·max(a, b). The engine must reproduce it exactly. | FHESim 03 · validation |
| Differential testing and a bit-exact twin | Running two independent implementations on the same input and requiring identical output, here the Python simulator and its JavaScript port. | LLM Inference Simulators 06 · the verification ladder; FHESim 03 · validation |
| Calibration and out-of-sample prediction | Fit as few model coefficients as possible to measurements (here, one rate to an OpenFHE multiplication), then judge the model on quantities it was not fitted to. | FHESim 03 · validation; FHESim 05 · against published numbers |
| Design sweeps and Pareto fronts | Simulate a grid of designs; a design is Pareto-optimal if no other is at least as good on every metric (latency, energy, and now area) and better on one. The front is the set of sensible choices; everything else is dominated. | FHESim 05 · sweeps and Pareto fronts; FHESim 05 · the three-way SRAM front; SimEng 13 · Pareto fronts; LLM Inference Simulators 08 · smarter experiments |
| MLIR, dialects and SSA | MLIR is a compiler framework of 'dialects' (sets of operations) lowered step by step. Its IR is in static single assignment (SSA) form: every value is defined once, so def-use chains give the dependencies directly. | LLM Inference Simulators 09 · MLIR in one slide |
| HEIR | Google's MLIR-based FHE compiler: it chooses parameters, packing, rotations, levels and bootstrap placement, and emits code for libraries or hardware. Its ckks-dialect output drives this simulator. | LLM Inference Simulators 09 · HEIR; FHESim 03 · where traces come from; FHESim 03 · a HEIR front end |
| OpenFHE | An open-source FHE library (C++). Here it is used to calibrate timing, and an instrumented build records the kernel stream of real bootstraps. | Cryptography 08 · FHE libraries; FHESim 02 · checked against OpenFHE; FHESim 03 · where traces come from |