Apsi

Documentation · Apsi 2.4.4

Learn Apsi

Guides and references for the language, the native compiler, AI and science libraries, and the library ecosystem.

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 read

Write Apsi your way

Apsi is designed so that you do not have to learn a new language before you are productive.

4 min read

Install on Windows

After installing, run apsi doctor to check your machine against these targets. Download: the Windows installer, the Linux installer (ApsiSetup-2.4.4-linux.sh) and the .deb are on apsi.dev/download, each with its SHA-256.

4 min read

Install 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 read

Troubleshooting

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 read

Versions compared

2.4.4 for everything new. Programs written for 2.0.0 and 1.10.0 run on 2.4.4 unchanged — each version only adds.

2 min read

What's new in 2.4.4

This page walks through everything 2.4.4 adds, with a working example for each part, the numbers we measured, and the limits you should know about.

12 min read

Project overview

Apsi is a programming language for AI, physics and servers. Physical units, tensor-shape checking, automatic differentiation, number formats from FP64 down to FP4, data pipelines and a hardened HTTP server are built into the language.

15 min read

Licensing

Apsi is published under the Apsi License 2.0 (the LICENSE file). This page explains it in plain words with examples.

4 min read

AI

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 read

Layers

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.

12 min read

Graphs that reach far

Graph neural networks pass messages along edges: one layer moves information one hop.

3 min read

From Python and PyTorch

apsi convert translates Python files — or whole projects — into Apsi with Python's exact semantics: the converted program prints the same text, raises the same errors, byte for byte.

11 min read

Reinforcement 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 read

Model 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 read

Large 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 read

Backends

Every model built with use layers runs on two backends without changing a line of the model:

8 min read

Fewer AI tokens

Language models charge by the token and read slower the more they get.

5 min read

Hugging Face models

use hub downloads models from the Hugging Face Hub, tokenizes text and runs the models natively — embeddings, classification, named entities, fill-mask and text generation — with Apsi's own code.

8 min read

RAM, SSD and GPU

Big data and big models run out of memory in the middle of the night.

5 min read

Ecosystem

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 read

Publishing 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 read

C, 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 read

HTTP and WebSocket servers

Measured — a synthetic benchmark (a route that returns a fixed 25-byte JSON object, keep-alive, the Go load generator in benchmarks/web on the same machine):

6 min read

.env, secrets and venvs

The file format is the one python-dotenv and Docker Compose read: KEY=value, export KEY=value, single and double quotes, multi-line double-quoted values, \n escapes in double quotes, # comments, and ${OTHER} expansion.

3 min read

Debugging

Apsi has a real debugger: breakpoints, stepping, the call stack, variables and tensors — in VS Code and the other VS Code-family editors (F5) or in the terminal.

4 min read

Editors

Apsi works in the editors people already use.

7 min read

Building from source

Linux release files that need no internet and no Node.js (any Linux, also WSL):

3 min read

Playground

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