DocsStart
Introduction
What Curta is, who uses it, the parts it is made of, and where each page of these docs takes you.
What Curta is
A language model that runs inside Solana. Every token is computed by the chain itself, and any program can call it.
Curta is a Solana program that executes a transformer language model’s whole forward pass on chain: tokenizing the prompt, every layer, sampling the next token and decoding it to text. A model’s weights live in sealed Solana accounts. The output of a run is account data that every validator computed, in the same place as a token balance.
A forward pass is a long integer computation, and one transaction holds a fixed amount of compute. Curta makes the computation resumable. A caller opens a run, an account that holds the prompt, the working state of the forward pass and the output. Anyone turns it: a turn is one transaction that advances the forward pass as far as one transaction’s compute allows, and is paid for it from the run’s budget. Tokens appear in the run account as they complete.
A person uses it at the console, a developer in one line, and a program by CPI:
const { text, address } = await curta.run({ model, prompt })A run from open to close
open_run: the caller names a sealed model, gives the prompt and the parameters (max tokens, temperature, seed) and deposits a budget in SOL. The run isrunning.turn: anyone signs. The program tokenizes the prompt, then advances the forward pass through as many steps as fit, and samples each new token on chain from the run’s seed. The turn pays its signer the turn reward from the budget. Each completed token accrues the publisher’s royalty.- The run is
completewhen it produces the end token or reaches max tokens. Its text is readable from the run account at every turn on the way. settle: anyone signs. The accrued royalty moves to the model’s vault and the accrued protocol share to the fee account.close_run: the caller takes back the unspent budget and the account’s rent.
How it works follows the computation through those turns. Runs and turns covers every state and transition.
The three roles
| Role | What it does | Money |
|---|---|---|
| Caller | Opens runs: at the console, through the SDK, or from a program by CPI. | Pays: Turns and tokens, in SOL. |
| Cranker | Turns runs. Anyone with a wallet can turn one by hand; a cranker process turns every open run. | Earns: The turn reward, per turn, from the run’s budget. |
| Publisher | Puts a model on chain: uploads weights, seals them, sets a royalty per token. | Earns: The royalty on every token the model produces. |
Runs are paid in SOL: a run costs validator compute, and crankers spend SOL to land turns. Fees gives every amount and who receives it.
The parts
The program
curta is a native Solana program. It holds 6 kinds of account and 13 instructions.
| Accounts | Instructions |
|---|---|
| Config, Model, weight accounts, ModelVault, Run, FeeVault | init_config, set_config, create_model, write_weights, seal_model, set_royalty, claim_royalties, open_run, turn, fund, cancel, settle, close_run |
A turn writes only the run and its signer. Weight accounts are read by every run and written by none once the model is sealed, so runs on separate accounts execute in parallel. Accounts, Instructions, Errors and Events are the program’s reference.
The inference core
curta-core is one no_std Rust crate with no dependencies. It holds the weight format, the resumable forward pass, the tokenizer, the sampler and the turn planner. The same source builds for three targets:
- the program (SBF)
- the CLI (native)
- the browser (WebAssembly)
Its arithmetic: int8 weights, fixed-point activations, lookup tables. Bit-exact across targets. Inference core describes it, and Weight format the file it reads.
The SDK
@curta/sdk is the TypeScript client for Node 20 and later and for the browser. It carries the WebAssembly build of curta-core, so the quote and the replay it computes come from the code the program runs. Its run and read calls are run, openRun, turn, quote, getRun, getModel, replay. SDK reference lists every call.
The CPI crate
curta-cpi is the Rust crate a Solana program calls Curta with. It builds and invokes open_run, cancel and close_run with a PDA as the opener, and its RunView reads a completed run’s state and text. The example program oracle-of-stories asks the model for a line by CPI and stores it in its own account. Call from a program walks through it.
The CLI
curta is the bin of the @curta/cli package, built on the SDK. It has 7 commands:
| Command | What it does |
|---|---|
| curta convert <checkpoint> --tokenizer <file> --out <artifact> | Turns a llama2.c checkpoint into Curta’s integer weight format and prints its hash, parameters and turns per token. |
| curta publish <artifact> | Creates the model and its weight accounts and writes the weights in chunks. |
| curta seal <model> | Seals the model. The program checks the weights hash. |
| curta set-royalty <model> <lamports> | Sets the royalty per token. |
| curta claim <model> | Claims royalties from the vault to the publisher’s wallet. |
| curta crank | Turns every running run in order, settles completed ones, prints turns landed and SOL earned. |
| curta run <model> <prompt> | Opens a run, turns it to completion and prints the text and the run address. |
CLI reference has every flag.
The cranker
A cranker is a process that turns every running run in order and settles the ones that have ended. It is the crank export of @curta/sdk, and curta crank runs it from the command line with any funded wallet. The turn reward of each turn it lands arrives in its wallet inside that turn’s transaction. Run a cranker sets one up.
The genesis models
The genesis models are Karpathy’s TinyStories checkpoints in the llama2.c architecture, converted to Curta’s integer weight format.
| Model | Parameters | Dimension | Layers | Heads | Vocabulary | Context |
|---|---|---|---|---|---|---|
| stories260K | 0.26M | 64 | 5 | 8 | 512 | 512 |
| stories15M | 15.2M | 288 | 6 | 6 | 32,000 | 256 |
The program runs any model of that architecture family from the configuration in its Model account, and any publisher adds one to the registry. Models describes the registry and Publish a model the steps.
The site
| Place | What is there |
|---|---|
| Run | The console: pick a model, type a prompt, read the quote, open a run and watch its turns land. |
| Runs | Every run on the program. Each run has a page with its prompt, output, turns, budget and settlement. |
| Models | The registry: every model with its configuration, royalty, runs and tokens produced. |
| Crank | The queue of running runs, with a button to turn each one by hand. |
| Publish | A publisher’s models: upload progress, sealing, the royalty and the vault. |
| Docs | These pages. |