Graph Export Architecture
SKaiNET export backends should share the same graph-export workflow while keeping backend writers separate.
The shared boundary is the captured graph representation. The shared contracts live in skainet-compile-core under sk.ainet.compile.export and cover diagnostics, generated artifact metadata, result envelopes, mutable export contexts, writers, verifiers, and component naming conventions.
Shared workflow
source model or imported model
-> graph capture
-> validation
-> backend lowering
-> backend writer
-> optional packaging
-> optional verification
Backends can skip stages that do not apply. For example, StableHLO does not need a project packager, while Minerva does.
Backend writers
StableHLO and Minerva should not be forced into one writer abstraction beyond the common result and diagnostic model.
| Backend | Lowering model | Writer output |
|---|---|---|
StableHLO |
Individual graph operations are lowered through operation converters. |
MLIR module text represented by |
Minerva |
Supported graph patterns are lowered into sequential layer descriptors. |
Minerva intermediate model, |
Naming conventions
Use the following suffixes consistently for export components:
| Suffix | Responsibility |
|---|---|
|
Lower source graph structures into a backend intermediate. |
|
Carry backend state, diagnostics, and generated artifacts. |
|
Map operation names or graph patterns to backend converters. |
|
Construct a backend exporter with standard converter registrations. |
|
Write a backend intermediate to files, text, or model bytes. |
|
Run backend-specific validation after writing artifacts. |
StableHLO alignment
The current StableHLO implementation already follows most of this shape:
-
StableHloConverteris the backend converter. -
ConversionContextis the backend context. -
StableHloOperationRegistrymaps operation names to converters. -
StableHloConverterFactorycreates standard converter sets. -
StableHloModuleis the backend result object.
StableHLO should keep its public API and MLIR output stable while adopting shared diagnostics where useful.
Minerva direction
Minerva should start as a sibling backend, not as a hidden mode of the Arduino/C99 exporter.
The first Minerva implementation should use this shape:
ComputeGraph
-> MinervaCompatibilityValidator
-> MinervaLayerPatternRegistry
-> MinervaLayerPatternConverter
-> MinervaIntermediate
-> MinervaNpzWriter
-> PythonMinervaCompilerAdapter
-> MinervaProjectPackager
-> MinervaHostVerifier
Minerva should fail fast for unsupported graphs. StableHLO may keep comments or fallback paths where that behavior is already part of its compatibility story, but Minerva export should not invoke the compiler after a compatibility error.