fhelium.backend.ckks.materialization
Prepare one device's CKKS numerical tables and sampling state.
CkksDeviceResources
class View source
CkksDeviceResources(*, config: CkksConfig, device: str | torch.device, rns_layout: RnsLayout | None=None, ntt_backend: str | None=None, rng_seed: int | None=None, rng_nonce: int | None=None, rns_dtype: torch.dtype | None=None)Own lazily constructed CKKS resources for one concrete device.
The default RNS layout follows the configuration's Q depth groups and hybrid decomposition. Callers can supply an existing layout for reuse.
rns_context
property
rns_context: RnsContextReturn the device's RNS arithmetic context.
ntt_context
property
ntt_context: NttContextReturn the NTT context composed with this device's RNS context.
rng
property
rng: CsprngReturn the stateful random stream assigned to this device.
key_generation
property
key_generation: KeyGenerationResourceReturn the resources used to generate keys on this device.
periodic_encode_operands
method
def periodic_encode_operands(period: int, depth: int, basis: str): ...Return compact tables and the existing live rounding stream.
encode_operands
method
def encode_operands() -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]: ...Return the inverse-embedding permutation, twister, and live rounding state.
decode_operands
method
def decode_operands() -> tuple[torch.Tensor, torch.Tensor]: ...Return the coefficient-embedding permutation and skewer.
key_switch_operands
method
def key_switch_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]]: ...Prepare Tensor views and digit ranges for a hybrid key switch.
rotation_sum_tables
method
def rotation_sum_tables(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 and retain deterministic rotation-sum quotient tables.
modulus_raise_operands
method
def modulus_raise_operands(source_depth: int, target_depth: int) -> tuple[dict[str, torch.Tensor], dict[str, object]]: ...Prepare centered-extension operands on this configuration's Q chain.
encapsulated_modulus_raise_operands
method
def encapsulated_modulus_raise_operands(source_depth: int, target_depth: int, low_p_moduli: tuple[int, ...], return_prime: int, return_p_moduli: tuple[int, ...], *, rounding: str='nearest') -> tuple[dict[str, torch.Tensor], dict[str, object]]: ...Prepare low-switch, centered extension and return-switch operands.
rescale_operands
method
def rescale_operands(row_count: int, drop_count: int, *, include_p: bool=False, input_domain: str='coefficient') -> tuple[dict[str, torch.Tensor], dict[str, object]]: ...Prepare quotient and transform tables for one rescale group.
reconstruction_operands
method
def reconstruction_operands(depth: int) -> tuple[torch.Tensor, ...]: ...Prepare Q parameters and centered mixed-radix reconstruction tables.
bindings
property
bindings: ResourceBindingsReturn this device's bindable random-stream execution resource.
materialize
method
def materialize(requirements: tuple[ResourceRequirement, ...], /) -> ResourceBindings: ...Return all constructible missing resources in one batch.