fhelium.compile.passes.lowering
Define shared CKKS lowering and its compile-pass adapter.
The package decomposes CKKS operations into logical RNS/NTT operations. LowerCkksToRnsNttPass applies caller-selected decompositions; SelectExecutionLoweringsPass chooses locally between whole-operation coverage and registered lowerings. Callers can also invoke the lowering library directly.
CkksLoweringDefinition
class View source
CkksLoweringDefinition(name: str, operation_type: type[Operation], lower: CkksLowering, is_default: bool = False)Declare one named CKKS lowering beside its implementation.
Attributes
| Name | Type | Default/value |
|---|---|---|
name | str | |
operation_type | type[Operation] | |
lower | CkksLowering | |
is_default | bool | False |
CkksLoweringRegistry
class View source
CkksLoweringRegistry(definitions: Sequence[CkksLoweringDefinition]=(), *, operation_specs: OperationSpecRegistry=DEFAULT_OPERATION_SPECS)Resolve implementation-local lowerings by operation class and name.
supports
method
def supports(operation: Operation) -> bool: ...Return whether one operation has a registered CKKS lowering.
definitions
property
definitions: tuple[CkksLoweringDefinition, ...]Return lowering declarations in registry order.
operation_types
property
operation_types: tuple[type[Operation], ...]Return CKKS operation classes with shared lowering definitions.
available
method
def available(operation_type: type[Operation]) -> tuple[str, ...]: ...Return registered lowering names for one operation class.
resolve
method
def resolve(operation_type: type[Operation], requested: str | None=None) -> CkksLoweringDefinition: ...Resolve a requested, default, or unambiguous lowering.
lower
method
def lower(operation: Operation, config: CkksConfig | None, compilation: Compilation, *, requested: str | None=None) -> LoweredCkksOperation: ...Apply one selected lowering without choosing an implementation.
DEFAULT_CKKS_LOWERINGS
constant View source
DEFAULT_CKKS_LOWERINGS = CkksLoweringRegistry((*ARITHMETIC_LOWERINGS, *REPRESENTATION_LOWERINGS, *KEY_SWITCH_LOWERINGS))LowerCkksToRnsNttPass
class View source
LowerCkksToRnsNttPass(selections: Mapping[str, str] = field(default_factory=dict), preserve: frozenset[str] = frozenset(), registry: CkksLoweringRegistry = DEFAULT_CKKS_LOWERINGS)Apply caller-selected CKKS-to-RNS/NTT lowering definitions.
Attributes
| Name | Type | Default/value |
|---|---|---|
selections | Mapping[str, str] | field(default_factory=dict) |
preserve | frozenset[str] | frozenset() |
registry | CkksLoweringRegistry | DEFAULT_CKKS_LOWERINGS |
name | str | field(default='lower-ckks-to-rns-ntt', init=False) |
run
method
def run(compilation: 'Compilation') -> PassResult: ...SelectExecutionLoweringsPass
class View source
SelectExecutionLoweringsPass(implementations: OperationImplementationRegistry, fusion_implementations: Sequence[FusionImplementation] = (), lowerings: CkksLoweringRegistry = DEFAULT_CKKS_LOWERINGS, allow_partial_fusion: bool = True, name: str = 'select-execution-lowerings')Keep applicable whole operations or expose a supported fusion expression.
A supplied implementation assignment is local to its operation. Unassigned operations without whole-operation coverage require lowering. Where both routes exist, a detached lowering probe is accepted only when a fusion implementation supports the complete expression. With partial fusion enabled, supported subregions may instead be combined with independent implementations for the remaining operations.
Attributes
| Name | Type | Default/value |
|---|---|---|
implementations | OperationImplementationRegistry | |
fusion_implementations | Sequence[FusionImplementation] | () |
lowerings | CkksLoweringRegistry | DEFAULT_CKKS_LOWERINGS |
allow_partial_fusion | bool | True |
name | str | 'select-execution-lowerings' |
run
method
def run(compilation: 'Compilation') -> PassResult: ...LoweredCkksOperation
class View source
LoweredCkksOperation(operations: tuple[Operation, ...], result: SSAValue, material_descriptions: dict[str, dict[str, object]] = field(default_factory=dict))Hold replacement operations and the logical result of one CKKS op.
Attributes
| Name | Type | Default/value |
|---|---|---|
operations | tuple[Operation, ...] | |
result | SSAValue | |
material_descriptions | dict[str, dict[str, object]] | field(default_factory=dict) |
lower_ckks_program
function View source
def lower_ckks_program(compilation, config: CkksConfig | None, *, registry: CkksLoweringRegistry=DEFAULT_CKKS_LOWERINGS, selections: Mapping[str, str] | None=None, preserve: Collection[str]=()) -> _LoweringResult: ...Apply selected CKKS lowerings while preserving other mixed-level IR.