fhelium.backend.ckks.tables
Tensor views used by complete hybrid CKKS key-switch implementations.
encapsulation_configs
function View source
def encapsulation_configs(config: CkksConfig, source_depth: int, low_p_moduli: tuple[int, ...], return_prime: int, return_p_moduli: tuple[int, ...]) -> tuple[CkksConfig, CkksConfig]: ...Describe the low switch basis and guard-prime return basis.
prepare_encapsulated_raise_operands
function View source
def prepare_encapsulated_raise_operands(rns_context, ntt_context, *, source_depth: int, target_depth: int, low_p_moduli: tuple[int, ...], return_prime: int, return_p_moduli: tuple[int, ...], rounding: str) -> tuple[dict[str, torch.Tensor], dict[str, object]]: ...Prepare low key-switch, centered extension and return-quotient tables.
The return hint uses [guard, Q, P] rows and one digit. Its relation is H0+H1s = guardP*t+e; quotient row order is [Q, guard, P]. Neither preparation context is retained by the returned numerical operands.
KeySwitchTables
class View source
KeySwitchTables(rns_context: RnsContext, ntt_context: NttContext | None, moddown_p_drop_inverses_montgomery_by_depth: tuple[torch.Tensor, ...] = (), galois_generator: int = 3)Own the tables used by hybrid CKKS key switching.
Attributes
| Name | Type | Default/value |
|---|---|---|
rns_context | RnsContext | |
ntt_context | NttContext | None | |
moddown_p_drop_inverses_montgomery_by_depth | tuple[torch.Tensor, ...] | () |
galois_generator | int | 3 |
p_inverse_montgomery
property
p_inverse_montgomery: torch.TensorPrepare the P-only inverse vector when that quotient is selected.
device
property
device: torch.devicemoddown_tables
property
moddown_tables: tuple[torch.Tensor, ...]Return the depth-indexed P-drop inverse tables read by ModDown.
moddown_tensor_operands
method
def moddown_tensor_operands(q_ids: tuple[int, ...], p_ids: tuple[int, ...], *, rounding: str='nearest', depth: int | None=None) -> dict[str, torch.Tensor]: ...Prepare quotient data for the represented ordered Q and P rows.
tensor_operands
method
def tensor_operands(depth: int, *, moddown_rounding: str='nearest', modup_method: str='exact', rescale: bool=False, rescale_rounding: str='nearest', output_domain: str='coefficient', key_prime_ids: tuple[int, ...] | None=None, digit_prime_ids: tuple[tuple[int, ...], ...] | None=None) -> tuple[dict[str, torch.Tensor], dict[str, object]]: ...Expose the selected digit-lift tables and active key digit ranges.
Returned data can populate ordinary Program Tensor placeholders. No execution resource object is needed to consume these table views.
RotationSumTables
class View source
RotationSumTables(tensors: Mapping[str, torch.Tensor], attributes: Mapping[str, object], p_montgomery: torch.Tensor, quotient_row_order: torch.Tensor | None, quotient_parameters: torch.Tensor, quotient_inverses: torch.Tensor, quotient_half: torch.Tensor | None, remaining_q_count: int, dropped_q_count: int, divisor: int, rescale_divisor: int)Tensor operands for a shared QP key-product sum and its quotient.
divisor is P, or P times the complete leading Q depth group. The quotient row order is surviving Q, dropped Q, P. Its pairwise inverses and optional nearest-rounding offset are prepared before execution.
Attributes
| Name | Type | Default/value |
|---|---|---|
tensors | Mapping[str, torch.Tensor] | |
attributes | Mapping[str, object] | |
p_montgomery | torch.Tensor | |
quotient_row_order | torch.Tensor | None | |
quotient_parameters | torch.Tensor | |
quotient_inverses | torch.Tensor | |
quotient_half | torch.Tensor | None | |
remaining_q_count | int | |
dropped_q_count | int | |
divisor | int | |
rescale_divisor | int |
tensor_operands
method
def tensor_operands() -> dict[str, torch.Tensor]: ...Return numerical operands without retaining a preparation owner.
from_operands
method
def from_operands(values, attributes): ...Bind supplied numerical operands; never construct missing tables.
prepare_rotation_sum_tables
function View source
def prepare_rotation_sum_tables(tables: KeySwitchTables, depth: int, *, rescale: bool=False, rounding: str='nearest', modup_method: str='exact', key_prime_ids: tuple[int, ...] | None=None, digit_prime_ids: tuple[tuple[int, ...], ...] | None=None) -> RotationSumTables: ...Prepare ordinary numerical data; key material remains caller supplied.