Skip to content

stateforward/emel.cpp

Repository files navigation

EMEL

Deterministic, production-grade C++ inference engine built around Boost.SML orchestration.

Status: WIP

This repository is under active development. APIs, state machines, and formats will change. If you’re evaluating EMEL, expect fast iteration and breaking changes until the core loader, allocator, and execution pipelines stabilize.

This inference engine is being implemented by AI under human engineering and architecture direction.

Implementation priorities

  1. Architect first, then scaffold cleanly.
  2. Port math, instructions, and behavior without mirroring reference control flow.
  3. Prove parity against llama.cpp.
  4. Match model/tokenizer intent as defined by their creators (transformers).
  5. Optimize once correctness is locked.

Why EMEL

EMEL exists to make inference behavior explicit and verifiable. Instead of ad-hoc control flow, orchestration is modeled as Boost.SML state machines with deterministic, testable transitions. That enables:

  1. Clear operational semantics and failure modes.
  2. Deterministic, reproducible inference paths.
  3. High-performance, C-compatible boundaries without dynamic dispatch in hot paths.
  4. Auditable parity work against reference implementations without copying their control flow.

Why state machines everywhere

It might look like over-engineering — "I have a hammer so everything looks like a nail." But a state machine with two states has virtually zero overhead, and the goal is explicit behavior modeling, not complexity for its own sake. Stateless functions inevitably accumulate conditional logic as the code evolves: mode flags, error booleans, retry counters, phase enums. Taming that accidental complexity before it starts is the whole point of EMEL. Every actor has a visible state model, every transition is declared, and every unexpected event has a defined handler. That's the trade I'm making.

End-to-end performance will be inferior to llama.cpp and other engines initially — that's expected and accepted, even though many individual machines will perform comparably or better in isolation. Having explicit actions and states makes it straightforward to find hotspots, and if profiling shows a state machine itself is the bottleneck, it gets removed. Concurrency is intentionally deferred until single-threaded behavior is verified. That doesn't mean there's no plan for it — the actor model makes adding concurrency easier than it looks, and it will be introduced only where measurement says it's necessary.

The name

“EMEL” is pronounced like “ML”. It’s a short, neutral name that doesn’t carry existing assumptions or baggage. It’s intentionally low-ceremony while I iterate on the core design.

Acknowledgements

Huge thanks to the contributors of llama.cpp and ggml. EMEL’s parity work depends on the quality and clarity of these reference implementations.

Special shout out to Georgi Gerganov, whose work created the foundation that made this ecosystem possible.

Build and test

scripts/quality_gates.sh

Individual gates live in scripts/build_with_zig.sh, scripts/test_with_coverage.sh, scripts/test_with_sanitizers.sh, scripts/fuzz_smoke.sh, scripts/lint_snapshot.sh, and scripts/bench.sh.

Why Zig for builds

Zig’s C/C++ toolchain gives us consistent, fast, cross-platform builds without forcing a full dependency on any single system compiler or SDK. It keeps the default dev path reproducible, while still allowing native toolchains when needed.

Why CMake for tests and coverage

Coverage and CI tooling are already standardized around CMake + CTest + llvm-cov/gcovr in this repo. Using CMake for test/coverage builds keeps gates deterministic and portable across CI environments, while Zig remains the default for day-to-day builds.

Documentation

Docs index

Regenerating docs

scripts/generate_docs.sh

Use scripts/generate_docs.sh --check in CI to validate generated artifacts.

About

emel is a deterministic, event-driven machine learning inference engine built on explicit state machines for predictable, high-performance execution.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages