fhelium.backend.triton._pointwise
Generate and execute component-aware RNS expression kernels.
compile_source
function View source
def compile_source(source: str) -> Any: ...Compile generated Python to a Triton function, retaining inspectable source.
PointwisePlan
class View source
PointwisePlan(graph: BoundGraph, materialized: tuple[ValueExpr, ...], kernel: Any, length: int)Attributes
| Name | Type | Default/value |
|---|---|---|
graph | BoundGraph | |
materialized | tuple[ValueExpr, ...] | |
kernel | Any | |
length | int |
build
method
def build(graph: BoundGraph) -> PointwisePlan: ...execute
method
def execute(inputs: tuple[torch.Tensor, ...], parameters: torch.Tensor, radix: int) -> tuple[torch.Tensor, ...]: ...execution_parameters
function View source
def execution_parameters(invocation: OperationInvocation | None, inputs: tuple[torch.Tensor, ...], parameters: torch.Tensor, *, in_place: bool) -> tuple[torch.Tensor, int]: ...PreparedFusion
class View source
PreparedFusion(graph: ExpressionGraph, name: str = 'triton-rns-fused', operation_types: tuple[type[Operation], ...] = (fusion.FusedOp,), supports_in_place: bool = False)Attributes
| Name | Type | Default/value |
|---|---|---|
graph | ExpressionGraph | |
name | str | 'triton-rns-fused' |
operation_types | tuple[type[Operation], ...] | (fusion.FusedOp,) |
supports_in_place | bool | False |
resource_requirements
method
def resource_requirements(invocation: OperationInvocation) -> tuple[ResourceRequirement, ...]: ...prepare_layout
method
def prepare_layout(operation: fusion.FusedOp) -> None: ...Prepare known physical layouts without allocating numerical storage.
execute
method
def execute(invocation, inputs, resources, *, in_place): ...TritonFusionImplementation
class View source
TritonFusionImplementation(name: str = 'triton-rns-fused', include_ntt: bool = False, operation_types: tuple[type[Operation], ...] = (fusion.FusedOp,), supports_in_place: bool = False)Generate indexed integer expression kernels from visible fusion regions.
Component extraction and packing become expression selection and output indexing. Arithmetic chains retain intermediates in registers and preserve every external result and identity-view alias. include_ntt admits compact radix-2 transform anchors; implementation names do not determine support. Match checks consume known Program facts, while missing layout/resource facts are checked when binding execution. Device compilation is lazy.
Attributes
| Name | Type | Default/value |
|---|---|---|
name | str | 'triton-rns-fused' |
include_ntt | bool | False |
operation_types | tuple[type[Operation], ...] | (fusion.FusedOp,) |
supports_in_place | bool | False |
select_ntt_schedule
method
def select_ntt_schedule(**facts): ...Offer compact schedules when this region implementation admits NTT.
match_fusion
method
def match_fusion(operations: Sequence[Operation]) -> int | None: ...Match Program facts against this implementation's RNS/NTT support.
resource_requirements
method
def resource_requirements(invocation: OperationInvocation) -> tuple[ResourceRequirement, ...]: ...prepare_operation
method
def prepare_operation(operation: Operation) -> PreparedFusion: ...execute
method
def execute(invocation: OperationInvocation, inputs: tuple[torch.Tensor, ...], resources: tuple[BoundResource, ...], /, *, in_place: bool) -> tuple[torch.Tensor, ...]: ...TritonRnsImplementation
class View source
TritonRnsImplementation(name: str = 'triton-rns-pointwise', operation_types: tuple[type[Operation], ...] = ARITHMETIC_OPS, supports_in_place: bool = False, plans: dict[tuple[object, ...], PointwisePlan] = field(default_factory=dict))Execute individual modular arithmetic operations using the expression generator.
Inputs use the native lazy interval [0,2q); Montgomery products preserve the native R32 canonical and R62 lazy representatives. Selection requires CUDA.
Attributes
| Name | Type | Default/value |
|---|---|---|
name | str | 'triton-rns-pointwise' |
operation_types | tuple[type[Operation], ...] | ARITHMETIC_OPS |
supports_in_place | bool | False |
plans | dict[tuple[object, ...], PointwisePlan] | field(default_factory=dict) |
resource_requirements
method
def resource_requirements(invocation: OperationInvocation) -> tuple[ResourceRequirement, ...]: ...execute
method
def execute(invocation: OperationInvocation, inputs: tuple[torch.Tensor, ...], resources: tuple[BoundResource, ...], /, *, in_place: bool) -> tuple[torch.Tensor, ...]: ...