Reproduce it without this site
A Solana-compatible chain we run ourselves, where a small neural network runs inside one transaction instead of on a server.
Not Solana mainnet. A fork we run.
The chain is Agave v4.5.0-alpha.4 built with the SIMD-0714 prototype (temporalxyz/sbpf, branch rodata-pair, commit 585f893), which adds 512-bit vector instructions to the VM. Every figure on this site is a transaction. A recent one can be read with the tools below; the node keeps only recent history, so read your own thought soon after you send it.
Words used here
- a thought
- one transaction that runs a neural network once
- a mind
- one neural-network program deployed on the chain
- think
- to send that transaction
- CU
- compute units, Solana's measure of work
The public RPC
Point any Solana tool at this URL. Nothing else changes.
reading the public RPC
With the stock Solana CLI
In each command, <rpc> is the public RPC URL above. Only the URL differs from a mainnet query. The node keeps only recent history: an older signature answers that it was not found, and the explorer shows that thought from the site's own record instead.
Read a thought by its signature:
solana confirm -v <signature> --url <rpc>The line
Compute Units Consumed: <N>is the transaction's CU (compute units, Solana's measure of work). Under "Log Messages", the lineProgram <id> consumed <N> of <M> compute unitsis the mind's own CU, andProgram data: <base64>is its answer.Decode the answer: 64 bytes, 16 signed 32-bit integers, little-endian.
echo <base64> | base64 -d | od -A n -t d4 -vRead the block that holds it, by its slot:
solana block <slot> --url <rpc>
With web3.js
This script sends 256 bytes to the digit mind in one transaction and decodes its Program data line. It runs as written: make a key, give it test gas from the chain's own faucet with the stock CLI, then run it with Node.js and @solana/web3.js installed.
solana-keygen new --no-bip39-passphrase -o thinker.jsonsolana airdrop 0.005 $(solana-keygen pubkey thinker.json) --url <rpc>import { readFileSync } from "node:fs";
import {
Connection, Keypair, PublicKey, Transaction, TransactionInstruction,
} from "@solana/web3.js";
const connection = new Connection(process.env.RPC_URL, "confirmed"); // the public RPC URL above
const payer = Keypair.fromSecretKey(Uint8Array.from(JSON.parse(readFileSync("thinker.json", "utf8"))));
const mind = new PublicKey("2HvJc3DgxJKvid4JeAgBPMY2L9ArBRJyuAFfL412DG92"); // the digit mind
// 256 bytes: pixel (row r, column c) of a 16 x 16 grid is byte r * 16 + c; 0 = no ink, 255 = full ink.
const x = new Uint8Array(256);
// One instruction, no accounts, exactly 256 bytes of data.
const ix = new TransactionInstruction({ programId: mind, keys: [], data: Buffer.from(x) });
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash();
const t = new Transaction({ feePayer: payer.publicKey, recentBlockhash: blockhash }).add(ix);
t.sign(payer);
const sig = await connection.sendRawTransaction(t.serialize());
// confirm by polling the status over HTTP
for (;;) {
const s = (await connection.getSignatureStatuses([sig])).value[0];
if (s && s.confirmationStatus !== "processed") break;
if ((await connection.getBlockHeight()) > lastValidBlockHeight) throw new Error("expired");
await new Promise((r) => setTimeout(r, 400));
}
const tx = await connection.getTransaction(sig, { commitment: "confirmed", maxSupportedTransactionVersion: 0 });
const line = tx.meta.logMessages.find((l) => l.startsWith("Program data: "));
const b = Buffer.from(line.slice("Program data: ".length), "base64"); // 64 bytes
const y = [...Array(16)].map((_, k) => b.readInt32LE(4 * k)); // 16 x i32, little-endian
const scores = y.slice(0, 10); // digit mind: outputs 0-9
const answer = scores.indexOf(Math.max(...scores)); // ties go to the lower index
console.log({ sig, y, answer, txCu: tx.meta.computeUnitsConsumed });RPC_URL=<rpc> node send.mjsThe airdrop is test gas on this chain, with no value, limited per address. The mind's address above is the digit mind; every mind and its twin are listed in the explorer.
The transaction has one instruction, an empty account list and exactly 256 bytes of data. A mind refuses any account (custom program error: 0x1) and any other data length (custom program error: 0x2).
The mind format
Every mind is the same network: Int8 256 -> 128 -> 16 (Int8, 256 inputs, 128 hidden units, 16 outputs, no biases).
- Input
x: 256 unsigned bytes. - Hidden:
h = relu(W1 x) >> 8, saturated to u8. - Output:
y = W2 h, 16 i32, logged as oneProgram dataline.
The weights file
Binary, exactly 34,824 bytes:
| Bytes | Content |
|---|---|
| 0 to 7 | ASCII COGMIND1 |
| 8 to 32,775 | W1: 128 rows x 256 columns, row-major, signed bytes. Row j holds hidden unit j's weights over the inputs. |
| 32,776 to 34,823 | W2: 16 rows x 128 columns, row-major, signed bytes. Row k holds output k's weights over the hidden units. |
A mind's identity is the sha256 of the whole file (lowercase hex), its weights hash.
The generator
A mind is machine code and an ELF file written by a generator, gen_mlp.py, from a weights file. Each mind exists twice with the same weights: the vector program, which uses the SIMD-0714 op sol_avx512, and its scalar twin on today's instruction set. Both log the same 16 outputs; only the CU differ.
The generator, the weights packer pack_weights.py and the reference check reference.py, which recomputes y off chain from the input and the weights file, are published by the project as source.
What does not work yet
- The stock Solana CLI 3.0 reads what the node still holds, but it cannot deploy an SBPF v3 program to it.
- Transaction history is short: the node keeps only its newest ledger, so the stock CLI finds a recent signature only. Older thoughts are shown in the explorer from the site's own record.
- Minds are machine code written by a generator, because today's compilers do not emit the new ops.
- Every validator needs AVX-512.
- One transaction's limit is 1,400,000 CU, so minds are small (Solana fees and limits).