Skip to content

Latest commit

 

History

History
87 lines (75 loc) · 7.93 KB

File metadata and controls

87 lines (75 loc) · 7.93 KB

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. 0146 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 InsertMxScaleAddr Inserts tile.tget_scale_addr before MX matmul consumers after memory spaces are resolved
19 ResolveBackendOpLayouts Repairs backend-required tile layouts for elementwise ops
20 LowerAutoVectorSplit Converts AUTO pl.split mixed InCore functions into the explicit split_aiv form
21 ExpandMixedKernel Splits mixed InCore functions into separate AIC (Cube) and AIV (Vector) kernels
22 InjectGMPipeBuffer Injects the __gm_pipe_buffer workspace for GM-routed cross-core pipes (Ascend910B)
23 SplitVectorKernel Stamps split attributes and handles the no-split dual-AIV path
24 StampTfreeSplit Copies each cross-core tpop's split and pipe id onto its matching tfree op
25 NormalizeReturnOrder Reorders every InCore function's return tuple into the canonical order
26 SkewCrossCorePipeline Software-pipelines mixed cube/vector loops so the two cores overlap
27 LowerPipelineToSlots Rotates a pl.pipeline body through the slots of one allocation instead of replicating it (memory_planner=PTOAS)
28 LowerPipelineLoops Replicates pl.pipeline(N, stage=F) bodies F times to enable ping-pong buffering
29 CanonicalizeIOOrder Reorders pipeline-body statements along the scalar → load → compute → store ladder
30 MaterializeTensorStrides Fills in the packed canonical stride for every tensor view that carries none
31 InitMemRef Initializes MemRefs and creates alloc operations with unallocated addresses
32 MaterializeSemanticAliases Forces buffers that program semantics require to be one allocation (loop-carry, in-place)
33 MemoryReuse Reuses buffers by lifetime analysis and removes redundant allocs
34 AllocateMemoryAddr Assigns real addresses to existing alloc operations
35 FoldNoOpReshape Folds tile.reshape calls that change neither physical shape nor allocation
36 FuseCreateAssembleToSlice Fuses tensor.create + tensor.assemble into one tensor.slice view
37 DeriveCallDirections Materializes wrapper ParamDirections, then derives a per-argument ArgDirection at every call
38 AutoDeriveTaskDependencies Derives conservative task-to-task dependency edges
39 ExpandManualPhaseFence Compresses profitable full-array TaskId dependencies in manual scopes
40 SynthesizeAllReduceSignals Turns a host allreduce's optional signal into explicit internal signal IR
41 MaterializeCommDomainScopes Assembles WindowBuffer and CommDomainScopeStmt wrappers in each host orchestration body
42 LowerHostTensorCollectives Rewrites host-level tensor collectives into internal builtin chip dispatches
43 MaterializeDistTensorCtx Materializes an explicit CommCtx parameter and argument per DistributedTensor
44 MaterializeRuntimeScopes Inserts AUTO RuntimeScopeStmt nodes so orchestration codegen emits PTO2_SCOPE 1:1
45 ClassifyIterArgCarry Classifies each orchestration ForStmt iter_arg as a trivial alias or a materialised rebind carry
46 InsertCommFence Inserts a whole-tensor system.cacheinvalid + GM system.fence between each publishing write and the pld.system.notify that releases it

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.