fhelium.compile.frontend._specs
Semantic input-role declarations for source capture.
BatchMode
type alias View source
BatchMode = Literal['none', 'any']InputSpec
class View source
InputSpec(role: ValueRole, depth: int = 0, scale: float | None = None, slots: SlotExtent = 'full', batch_mode: BatchMode = 'none', polynomial_domain: PolynomialDomainSpec | None = None, residue_representation: ResidueRepresentationSpec | None = None, static_value: StaticValue = None)Declare one function input's role in the PyTorch-to-FHE interface.
encrypted declares a logical slot extent, batch policy, depth, and scale for a runtime Tensor or core Ciphertext. message declares public Python/PyTorch data passed through directly until an plaintext-preparation operation consumes it. plaintext declares a caller-owned core Plaintext whose state is validated at its encrypted consumer. static declares an immutable scalar specialized during capture and removed from the Program's runtime argument list.
Attributes
| Name | Type | Default/value |
|---|---|---|
role | ValueRole | |
depth | int | 0 |
scale | float | None | None |
slots | SlotExtent | 'full' |
batch_mode | BatchMode | 'none' |
polynomial_domain | PolynomialDomainSpec | None | None |
residue_representation | ResidueRepresentationSpec | None | None |
static_value | StaticValue | None |
SlotExtent
data View source
SlotExtent = int | Literal['full']StaticValue
data View source
StaticValue = bool | int | float | complex | str | NoneValueRole
type alias View source
ValueRole = Literal['encrypted', 'message', 'plaintext', 'static']encrypted
function View source
def encrypted(*, depth: int=0, scale: float | None=None, slots: SlotExtent='full', batch_mode: BatchMode='none', polynomial_domain: PolynomialDomainSpec | None=None, residue_representation: ResidueRepresentationSpec | None=None) -> InputSpec: ...Declare a secret slot input accepted as Tensor or Ciphertext.
depth and a non-None scale define the runtime CKKS input state; scale=None selects the execution Engine's default scale. slots specifies either the engine's full capacity or a final-axis extent. batch_mode='none' requires a one-dimensional Tensor and an unbatched Ciphertext; 'any' permits leading batch axes.
polynomial_domain and residue_representation may jointly declare a coefficient/standard or NTT/Montgomery input contract; omitting both leaves representation assignment to later passes.
These fields are frontend metadata. Later transforms and runtimes may use, refine, ignore, or diagnose them according to caller-selected policy. The callable retained by CapturedCallable.reference consumes its ordinary public Tensor argument.
message
function View source
def message() -> InputSpec: ...Declare public Tensor/scalar data processed by ordinary PyTorch.
Message-only subgraphs execute as public calls. A mixed encrypted operation introduces operation-specific encoding and plaintext preparation; that preparation derives the required CKKS representation from its ciphertext consumer.
plaintext
function View source
def plaintext() -> InputSpec: ...Declare a caller-owned FHElium Plaintext with runtime state.
Capture records this role without requiring a live core Plaintext. Runtime binding and state analysis are separate consumers. The callable used by CapturedCallable.reference consumes the public Tensor or scalar shadow supplied by the caller.
static
function View source
def static(value: StaticValue) -> InputSpec: ...Specialize an immutable scalar Python input during capture.
A finite bool, int, float, complex, str, or None value participates in Python control and graph construction. Capture stores its serialized value in Program metadata and removes the parameter from CapturedCallable.runtime_signature and Program execution inputs.