Encrypted GELU

L4 · Application Components
gelu · 1 specification · 0 implementations · no benchmarks yet
WHAT IT ISEvaluate the GELU activation on an encrypted real vector under CKKS.
CKKS
SIGNATURE
kernel gelu<N: u32>(
%xs: secret<tensor<N x f64>>,
) -> %ys: secret<tensor<N x f64>>
Sizes and element types are left open here. A specification fixes them; an implementation says over which of them it works.
DESCRIPTION

Definition

The Gaussian Error Linear Unit applied element by element to a secret vector. For a real vector x=(x0,,xN1)x = (x_0, \ldots, x_{N-1}), the result yy has

yi=xiΦ(xi),0i<N,y_i = x_i \,\Phi(x_i), \qquad 0 \le i < N,

where Φ\Phi is the cumulative distribution function of the standard normal distribution. Equivalently,

yi=12xi(1+erf ⁣(xi2)).y_i = \tfrac{1}{2}\,x_i\left(1 + \operatorname{erf}\!\left(\tfrac{x_i}{\sqrt{2}}\right)\right).

Each output element depends only on the corresponding input element. There is no interaction between positions and no reduction across the vector.

Mathematical Domain

GELU is a smooth activation: unlike the hard corner of ReLU it is differentiable everywhere, weighting each input by the probability that a standard normal variable falls below it. It is transcendental — defined through the error function — so it cannot be expressed as a polynomial. Arithmetic homomorphic encryption schemes evaluate only polynomials, so an implementation approximates GELU by a polynomial over a bounded input range.

The kernel fixes neither the input range, the vector length, nor the packing; these are defined by individual specifications.

Parameters Defined by Specifications

A specification narrows the general GELU operation into a concrete problem by pinning:

  • the element domain and encryption scheme
  • the input range on which the approximation must hold
  • the vector length NN
  • the ciphertext packing and layout
  • the correctness or accuracy rule and how it is scored
  • which stages of the computation are timed

Applications

GELU is the standard activation of transformer models: it appears in the feed-forward block of each layer in architectures such as BERT and the GPT family. Private inference over these models needs an encrypted GELU wherever such a feed-forward block is evaluated.

MAINTAINER
FM
fairmathreviews specifications · resolves disputes
USED BY · 0 KERNELS
Kernels above this one. If this kernel is wrong, or slow, they are wrong or slow with it.Nothing depends on this kernel yet.
BUILDS ON · 0 KERNELS
Kernels this one is stated in terms of. Not a call graph — a statement of dependence between problems.Nothing. This kernel sits at the bottom of the graph.
RECENT ACTIVITYNothing yet.