Unified Butterfly Units in Computation
- Unified Butterfly Units are butterfly-structured primitives with multistage sparse connections and reconfigurable local transforms, optimizing performance across FFT, NUFFT, neural networks, cryptography, and quantum operations.
- They underpin various applications by leveraging low-rank approximations, adaptive control layers, and shared hardware modules to efficiently implement oscillatory transforms and matrix factorizations.
- The unified design pattern reduces computational complexity and enhances performance, yielding significant speedups and parameter reductions in diverse settings from signal processing to post-quantum cryptography.
Unified Butterfly Units are butterfly-structured computational primitives that recur in several technically distinct settings: fast oscillatory integral transforms, attention-based neural networks, FPGA accelerators for FFT- and butterfly-linear layers, parallel iterative NTT/INTT accelerators for post-quantum cryptography, and distributed quantum computation over the butterfly network. Across these settings, the common pattern is a multistage butterfly transform with sparse local interactions, together with a control layer that selects among closely related butterfly behaviors such as NUFFT versus butterfly factorization, FFT versus butterfly-linear mode, or NTT versus INTT mode (Yang, 2018, Fan et al., 2022, Alexakis et al., 1 Jul 2026, Soeda et al., 2010).
1. Mathematical and structural foundations
In the harmonic-analysis literature, a butterfly factorization is defined for matrices with the complementary low-rank property. Let and be dyadic trees of depth . For a node at level and a node at level , the submatrix is numerically low-rank with rank bounded independently of . Equivalently, on each such pair of boxes there is a separated representation
This property underlies the Interpolative Butterfly Factorization (IBF), which represents an 0 matrix as a product of 1 sparse matrices, each with 2 nonzeros, with construction in 3 operations and memory and application in 4 (Li et al., 2016).
The preliminary IBF has the form
5
and the optimal form after sweeping compression is
6
Structurally, this is precisely a sequence of “butterfly units”: modules mapping coefficients between adjacent levels with sparse, local connectivity. The factors 7, 8, 9, 0, and 1 are level-wise transformations whose dense subblocks encode local interpolation, restriction, prolongation, and switching operations (Li et al., 2016).
IBF is built from interpolative low-rank approximations of oscillatory kernels 2. The key analytic decomposition is
3
which isolates the smooth coupling term 4 for Chebyshev interpolation. Sweeping compression then propagates the true numerical ranks and recompresses all dense subblocks to near-optimal size via structure-preserving low-rank approximations (Li et al., 2016).
This formulation fixes the canonical mathematical meaning of a butterfly unit: a sparse, multilevel, rank-structured transformation acting between complementary scales.
2. Unified butterfly units for oscillatory integral transforms
For oscillatory integral transforms,
5
the discretized problem is 6 with 7. The relevant assumptions are that the amplitude 8 is smooth and the phase 9 is piecewise smooth in both 0 and 1 with 2 discontinuities in each variable. On suitably chosen pairs of small spatial–frequency boxes 3, the kernel is numerically low-rank, while in many important cases the phase is approximately separable,
4
The unified framework in "A Unified Framework for Oscillatory Integral Transform: When to use NUFFT or Butterfly Factorization?" automatically decides whether a NUFFT-style butterfly unit or a general butterfly factorization (BF) unit is better for applying 5 to vectors in 6 time (Yang, 2018).
The framework has three stages. First, it builds low-rank factorizations
7
If explicit formulas are known, random sampling yields these in 8. If only indirect access is available, a new low-rank matrix recovery algorithm reconstructs the phase from 9 up to a low-rank error in 0, while the amplitude is recovered from 1. The indirect-access setting includes three scenarios: 2 can be evaluated in 3 per entry; 4 and 5 can be applied to vectors in 6; or 7 are solutions of PDEs and only a few columns or rows are available from PDE solves (Yang, 2018).
Second, Algorithm 3.1 decides between NUFFT and BF in 8. It truncates the phase to rank 9,
0
and tests whether
1
has small numerical rank 2, estimated via sampling and pivoted QR. If the residual rank is below threshold 3, the kernel is declared NUFFT-applicable; otherwise the framework selects butterfly factorization. The SVD, sampling, QR, and low-rank factorization all cost 4, so the decision mechanism is a genuine 5 butterfly-router (Yang, 2018).
Third, the selected unit is applied. If NUFFT is chosen, the transform is rewritten as
6
so the computation reduces to a small number of 7-dimensional NUFFTs. Here 8 is the NUFFT dimension after lifting, even in physically one-dimensional problems, and 9 is the rank of the low-rank correction to the phase-separated kernel. If BF is chosen, the framework constructs and applies IBF-MAT, a new stable and nearly optimal butterfly factorization for kernels of the form
0
with precomputation and application both in 1 time and memory (Yang, 2018).
A central technical component is recovery of the phase modulo 2. Since
3
the goal is to find a numerically low-rank 4 such that
5
The reconstruction uses a discrete third-order total variation norm 6, a linear-time heuristic for vector recovery from modulo-7 observations, and a matrix recovery procedure that detects discontinuity patterns, partitions the matrix into smooth blocks, and then applies randomized low-rank factorization (Yang, 2018).
The resulting architecture is explicitly modular: low-rank amplitude/phase builder, NUFFT-versus-BF selector, then a NUFFT unit or a BF unit. In this setting, “unified butterfly units” refers to a shared representation of the kernel together with an automated router between specialized and general butterfly implementations.
3. Butterfly units in attention-based neural networks and hardware co-design
In attention-based neural networks, "Adaptable Butterfly Accelerator for Attention-based NNs via Hardware and Algorithm Co-design" defines a butterfly matrix 8 as a product of sparse butterfly factors. Each factor is a 9 block matrix with diagonal blocks, and the nonzeros form the familiar butterfly connectivity pattern: at each stage, pairs of coordinates interact via a 0 transform. Applying 1 to a vector has depth 2, per-stage work 3, and total complexity 4. FFT is a specific case of this structure, since the Cooley–Tukey FFT can be written as a product of such butterfly factors whose diagonals implement complex twiddle factors (Fan et al., 2022).
FABNet uses a unified butterfly sparsity pattern to approximate both the attention mechanism and the FFNs. It has two butterfly-based block types. The Attention Butterfly block (ABfly) keeps a standard multi-head attention module but replaces all surrounding linear layers by butterfly-structured ones: 5 with each projection factored into butterfly stages, and
6
The Fourier Butterfly block (FBfly) replaces the entire attention mechanism with a 2‑D FFT, implemented as two 1‑D FFTs along sequence and feature dimensions,
7
followed again by butterfly-structured FFNs (Fan et al., 2022).
At the algorithmic level, FABNet uses a generic butterfly transform operator
8
where each stage applies, in parallel, a set of 2‑point transforms. The implemented real butterfly formula is
9
For FFT, the operator has the same shape but the weights obey FFT constraints and are fixed or precomputed twiddles. Q/K/V projections, attention output projections, FFN layers, and FFT-based mixing operations all share this butterfly primitive (Fan et al., 2022).
At the hardware level, the unified butterfly unit is an adaptable Butterfly Unit (BU) inside an adaptable butterfly engine. Each BU contains 4 real multipliers, 2 real adders, and 2 complex adders/subtractors. In butterfly-linear mode, it implements the real butterfly formula above. In FFT mode, with
0
the BU computes
1
Control signals configure each BU to operate in FFT or butterfly-linear mode, so the same physical multipliers and adders are reused for both (Fan et al., 2022).
The accelerator comprises a Butterfly Processor with Butterfly Engines and Butterfly Units, an Attention Processor containing QK and SV units, a Post-processing Processor for layer normalization and residual additions, on-chip buffers, and off-chip memory. It also includes a butterfly memory system with a custom data layout, an index coalescing module, and runtime-configurable address mappings that allow the same physical buffers to service both FFT and butterfly layers. Fine-grained pipelining overlaps Q/K/V generation, 2, softmax, and 3 (Fan et al., 2022).
Quantitatively, on the Long-Range-Arena dataset, FABNet achieves the same accuracy as the vanilla Transformer while reducing the amount of computation by 10 to 66 times and the number of parameters 2 to 22 times. By jointly optimizing the algorithm and hardware, the FPGA-based butterfly accelerator achieves 14.2 to 23.2 times speedup over state-of-the-art accelerators normalized to the same computational budget. Compared with optimized CPU and GPU designs on Raspberry Pi 4 and Jetson Nano, the system is up to 273.8 and 15.1 times faster under the same power budget (Fan et al., 2022).
In this domain, a unified butterfly unit is simultaneously a model primitive, a hardware primitive, and a scheduling primitive.
4. Unified butterfly units for NTT and INTT in post-quantum cryptography
For radix‑2 NTT/INTT butterflies, the forward Cooley–Tukey butterfly is
4
and the inverse Gentleman–Sande butterfly is
5
"High-Performance NTT Accelerators for PQC leveraging Unified Redundant Arithmetic and Fine-Tuned Microarchitecture" defines a unified butterfly unit as a single processing element that implements both NTT and INTT butterflies in one structure, uses the same Montgomery multiplier, adders and subtractors for both directions, shares pipeline and control, and operates in a carefully chosen redundant Montgomery representation (Alexakis et al., 1 Jul 2026).
All internal values are represented in Montgomery form 6 with a redundant range
7
For the subtract input to the Montgomery multiplier in INTT, the design temporarily allows
8
The analysis imposes 9, with 0 chosen as the smallest power of two greater than 1, so the internal datapath width is
2
Under these bounds, the Montgomery result is guaranteed to lie in the same redundant range 3 without any final conditional subtraction. Consequently, the post-multiplication correction is removed for both 4 in NTT mode and 5 in INTT mode, and the subtractor correction feeding the multiplier can also be dropped (Alexakis et al., 1 Jul 2026).
The INTT scaling is integrated into existing arithmetic hardware. One divide‑by‑2 is removed by precomputing INTT twiddle factors as
6
The second division by 2 is merged into the adder’s correction logic by case analysis on range and parity of 7. For example, if 8 and odd, the block computes
9
while if 00 and odd, it computes
01
The divider is therefore no longer an explicit module; it is merged into the adder’s correction logic (Alexakis et al., 1 Jul 2026).
The final unified butterfly has input registers, an adder, a subtractor plus bias 02, a hierarchical DSP-based Montgomery multiplier, an Add/Div2 unit, and output registers. In NTT mode it computes
03
then performs final add and subtract with correction to keep outputs in 04. In INTT mode it computes
05
while the top path yields 06 in the same redundant range (Alexakis et al., 1 Jul 2026).
The Montgomery multiplier is redesigned as a DSP-centric hierarchical unit. For small widths up to 17 bits, a complete Montgomery multiplier uses 3 DSPs per multiplier. For a generic 34-bit Montgomery datapath supporting up to 31-bit moduli with redundancy, the multiplier uses 11 DSP blocks and 6 pipeline stages. The resulting unified butterfly frequency reaches up to 437 MHz for 17-bit BFUs on Virtex‑7, about 391 MHz for 34-bit BFUs on Virtex‑7, up to 905 MHz for 17-bit BFUs on Alveo U200, and about 496 MHz for 34-bit BFUs on Alveo U200 (Alexakis et al., 1 Jul 2026).
At system level, the accelerator is a parallel iterative NTT/INTT architecture with a multi-banked BRAM coefficient memory, conflict-free mapping and addressing, and an array of 07 processing elements, each processing element being one unified butterfly. The same PE array is reused iteratively for all 08 stages, and a mode bit selects NTT or INTT. The 17-bit BFU variant supports Kyber, Falcon, and NewHope; the 34-bit BFU variant supports moduli up to 31 bits, including Dilithium’s 23-bit modulus. Reported execution time reductions are 35–73% depending on 09 and 10 compared with comparable state-of-the-art architectures (Alexakis et al., 1 Jul 2026).
Here, a unified butterfly unit is a direction-switchable modular-arithmetic processing element whose correctness hinges on a shared redundant range and whose efficiency hinges on removal of intermediate corrections.
5. Butterfly units in distributed quantum computation
In distributed quantum computation, the butterfly is a directed network with six nodes and seven edges: 11 Each edge can be chosen to be either a single-use, one-way quantum channel that can carry 1 qubit, or a single-use, one-way classical channel that can carry 2 classical bits. Local operations are free. The task is deterministic implementation of a two-qubit global unitary
12
on two unknown inputs given at 13 and 14, with outputs at 15 and 16 (Soeda et al., 2010).
The central characterization is: in Hayashi’s butterfly setting, with no additional entanglement resource, a two-qubit global unitary 17 is deterministically implementable over the butterfly network if and only if 18 is locally unitary equivalent to a controlled unitary operation. A controlled unitary has the form
19
and a controlled phase is
20
The implementability boundary is proved using the Schmidt number of
21
If 22 is locally equivalent to a controlled unitary, the resulting state has Schmidt number 23; otherwise it has Schmidt number 24. The butterfly network without ebits cannot deterministically create the required Schmidt rank‑4 pure state under the channel constraints (Soeda et al., 2010).
The zero-ebit protocol for controlled phases uses the channel assignment: 25 quantum; 26 a 2-bit classical channel; 27 each used as 1-bit classical channels. It entangles the logical wires via the bottleneck 28 using classical bits derived from computational-basis measurements, sends one quantum wire from 29 to 30 via 31 and one from 32 to 33 via 34, and applies conditional single-qubit corrections at 35 and 36. Because every controlled unitary is locally equivalent to some controlled phase, this yields a Butterfly Controlled-Unitary Primitive (0-ebit unit) (Soeda et al., 2010).
The resource pattern is also optimal. Controlled unitaries cannot be implemented if the number of quantum channels is fewer than four, if a different subset of edges is chosen as quantum, if 37 is reduced below a 2-bit classical channel, or if either 38 or 39 is absent. The minimal channel pattern is therefore: quantum 40; classical 41 with 2 bits; classical 42 with at least 1 bit each (Soeda et al., 2010).
With 1 ebit between 43 and 44, the network can implement controlled traceless unitaries under a slightly weakened channel assumption. A controlled traceless unitary can be written as
45
The key algebraic condition
46
permits rerouting of control dependencies, producing a Butterfly Controlled-Traceless Unit (1-ebit) (Soeda et al., 2010).
With 2 ebits between 47 and 48, and channels chosen as in Hayashi’s swap protocol, the network implements the full 2-qubit Clifford group. The construction uses Bell measurements, Pauli-frame propagation through a Clifford unitary 49, and final Pauli corrections depending on transmitted classical bits, yielding a Butterfly Global Clifford Unit (2-ebit). These units form a resource-ordered hierarchy
50
The paper also notes that the set of implementable unitaries in the 0-ebit regime is not closed under composition unless extra resources are added (Soeda et al., 2010).
In this setting, a unified butterfly unit is a network-level gate family parameterized by channel capacities and initial entanglement resources.
6. Cross-domain synthesis, limits, and common design principles
Across these literatures, the butterfly unit is always a multistage structure with sparse local interactions, but the meaning of “unit” changes with the application. In IBF and oscillatory integral transforms, the unit is a level-wise sparse matrix factor with 51 nonzeros, assembled into an 52 factorization (Li et al., 2016). In the unified oscillatory-transform framework, the unit is either a NUFFT butterfly or a general BF/IBF-MAT butterfly, selected by an 53 decision algorithm (Yang, 2018). In FABNet, the unit is a parameterized butterfly transform operator and an adaptable hardware cell that switches between FFT and butterfly-linear mode (Fan et al., 2022). In PQC accelerators, the unit is a shared NTT/INTT processing element with redundant Montgomery arithmetic and mode-dependent control (Alexakis et al., 1 Jul 2026). In distributed quantum computation, the unit is a maximal class of implementable two-qubit unitaries over a fixed butterfly topology and resource profile (Soeda et al., 2010).
Several limitations are explicit. In the oscillatory-transform setting, NUFFT is used only when the residual
54
has sufficiently small numerical rank; otherwise the framework falls back to BF/IBF-MAT (Yang, 2018). In FABNet, self-attention’s quadratic term in sequence length remains in ABfly, FABNet still retains some full attention blocks for accuracy, the butterfly pattern is static, and only 16-bit floating point is used (Fan et al., 2022). In the PQC setting, redundancy adds 3 bits to coefficient width and slightly more LUTs and FFs, and for large 55 arrays the frequency drops due to routing pressure (Alexakis et al., 1 Jul 2026). In the quantum setting, swap and generic non-controlled unitaries are impossible without ebits, and composition of 0-ebit units does not in general stay within the locally controlled-equivalent class (Soeda et al., 2010).
A plausible implication is that “Unified Butterfly Units” is best understood not as a single algorithm but as a reusable design pattern. The invariant ingredients are a butterfly connectivity pattern, a small set of mode-dependent local transforms, and a control layer that decides which butterfly behavior is valid under the available structure. In the mathematical formulations this structure is complementary low rank or approximate phase separability; in the hardware formulations it is the reuse of the same multipliers, adders, and memory system across closely related butterfly modes; in the quantum formulation it is the sharp relation between channel capacities, entanglement resources, and the maximal implementable gate family.
This suggests a unifying technical definition: a unified butterfly unit is a butterfly-structured primitive whose topology is fixed, whose internal coefficients or arithmetic mode are reconfigurable, and whose efficiency derives from preserving a sparse multistage pattern while specializing only the local transfer rules.