fhelium.backend.rns.modup
Hybrid-digit decomposition and RNS basis extension.
modup_digit
function View source
def modup_digit(source: torch.Tensor, tensors: Mapping[str, torch.Tensor], digit_index: int, span: tuple[int, int, int], *, out: torch.Tensor | None=None, scratch: torch.Tensor | None=None) -> torch.Tensor: ...Extend one coefficient digit to QP Montgomery residues.
Garner decomposition represents the selected source residues as mixed-radix digits; basis extension evaluates those digits modulo each target prime and multiplies by its Montgomery radix. out receives the QP result when supplied. scratch receives the decomposition and has the source batch and coefficient dimensions with at least stop - start rows. Neither buffer may overlap the read operands or the other buffer. Without these buffers, the corresponding native operations allocate their outputs.
Multi-prime CUDA digits use a shared-memory coefficient tile when its decomposition, extension, and parameter data fit 48 KiB and the caller supplies no decomposition scratch. Single-prime digits, CPU/HIP, larger tiles, and caller-supplied scratch use the separate native operations. Both routes read the supplied numerical tables and preserve the same lazy residues.
NativeHybridModUpImplementation
class View source
NativeHybridModUpImplementation(name: str = 'native-hybrid-modup', supports_in_place: bool = False, operation_types: tuple[type[Operation], ...] = (rns.HybridModUpDigitOp,))Execute one represented hybrid-digit ModUp using concrete RNS tables.
Attributes
| Name | Type | Default/value |
|---|---|---|
name | str | 'native-hybrid-modup' |
supports_in_place | bool | False |
operation_types | tuple[type[Operation], ...] | (rns.HybridModUpDigitOp,) |
resource_requirements
method
def resource_requirements(invocation: OperationInvocation) -> tuple[ResourceRequirement, ...]: ...execute
method
def execute(invocation: OperationInvocation, values: tuple[torch.Tensor, ...], resources: tuple[BoundResource, ...], *, in_place: bool) -> tuple[torch.Tensor, ...]: ...