Skip to content

canvas_engineering.compiler

Program compilation: lower a CanvasProgram to a deploy-ready execution plan.

canvas_engineering.compiler.CompiledProgram dataclass

Deploy-ready execution plan produced by ProgramCompiler.

Attributes:

Name Type Description
schema CanvasSchema

Potentially reduced CanvasSchema (inactive regions removed).

active_regions Set[str]

Set of region names still alive at deploy.

frozen_regions Set[str]

Set of region names with frozen parameters.

constant_regions Set[str]

Set of regions materialized as buffers.

exported_memories Set[str]

Dict of region names exported to disk.

active_connections List[Connection]

Connections between active regions only.

n_eliminated property

Number of regions eliminated from the training graph.

canvas_engineering.compiler.ProgramCompiler

Lowers a CanvasProgram to a deploy-ready CompiledProgram.

Compile passes applied in order: 1. freeze: mark compile_mode="freeze" regions (no gradient) 2. constant: mark compile_mode="constant" regions (materialize as buffer, remove from active) 3. export: mark compile_mode="export" regions (save to disk, remove from active) 4. dead elimination: remove connections involving inactive regions

Usage

compiler = ProgramCompiler(program) compiled = compiler.compile()

compile()

Run all compile passes and return a CompiledProgram.