fhelium.engine.direct_keyswitch_consumer
Execution adapters that consume one direct key-switch digit.
DirectKeySwitchDigitConsumer
class View source
DirectKeySwitchDigitConsumer()Bases: Protocol
Consume one coefficient-domain QP digit into two accumulators.
The hybrid key-switch executor owns digit production and lifetime. A consumer owns only the representation transition and multiply-accumulate, which is the exact operation that an ordinary two-kernel implementation and a fused native implementation may differ.
digit_qp and both accumulators are integral [*batch, limb, coefficient_or_ntt_index] tensors whose limb order is the same exact active key_digit[key_component, limb, ntt_index] into the two NTT/Montgomery accumulators. parameter_row_start maps local digit rows to parameter prime ids; key_row_start independently maps them to key storage. No input tensors may alias one another.
consume_
method
def consume_(digit_qp: torch.Tensor, key_digit: torch.Tensor, accumulator0_qp: torch.Tensor, accumulator1_qp: torch.Tensor, *, parameter_row_start: int, key_row_start: int) -> None: ...Transform and consume digit_qp without retaining it.
Mutates digit_qp, accumulator0_qp, and accumulator1_qp; key material and parameter/twiddle tables remain read-only.
StandardDirectKeySwitchDigitConsumer
class View source
StandardDirectKeySwitchDigitConsumer(rns_runtime: RnsRuntime)Use an arbitrary NTT backend followed by the shared KSK accumulator.
Attributes
| Name | Type | Default/value |
|---|---|---|
rns_runtime | RnsRuntime |
consume_
method
def consume_(digit_qp: torch.Tensor, key_digit: torch.Tensor, accumulator0_qp: torch.Tensor, accumulator1_qp: torch.Tensor, *, parameter_row_start: int, key_row_start: int) -> None: ...CompactTailFusedDirectKeySwitchDigitConsumer
class View source
CompactTailFusedDirectKeySwitchDigitConsumer(backend: CompactRadix2NttBackend)Fuse the validated compact final-eight-stage NTT into KSK consume.
Attributes
| Name | Type | Default/value |
|---|---|---|
backend | CompactRadix2NttBackend |
consume_
method
def consume_(digit_qp: torch.Tensor, key_digit: torch.Tensor, accumulator0_qp: torch.Tensor, accumulator1_qp: torch.Tensor, *, parameter_row_start: int, key_row_start: int) -> None: ...create_direct_keyswitch_digit_consumer
function View source
def create_direct_keyswitch_digit_consumer(rns_runtime: RnsRuntime) -> DirectKeySwitchDigitConsumer: ...Bind one direct digit consumer when the engine is constructed.
Concrete-backend inspection is confined to this construction function. The key-switch hot path receives one stable protocol implementation and performs no capability discovery or backend-name dispatch.