Native Computational Graph Engine ZGC, an ahead-of-time tensor graph compiler written in Zig by developer krypticlogan, lowers a statically defined graph architecture into a specialized Zig type with an inline memory plan before the program runs, eliminating runtime graph interpretation and graph-level operation dispatch. The project requires Zig 0.17.0, is installed via `zig fetch --save git+https://github.com/krypticlogan/zig-graph-compiler`, and targets dense neural network inference, iterative solvers, DSP, image analysis and cellular automata; its author reports that in selected benchmarks ZGC-generated executables perform close to equivalent handwritten Zig implementations, with performance varying by graph structure, execution plan and hardware. The author warns that ZGC is under active development and that public APIs and compiled-model contracts should be expected to change before a stable release. ZGC is an ahead-of-time tensor graph compiler written in Zig that generates statically planned, allocation-free runtimes. Using Zig's comptime , a graph architecture is defined, lowered and optimized to a fixed execution graph, assigned an inline memory plan, and emitted as a specialized type all before the real program ever executes. Compiled executables are validated and contain specialized execution logic directly, eliminating runtime graph interpretation. Graph traversal, tensor ranks, shapes, dtypes, layouts, and kernel selection are compile-time-known. The project requires Zig 0.17.0. Any statically defined numerical pipeline. This includes, but is not limited to: - Inference on dense neural network graphs - Iterative mathematical solvers physics simulations - Audio analysis digital signal processing - Image analysis - Cellular automata or other rule-based simulations Specialized for: - High visibility and control - Cross-compilation thanks Zig - Entirely static execution - No runtime graph interpretation or graph-level operation dispatch ZGC provides a common static graph representation for these workloads; passing optimization off to the compiler instead of handwriting these pipelines. In selected benchmarks, ZGC-generated executables perform close to equivalent handwritten Zig implementations. Performance varies with graph structure, selected execution plan, and hardware. Examples exist in the examples https://github.com/krypticlogan/zig-graph-compiler/blob/master/examples directory. Check them out and build locally if you prefer to see it in action. conways-gol-demo.mp4 mnist-digit-demo.mov In a Zig project directory: zig fetch --save git+https://github.com/krypticlogan/zig-graph-compiler Add to your build.zig and add the ZGC module as an import to your own: js const zgc dep = b.dependency "zgc", .{ .target = target, .optimize = optimize, } ; const zgc mod = zgc dep.module "zgc" ; exe.root module.addImport "zgc", zgc mod ; Import normally. Note ZGC is under active development. Public APIs and compiled-model contracts should be expected to change before a stable release. DefinitionBuilder is the public model-building surface. Source keys and tensor values are concrete types. js const std = @import "std" ; const zgc = @import "zgc" ; const Sources = enum usize { input, weights }; // user-defined source keys const Definition = zgc.DefinitionBuilder; fn define builder: Definition void { // complete graph architecture is defined here const sources = builder.sources Sources ; const input = sources.input .input, .f32, &.{ 4, 8 } ; const weights = sources.parameter .weights, .f32, &.{ 8, 16 } ; builder.output builder.relu builder.matmul input, weights ; } const definition = blk: { var builder = Definition.init ; define &builder ; break :blk builder.finish ; }; const MyExecutable = definition.executable ; // graph is lowered to a specialized Zig type pub fn main void { var runtime = MyExecutable.Runtime.init ; const input values: 4 8 f32 = @splat 1 ; const weight values: 8 16 f32 = @splat 0.25 ; try runtime.copyInput .input, &input values ; try runtime.copySource .weights, &weight values ; runtime.run ; const output = runtime.outputView 0 ; std.debug.print "shape={any} data={any}\n", .{ output.shape, output.storage } ; } executableWith chooses from the compiler's retained executable frontier at compile time. The default target is balanced : js const FastExecutable = definition.executableWith .{ .target = .fast } ; const MemoryExecutable = definition.executableWith .{ .target = .memory } ; const SmallExecutable = definition.executableWith .{ .target = .small } ; const ForcedExecutable = definition.executableWith .{ .frontier index = 0 } ; fast minimizes estimated runtime work memory minimizes planned peak model buffer space small minimizes estimated generated-code units balanced combines runtime, peak memory, and code-size ratios with a 3:1:1 weighting These are compile-time estimates; small does not measure the linked binary. An explicit frontier index overrides the target and fails compilation if the index is outside the retained frontier. Inspect Executable.executable candidate frontier and Executable.selected executable candidate index to choose an index. The frontier retains distinct implementations for explicit selection, including some that lose on every current cost metric, and holds at most 16 candidates. Source bindings can be supplied in the same options value with .sources = &.{...} . ZGC provides tooling for compilation, inspection, and runtimes outside of Zig. To install the CLI, first run zig build -Doptimize=ReleaseFast from the project root. This will install the CLI executable titled zgc to zig-out. Finally, add the directory containing zgc to your system PATH and invoke the CLI with zgc . The CLI provides: | Instruction | Description | |---|---| | compile <.zgir or graph.zig