How Aner works
Follow interpreted programs and the development CPU compiler through shared checks, native operations, explicit devices and parallel workers.
Released in Aner 0.1.0Aner 0.1.0 or newerAner gives researchers a checked scientific language over a native execution engine. You write an experiment in .aner source; Aner checks the program, interprets its control flow, and calls native operations for data, numerical work and supported models. Those operations can run on a CPU or, where supported and explicitly selected, a local accelerator.
This page explains interpreted execution and the bounded native compiler implemented in the current development source. Available APIs can differ between an installed release and the development runtime; use release and development status to check availability.
Two different things are built
The Aner engine is implemented in C++, with a C++20 build baseline. Maintainers compile that engine and its native modules into the platform’s aner executable. A researcher installs the appropriate binary and can run Aner programs without installing a C++ compiler.
Your Aner program has two explicit paths. aner run checks and interprets it using the already compiled engine. In the current development source, aner build checks and lowers a supported typed CPU subset into C++20, then compiles a separate native executable. Downloaded runtime packages provide the interpreted path. Building Aner source requires a matching source build SDK and C++20 toolchain; the runtime packages do not contain a usable native SDK.
The illustration separates the installed engine from the researcher’s program. The development compiler branch supports the CPU subset described below; broader native module and device lowering remains planned.
From source to a result
The frontend first turns source text into tokens, parses a syntax tree, resolves names and checks types. This produces a checked representation of the program, preserving source locations for diagnostics. Checking can catch problems such as an unknown name, an invalid call or an incompatible type before execution.
The interpreter then evaluates that checked program: variables, conditions, function calls and loops determine which work runs. A call to a supported native operation crosses into the C++ runtime. For example, matrix multiplication reaches a numerical kernel rather than asking the interpreter to multiply every matrix cell through an Aner callback.
Static checking and runtime validation work together. Some properties depend on actual data: a tensor’s dimensions, an allocation request, a file’s contents or whether a GPU can initialize. The relevant native operation checks those properties when needed and reports failures through Aner’s diagnostics.
Built in modules connect to this native implementation. Their public contracts define accepted values, resource limits and errors; using a module does not make every operation a GPU operation. The run and notebook paths interpret ordinary scalar control flow. The Aner 0.0.5 build path compiles its supported scalar control flow and fixed numerical buffers for CPU execution. See the language reference, Tensor reference and module catalogue for the exact supported surfaces.
How CPU, CUDA and Metal fit together
The runtime owns numerical buffers, device placement, transfers and completion. Supported Tensor operations dispatch according to the operands’ actual placement and precision. An execution profile can prepare that placement before work begins; changing the profile leaves existing values unchanged. The backend calls the platform’s native libraries and runtime, which in turn use the operating system and hardware driver to execute work on the device.
| Execution target | Native route | Supported Tensor precision |
|---|---|---|
| CPU | Portable C++ kernels; eligible builds can use Apple Accelerate or an installed CBLAS provider | Float64 and Float32 |
| NVIDIA GPU | CUDA kernels and cuBLAS through the CUDA runtime and a compatible NVIDIA driver | Float64 and Float32 |
| Apple GPU | Metal kernels and Metal Performance Shaders through Apple’s native frameworks and driver | Float32 |
A GPU path requires both an Aner binary containing that backend and compatible hardware/runtime support. Installing a driver alone does not add a missing backend. The native runtime handles queues or streams, device buffers and synchronization; an Aner program does not configure those low level objects itself. A backend may prepare device kernels, including compiling Metal shader source, while the Aner program still follows the interpreter path above.
Precision is an explicit scientific choice. The default execution profile is CPU, Float64, with the preserve policy. Automatic device selection considers available CUDA, then Metal/MPS, then CPU, and applies the chosen precision policy. On available Metal/MPS, preserving Float64 resolves to CPU Float64 with a reported fallback; adapt permits Float32 when the selected backend lacks Float64, and fast intentionally selects Float32. Explicitly requesting an unavailable accelerator fails. Tensor operations do not implicitly move or cast their operands.
These choices concern supported operations, not arbitrary GPU execution of a source program. Actual speed depends on workload size, transfers, synchronization, precision and hardware. Inspect the resolved profile and compare numerical results before interpreting timing. The device and performance guide contains runnable examples and the complete policy.
From one computer to several
Aner separates the scientific workload from an explicit execution context. Local repetitions, remote native tasks and replicated model training have different contracts; they are separate ways to organize work.
Local independent repetitions. parallel.repeat admits a checked, isolated task function, copies its initial parameters and schedules iterations across a bounded set of local worker threads for CPU execution. Each iteration has private interpreter state and a deterministic seed. Successful numeric outputs are published in iteration order. This supports repeated simulations and independent CPU work without changing the task into a GPU kernel.
The operating system schedules local worker threads on eligible logical CPUs. Workers can time share a logical CPU or run on different logical CPUs, and a thread can migrate during execution. Aner uses the CPU budget to bound worker admission; it does not promise a dedicated core or fixed CPU affinity for each worker.
Configured worker processes. Supported native CPU tasks can run through explicitly configured worker processes launched locally or over SSH. A configured process can own multiple bounded execution threads; its CPU slot allowance is an admission limit, not a processor identity. Each host OS schedules its threads. Workers must be enrolled and compatible. The runtime coordinates the admitted task and validates its results; it does not discover a cluster or send any arbitrary source function to another computer. Remote execution of general repetition callbacks remains future work.
Supported Dense model replicas. ml.fit gives each worker a full model replica and a disjoint share of the training rows. Workers compute forward/backward work on their declared CPU, CUDA or Metal/MPS backend. Gradient sums and sample counts return through host communication; the coordinator combines them with sample weighting, performs one canonical CPU optimizer update and distributes the next parameters. This is replicated training, with separate worker memory, rather than a model split across pooled GPU memory. Direct GPU collectives, general model sharding and durable distributed recovery remain future work.
Begin with CPU parallelism in practice, then use the repetition guide, worker execution reference or distributed Dense training guide for the workload you need.
Compile supported user code natively
The Aner 0.0.5 aner build FILE.aner -o OUTPUT --emit-cpp FILE.cpp command reuses the lexer, parser, name resolution and type checker. A bounded backend then validates every construct it supports and lowers typed user operations into inspectable C++20. A C++ compiler produces a standalone CPU executable. Supported loops and calls run as native instructions; they do not evaluate syntax tree nodes or silently return to the interpreter.
The first subset covers typed scalar functions, local state, arithmetic, comparisons, conditions, loops, calls between supported functions and checked fixed array access. Unsupported constructs receive an Aner source diagnostic. The admitted typed repetition path also compiles checked task bodies, with scalar parameters and exclusive typed output. An explicit local context uses the existing bounded executor; a cluster context requires matching compiled worker binaries and a separate versioned static registry protocol, with no source/session interpretation. Broader scientific objects, units, data plans and model execution remain on their existing validated runtime paths.
C++20 is the initial backend because Aner already uses that toolchain and checked native numerical/storage helpers. Adding an LLVM or MLIR dependency before those operations need it would enlarge the first integration without supplying an existing backend to reuse. The compiler boundary remains separate from language semantics so further backends can be evaluated on their own evidence.
Building requires the matching Aner 0.0.5 source build SDK and C++20 compiler; running the resulting executable needs no Aner interpreter. The subset is CPU only. It does not compile arbitrary source to GPU kernels or automatically distribute ordinary loops, and it does not change a selected numerical policy. The native compilation guide and compiled parallel guide define the exact supported surface, worker admission and diagnostics. C++20 remains required; C++26 readiness reports optional feature observations without changing that baseline.
This compiler milestone requires Aner 0.0.5 or newer and its matching SDK. It introduces a real native execution path without promising universal speedups or complete language coverage. Measure compilation, startup and repeated execution separately, and compare numerical results before interpreting timings. The architecture guide describes the shared frontend and runtime boundary; the roadmap separates broader compiler work from this development subset.
Read further
For the underlying infrastructure, see the LLVM frontend tutorial, NVIDIA cuBLAS documentation and Apple Metal Performance Shaders documentation. These explain technologies used or considered beneath Aner; Aner’s own references define the supported language and runtime behavior.
Native compilation and compiled worker enrollment remain source build capabilities. Downloaded runtime packages do not include a usable native SDK. Select the matching development SDK and C++20 toolchain explicitly; these sections do not promise turnkey compilation from a runtime archive.