Skip to content

Passes

Every transformation PyPTO runs over the IR, numbered to match its position in the default pipeline.

Pass documentation is numbered so that reading it front to back walks the compilation pipeline in execution order. 0143 are pipeline passes; 91+ is reserved for passes that run at several positions and for infrastructure that is not a pipeline pass at all.

Framework

Page What it covers
Pass, PassContext, PassPipeline, and PassManager Organizing and executing passes with property tracking, instrumentation, and strategy-based pipelines

Default pipeline

Order Pass What it does
01 InlineFunctions Splices FunctionType.Inline bodies into every call site
02 UnrollLoops Expands ForKind::Unroll loops at compile time
03 CtrlFlowTransform Rewrites break / continue into structured control flow
04 ConvertToSSA Converts to SSA form with variable renaming, phi nodes, and iter_args
05 Simplify Folds arithmetic, shape expressions, and scalar constant bindings
06 FlattenCallExpr Flattens nested call expressions into three-address form
07 OutlineHierarchyScopes Outlines Hierarchy scopes into functions carrying level / role metadata
08 OutlineIncoreScopes Outlines InCore scopes into separate functions
09 OutlineClusterScopes Outlines Cluster scopes into Group functions and standalone Spmd scopes into Spmd functions
10 ConvertTensorToTileOps Converts tensor ops to tile ops in InCore functions, updating orchestration call sites
11 OptimizeOrchTensors Eliminates redundant orchestration allocations and improves data flow
12 LowerCompositeOps Decomposes composite tile / distributed ops into primitives
13 FlattenTileNdTo2D Flattens 3D+ tile operations to 2D by merging all but the last dimension
14 LegalizeTileCast Expands tile.cast pairs the ISA cannot emit as one instruction into the shortest native chain
15 AutoTileMatmulL0 Picks an L0 tile shape (m, n, k) from the backend's L0 capacities and tiles matmuls to it
16 CanonicalizeTileSlice Lowers tile.slice into the canonical tile.extract form
17 InferTileMemorySpace Infers the on-chip MemorySpace of every tile and inserts tile.move to legalize mismatches
18 ResolveBackendOpLayouts Repairs backend-required tile layouts for elementwise ops
19 LowerAutoVectorSplit Converts AUTO pl.split mixed InCore functions into the explicit split_aiv form
20 ExpandMixedKernel Splits mixed InCore functions into separate AIC (Cube) and AIV (Vector) kernels
21 InjectGMPipeBuffer Injects the __gm_pipe_buffer workspace for GM-routed cross-core pipes (Ascend910B)
22 SplitVectorKernel Stamps split attributes and handles the no-split dual-AIV path
23 StampTfreeSplit Copies each cross-core tpop's split and pipe id onto its matching tfree op
24 NormalizeReturnOrder Reorders every InCore function's return tuple into the canonical order
25 SkewCrossCorePipeline Software-pipelines mixed cube/vector loops so the two cores overlap
26 LowerPipelineLoops Replicates pl.pipeline(N, stage=F) bodies F times to enable ping-pong buffering
27 CanonicalizeIOOrder Reorders pipeline-body statements along the scalar → load → compute → store ladder
28 MaterializeTensorStrides Fills in the packed canonical stride for every tensor view that carries none
29 InitMemRef Initializes MemRefs and creates alloc operations with unallocated addresses
30 MaterializeSemanticAliases Forces buffers that program semantics require to be one allocation (loop-carry, in-place)
31 MemoryReuse Reuses buffers by lifetime analysis and removes redundant allocs
32 AllocateMemoryAddr Assigns real addresses to existing alloc operations
33 FoldNoOpReshape Folds tile.reshape calls that change neither physical shape nor allocation
34 FuseCreateAssembleToSlice Fuses tensor.create + tensor.assemble into one tensor.slice view
35 DeriveCallDirections Materializes wrapper ParamDirections, then derives a per-argument ArgDirection at every call
36 AutoDeriveTaskDependencies Derives conservative task-to-task dependency edges
37 ExpandManualPhaseFence Compresses profitable full-array TaskId dependencies in manual scopes
38 SynthesizeAllReduceSignals Turns a host allreduce's optional signal into explicit internal signal IR
39 MaterializeCommDomainScopes Assembles WindowBuffer and CommDomainScopeStmt wrappers in each host orchestration body
40 LowerHostTensorCollectives Rewrites host-level tensor collectives into internal builtin chip dispatches
41 MaterializeDistTensorCtx Materializes an explicit CommCtx parameter and argument per DistributedTensor
42 MaterializeRuntimeScopes Inserts AUTO RuntimeScopeStmt nodes so orchestration codegen emits PTO2_SCOPE 1:1
43 ClassifyIterArgCarry Classifies each orchestration ForStmt iter_arg as a trivial alias or a materialised rebind carry

Outside the default pipeline

Page What it covers
Utility Passes Normalization and cleanup passes that run at several pipeline positions
Diagnostics The advisory channel for compile-time warnings and performance hints
IR Verifier Pluggable property verifiers that validate IR correctness between passes

Shared material

Page What it covers
Shared Pass Utilities Reusable helpers in include/pypto/ir/transforms/utils/
Loop-Carried Compiler Dependency Compression How loop-carried dependency edges are compressed

See Also

  • IR — the representation these passes transform.
  • Backend — how passes get per-architecture answers without branching on the backend.
  • Code Generation — what runs once the pipeline is done.