fhelium.backend.ckks.key_switch
Compose hybrid RNS key switching for CKKS ciphertext components.
key_switch_corrections
function View source
python
def key_switch_corrections(source: torch.Tensor, *, tensors: Mapping[str, torch.Tensor], attributes: Mapping[str, object], key: torch.Tensor, output_ntt: bool=False, coefficient_c0: torch.Tensor | None=None) -> torch.Tensor: ...1
Stream hybrid digit products into QP accumulators and remove P.
NativeKeySwitchImplementation
class View source
python
NativeKeySwitchImplementation(supports_in_place: bool = False, name: str = 'native-key-switch-streaming', operation_types: tuple[type[Operation], ...] = (ckks.SwitchKeyOp, ckks.ConjugateOp))1
Switch CT2 secret relations with a shared streaming QP accumulator.
For input phase
Attributes
| Name | Type | Default/value |
|---|---|---|
supports_in_place | bool | False |
name | str | 'native-key-switch-streaming' |
operation_types | tuple[type[Operation], ...] | (ckks.SwitchKeyOp, ckks.ConjugateOp) |
tensor_requirements | staticmethod(native_key_switch_requirements) | |
prepare_operation | prepare_native_key_switch |
resource_requirements
method
python
def resource_requirements(invocation: OperationInvocation) -> tuple[ResourceRequirement, ...]: ...1
execute
method
python
def execute(invocation: OperationInvocation, inputs: tuple[torch.Tensor, ...], resources: tuple[BoundResource, ...], *, in_place: bool) -> tuple[torch.Tensor, ...]: ...1
NativeRelinearizeImplementation
class View source
python
NativeRelinearizeImplementation(supports_in_place: bool = False, name: str = 'native-relinearize-streaming', operation_types: tuple[type[Operation], ...] = (ckks.RelinearizeOp,))1
Relinearize CT3 through one streaming hybrid key-switch schedule.
Attributes
| Name | Type | Default/value |
|---|---|---|
supports_in_place | bool | False |
name | str | 'native-relinearize-streaming' |
operation_types | tuple[type[Operation], ...] | (ckks.RelinearizeOp,) |
tensor_requirements | staticmethod(native_key_switch_requirements) | |
prepare_operation | prepare_native_key_switch |
resource_requirements
method
python
def resource_requirements(invocation: OperationInvocation) -> tuple[ResourceRequirement, ...]: ...1
execute
method
python
def execute(invocation: OperationInvocation, inputs: tuple[torch.Tensor, ...], resources: tuple[BoundResource, ...], *, in_place: bool) -> tuple[torch.Tensor, ...]: ...1