fhelium.backend.ckks.codec._embedding
CKKS slot and coefficient embeddings for fixed-context codecs.
The functions in this module implement the generator-3 and generator-5 slot orders, the conjugate-symmetric negacyclic FFT embedding, and stochastic coefficient quantization. They operate on tensors and store no runtime state.
make_slot_tensor
function View source
python
def make_slot_tensor(message: Sequence[object] | torch.Tensor | complex | float | int, num_slots: int, device: torch.device) -> torch.Tensor: ...1
Return a dense [*batch, slot] tensor with a full slot axis.
inverse_embed_slots
function View source
python
def inverse_embed_slots(message: torch.Tensor, *, pre: torch.Tensor, twister: torch.Tensor) -> torch.Tensor: ...1
Map ordered slots to real coefficients using supplied embedding tables.
embed_coefficients
function View source
python
def embed_coefficients(coefficients: torch.Tensor, *, post: torch.Tensor, skewer: torch.Tensor) -> torch.Tensor: ...1
Map real coefficients to the selected complex CKKS slot order.
encode_slots
function View source
python
def encode_slots(message: torch.Tensor, *, pre: torch.Tensor, twister: torch.Tensor, rounding_state: torch.Tensor, scale: float) -> torch.Tensor: ...1
Stochastically quantize the inverse slot embedding with a live stream.
decode_slots
function View source
python
def decode_slots(coefficients: torch.Tensor, *, post: torch.Tensor, skewer: torch.Tensor, scale: float) -> torch.Tensor: ...1
Recover ordered complex slots from scaled coefficients.