Documentation · Apsi 2.0.0
Learn Apsi
Guides and references for the language, the native compiler, AI and science libraries, and the library ecosystem.
New to Apsi?
Write it like Python, let an AI write it, or convert Python — no new language to learn first.
Open →02Everything on one page
All syntax with examples, then every built-in, module member and command.
Open →03Fast by design
The few habits that make Apsi run at C speed — and why each one matters.
Open →Start here
Getting started
This guide takes you from installation to a first program, a first trained model and a first library in about ten minutes.
2 min readWrite Apsi your way
Apsi is designed so that you do not have to learn a new language before you are productive.
4 min readInstall on Windows
After installing, run apsi doctor to check your machine against these targets. Unattended install: ApsiSetup-2.0.0-x64.exe --silent [--dir PATH] [--profile strict] [--no-editors] [--with-torch].
4 min readInstall on Linux
Works on every x86-64 distribution with glibc 2.17 or newer, such as Ubuntu 18.04+, Debian 10+, Fedora, Arch, openSUSE, Mint and Pop!OS (the shell installer also on ARM, and in WSL on Windows).
3 min readTroubleshooting
This page covers the problems people most often hit right after installing Apsi, with the exact commands to fix them. Why it happens.
6 min readVersions compared
2.0.0 for everything new. Programs written for 1.10.0 run on 2.0.0 unchanged — 2.0.0 only adds.
2 min readThe language
Everything on one page
This page is the whole language in one place: every piece of syntax with a short example, then every built-in function, every standard module and every member, and every command of Apsi 2.0.0.
66 min readLanguage reference
Version 2.0 · source files use the extension .apsi and the UTF-8 encoding.
50 min readNative compiler
Apsi 2.0 compiles functions to machine code.
15 min readMaximum performance — and why
Apsi programs are correct by default. Being fast as well depends on a handful of habits. Each one below says what to do, why (what happens inside Apsi), and how big the difference is.
3 min readHardware & performance
About speed: f64/f32/f16 use the CPU's instructions directly. In the current runtime BF16/FP8/FP6/FP4/INT4 are stored as real-size codes (saving RAM, SSD and bandwidth in proportion to the bits) and decoded to FP32 for computing.
5 min readPermissions & security
Apsi assumes any program might be hostile, including one you downloaded, one an AI wrote, or a dependency of either. The defences are layered.
8 min readAI
AI and machine learning
Apsi does not force a ready-made architecture on you. Every network is an ordinary function that takes a "parameter tree" (record / list / struct), and grad differentiates with respect to every parameter in it.
5 min readLayers
use layers builds neural networks of any architecture out of small, composable layers: plain stacks, residual networks, any directed acyclic graph (several inputs and outputs, shared weights), convolutional and recurrent networks.
11 min readFrom Python and PyTorch
apsi convert translates Python files — or whole folders — into Apsi, maps the libraries you use onto Apsi's own built-ins, checks the result and tells you exactly which lines need a human look.
9 min readReinforcement learning
use rl provides environments, advantage estimation, policy helpers, complete training algorithms (PPO, DQN, REINFORCE), the losses used to train language models from human preferences (RLHF, DPO, IPO, GRPO), beam search.
4 min readModel files
Apsi saves and loads models in the formats the rest of the ecosystem uses, and in its own checkpoint format (.apsim) for everything those formats cannot hold: physical units, compressed tensors, the shape of the parameter tree.
4 min readLarge models & clusters
Training a 21B, 500B, 1T or 2T-parameter model is decided by arithmetic before any code runs: how much memory each GPU needs, how the model must be split, how many GPUs, and how many days.
3 min readBackends
Every model built with use layers runs on two backends without changing a line of the model:
8 min readEcosystem
Libraries (.apsil)
Apsi libraries are distributed as .apsil files through the official registry. One command installs the newest version, every file is verified, and a library is used exactly like a standard module.
5 min readPublishing to apsi.dev
Everything on the website can be added and removed from the command line on any computer, or with the server command when you are on the server itself.
2 min readC, C++ and Python interop
Apsi keeps a clear border between its own world and the outside: values that cross it are converted by fixed rules (quantities with units always travel as {"value": ..., "unit": "..."}).
2 min readHTTP and WebSocket servers
Measured (2 vCPU machine, load generator on the same machine): 7,700 requests/s at 500 concurrent connections, p99 82 ms, 0 errors out of 20,000 requests.
3 min readEditors
Apsi works in the editors people already use.
7 min readBuilding from source
Linux release files that need no internet and no Node.js (any Linux, also WSL):
3 min readPlayground
The playground/ folder is a web page that runs Apsi in the browser with no server doing the work. It uses Pyodide (CPython compiled to WebAssembly) and numpy entirely on the visitor's machine, so it can be put on the official website as is.
1 min read