fhelium.backend.rns.layout
Placement-independent RNS chain and hybrid-decomposition metadata.
RnsDigitSpec
class View source
RnsDigitSpec(depth: int, digit_index: int, key_digit_index: int, prime_ids: tuple[int, ...], component_row_ids: tuple[int, ...])One active hybrid-RNS digit in [Q | P] row order.
digit_index is the digit's local position at this depth. key_digit_index is its stable depth-zero key-storage position; dropped Q rows may make these values differ. prime_ids identify parameter primes, while component_row_ids index the compact depth-specific Q component tensor.
Attributes
| Name | Type | Default/value |
|---|---|---|
depth | int | |
digit_index | int | |
key_digit_index | int | |
prime_ids | tuple[int, ...] | |
component_row_ids | tuple[int, ...] |
RnsLayout
class View source
RnsLayout(chain: RnsChain, hybrid_decomposition: HybridRnsDecomposition)Mathematical Q/P layout independent of execution placement.
For any tensor [..., limb, coefficient_or_ntt_index], limb j maps exactly to prime_ids(...)[j]. include_p chooses between internal modulus_basis separately and must not expose this implementation flag.
from_config
method
def from_config(config: CkksConfig) -> RnsLayout: ...Build Q depth-group rows and hybrid digits from CKKS parameters.
key_digit_count
property
key_digit_count: intprime_ids
method
def prime_ids(depth: int, *, include_p: bool=False) -> tuple[int, ...]: ...Return modulus ids in tensor limb order.
row_count
method
def row_count(depth: int, *, include_p: bool=False) -> int: ...depth_for_active_row_count
method
def depth_for_active_row_count(row_count: int, *, include_p: bool=False) -> int: ...Return the chain position represented by one complete active basis.
Configured Q depth groups have distinct cumulative row starts, so a complete Q or QP tensor's row count identifies its chain position. A partial group, digit, or arbitrary prime interval cannot use this lookup.
start_row
method
def start_row(depth: int) -> int: ...parameter_rows
method
def parameter_rows(depth: int, *, include_p: bool=False) -> slice: ...select_values
method
def select_values(depth: int, values: Sequence[int], *, include_p: bool=False) -> tuple[int, ...]: ...Select global-prime-indexed values in the active basis order.
digit_rows
method
def digit_rows(depth: int, *, include_p: bool=False) -> tuple[tuple[int, ...], ...]: ...Parameter rows for active hybrid-RNS digits.
component_digit_rows
method
def component_digit_rows(depth: int) -> tuple[tuple[int, ...], ...]: ...Return local limb indices for each active Q decomposition digit.
digit_spec
method
def digit_spec(depth: int, digit_index: int) -> RnsDigitSpec: ...digit_specs
method
def digit_specs(depth: int) -> tuple[RnsDigitSpec, ...]: ...