enigma.compile runs entirely in the compiler pipeline and does not require a Metal device. You can use this to develop and inspect kernels on any macOS machine with Xcode CLT, including CI runners without Apple Silicon.
Basic usage
Enabling debug artifacts
Use compile flags to capture every stage of the pipeline:What each flag does
| Flag | Effect |
|---|---|
dump_ir=True | Prints the traced op graph (loads, stores, arithmetic) to stdout |
dump_mlir=True | Prints the Enigma dialect MLIR before MSL emission |
keep_metal_source=True | Writes .metal source to work_dir (default: temp dir) |
work_dir=path | Directory for all intermediate build artifacts |
Exporting Metal source
To save the generated source to a specific path for review or diffing:- Code review of generated kernels
- Tracking codegen regressions in CI with
git diff - Profiling with Metal’s GPU capture tools using the original source
Vectorized kernels
Passvec_width to request vectorized codegen. The pipeline will emit float4-style loads and stores when alignment allows:
When to use this workflow
| Scenario | Use |
|---|---|
| Developing on a non-Metal machine | Compile-only — no GPU needed |
| CI codegen regression tests | keep_metal_source=True + diff artifacts |
| Debugging incorrect output | dump_ir=True + dump_mlir=True |
| Performance tuning with Instruments | Export source with export_metal() |
