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', max_ntt_endpoints: int | None = None, operation_types: tuple[type[Operation], ...] = (fusion.FusedOp,), supports_in_place: bool = False)Attributes
| Name | Type | Default/value |
|---|---|---|
graph | ExpressionGraph | |
name | str | 'triton-rns-fused' |
max_ntt_endpoints | int | None | None |
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, max_ntt_endpoints: int | None = None, 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 transform dependencies; their execution plans compose generated endpoints, native stage ranges or complete transforms according to the selected algorithm. Match checks consume known Program facts, while missing layout/resource facts are checked when binding execution. Device compilation is lazy.
max_ntt_endpoints bounds transform endpoints per generated kernel while preserving their stage order. None selects eight endpoints on HIP to limit compiler IR growth and leaves CUDA endpoint merging unbounded.
Attributes
| Name | Type | Default/value |
|---|---|---|
name | str | 'triton-rns-fused' |
include_ntt | bool | False |
max_ntt_endpoints | int | None | None |
operation_types | tuple[type[Operation], ...] | (fusion.FusedOp,) |
supports_in_place | bool | False |
select_ntt_schedule
method
def select_ntt_schedule(**facts): ...Select an NTT schedule independently of endpoint decomposition.
new_fusion_matcher
method
def new_fusion_matcher() -> FusionMatcher: ...Create candidate analysis scoped to a read-only scheduling window.
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, ...]: ...