Module ir

Module ir 

Source
Expand description

2026-09-28: The circuit IR: a closed op vocabulary, edges with a format and a shape, nodes bound to checkpoint modules, and the instantiated graph of one model.

Owner: metrale-circuit. Invariants:

  • OpKind is closed. A template naming anything else is a load error, never an opaque pass-through.
  • Heavy ops (OpKind::is_heavy) are opaque: the fuser fuses at their edges or through a pre-written kernel, and never generates them.
  • Nodes are stored in execution order, which is a topological order: every input of a node is produced by an earlier node or is a circuit input.
  • An edge’s fused or materialised state belongs to a plan (FusionPlan::edge_states), not to the circuit, because one circuit has one plan per mode and row count.

Structs§

ArchShape
2026-09-28: What instantiation needs from a model config: its layer kinds in order and its named dims. The caller fills it from ModelConfig, so this crate does not depend on the config tree.
BlockInstance
2026-09-28: One instantiated block: its template and the node range it produced.
Circuit
2026-09-28: An instantiated circuit.
Edge
2026-09-28: One tensor between nodes: rows x dim in format. rows is an expression over n, the step’s row count, and the arch dims (e.g. n*top_k).
Node
2026-09-28: One op instance.

Enums§

LayerKind
2026-09-28: A decoder layer’s kind, as ModelConfig::layer_type reports it.
LinearRole
2026-09-28: What a linear (GEMV/GEMM) node projects. Closed, like OpKind.
OpKind
2026-09-28: The closed op vocabulary.
OpParseError
2026-09-28: Why an op spelling was refused.
Section
2026-09-28: Which forward a block belongs to.

Type Aliases§

EdgeIdx
2026-09-28: Index of an edge in Circuit::edges.
NodeIdx
2026-09-28: Index of a node in Circuit::nodes.