fhelium.backend.rns.tables
RNS quotient tables and depth-indexed rescaling data.
centered_basis_extension_tables
function View source
def centered_basis_extension_tables(source: RnsContext, target: RnsContext, source_prime_ids: tuple[int, ...], target_prime_ids: tuple[int, ...]) -> dict[str, torch.Tensor]: ...Prepare Garner and centered-extension operands for two residue bases.
Source and destination use the same word format and device. For source product Q, subtraction of Q mod p recenters the upper CRT half in each target row p. All row parameters and half digits are ordinary tensors; execution does not retain either preparation context.
rescale_inverse_matrix
function View source
def rescale_inverse_matrix(rns_context: RnsContext) -> torch.Tensor: ...trailing_quotient_inverses
function View source
def trailing_quotient_inverses(moduli: tuple[int, ...], drop_count: int, radix: int, *, dtype: torch.dtype, device: torch.device) -> torch.Tensor: ...Build
Row j removes the j-th prime from the end. Only columns before that prime participate; unused columns are zero.
moddown_inverse_tables
function View source
def moddown_inverse_tables(rns_context: RnsContext) -> tuple[torch.Tensor, ...]: ...RescaleTables
class View source
RescaleTables(rns_context: RnsContext, dropped_prime_inverses_montgomery: torch.Tensor)Own pairwise and prefix-product inverses used by RNS rescaling.
Attributes
| Name | Type | Default/value |
|---|---|---|
rns_context | RnsContext | |
dropped_prime_inverses_montgomery | torch.Tensor |
device
property
device: torch.deviceactive_views
method
def active_views(row_count: int, *, include_p: bool) -> tuple[torch.Tensor, torch.Tensor, int]: ...Return preselected parameters, inverses, and dropped modulus.
prefix_inverse
method
def prefix_inverse(row_count: int, drop_count: int, *, include_p: bool) -> torch.Tensor: ...Return
drop_count active primes. The resource retains the vector for reuse with the same prime interval.
tensor_operands
method
def tensor_operands(row_count: int, drop_count: int, *, include_p: bool, ntt_context: NttContext | None=None) -> tuple[dict[str, torch.Tensor], dict[str, object]]: ...Expose quotient tables and scalar rounding offsets for one group.
MODDOWN_RESCALE_TABLE_NAMES
constant View source
MODDOWN_RESCALE_TABLE_NAMES = ('joint_remaining_parameters', 'joint_dropped_parameters', 'joint_ordered_parameters', 'joint_p_times_base', 'joint_inverses', 'joint_product_inverse', 'joint_dropped_offset', 'joint_remaining_offset', 'joint_drop_positions', 'joint_remaining_positions')moddown_rescale_tables
function View source
def moddown_rescale_tables(context: RnsContext, q_prime_ids: tuple[int, ...], p_prime_ids: tuple[int, ...], drop_prime_ids: tuple[int, ...], *, moddown_rounding: str='nearest', rescale_rounding: str='nearest') -> dict[str, torch.Tensor]: ...Prepare the exact quotient of
Q and P identify actual ordered input rows; D identifies the complete group consumed by rescaling. The remaining Q rows retain their input order. All returned values are ordinary numerical Tensors on this RNS context's device.