  flowchart TD
      subgraph Build["Package build path"]
          B0["ipu-trivial-test main"]
          B1["Validate arguments<br/>choose workload"]
          B2["Construct ComputeGraph<br/>and PipelineConfig"]
          B3["build_package(graph, config)"]
          B4["lower_finalists:<br/>semantic graph → candidate MidGraphs"]
          B5{"One finalist?"}
          B6["lower_to_tiles:<br/>MidGraph → logical LowProgram"]
          B7["For each finalist:<br/>lower → place → schedule exchanges<br/>rank by refined cycle cost"]
          B8["Compile static runtime"]
          B9["Derive KernelBuildPlan<br/>compile required kernels"]
          B10["Initial link for symbols/layout"]
          B11["Provisional placement and exchange lowering<br/>size exchange/profile/host/code regions"]
          B12["Reserve support regions"]
          B13["Final SRAM placement"]
          B14["Final exchange scheduling and encoding"]
          B15["Create tensor bindings<br/>and host-exchange protocol"]
          B16["Lower each logical work list<br/>to finalized TileProgram"]
          B17["Emit supervisor code<br/>and exchange rows"]
          B18["Link/build every physical TileImage"]
          B19["Assemble and validate Application"]
          B20["Application::write → .ipuexe"]

          B0 --> B1 --> B2 --> B3 --> B4 --> B5
          B5 -- Yes --> B6
          B5 -- No --> B7 --> B6
          B6 --> B8 --> B9 --> B10 --> B11 --> B12
          B12 --> B13 --> B14 --> B15 --> B16 --> B17
          B17 --> B18 --> B19 --> B20
      end

      subgraph Run["Generic package run path"]
          R0["ipu-stack host-run"]
          R1["Application::read<br/>decode and validate package"]
          R2["Runtime::open"]
          R3["Open /dev/ipuN<br/>initialize/reset device<br/>replay IPUCFG1"]
          R4["Runtime::load"]
          R5["Parse/install bootloader<br/>load tile images in 64-tile batches<br/>initial synchronization"]
          R6["Apply package device-config writes"]
          R7["HostSession::new"]
          R8["HostSession::start<br/>handoff and attach host pages"]
          R9{"Next requested call?"}
          R10["Read --input CALL=PATH<br/>or use empty input"]
          R11["HostSession::invoke"]
          R12{"Input/output pages overlap?"}
          R13["Normal path:<br/>prepare → handshake → collect"]
          R14["Streaming path:<br/>interleave copies with handshake"]
          R15{"Output mapping?"}
          R16["Write --output CALL=PATH"]
          R17["No bytes: continue"]
          R18["Error: output produced<br/>without destination"]
          R19["hostRun=PASS"]

          R0 --> R1 --> R2 --> R3 --> R4 --> R5 --> R6
          R6 --> R7 --> R8 --> R9
          R9 -- Yes --> R10 --> R11 --> R12
          R12 -- No --> R13 --> R15
          R12 -- Yes --> R14 --> R15
          R15 -- Path supplied --> R16 --> R9
          R15 -- Empty, no path --> R17 --> R9
          R15 -- Nonempty, no path --> R18
          R9 -- No --> R19
      end

      B20 -. package artifact .-> R1
