Qwen2.5-Coder-1.5B Solana operator (v2)
A fine-tune of Qwen/Qwen2.5-Coder-1.5B-Instruct that turns a multi-step Solana operation request plus a description of the environment into exactly one bash script that carries it out against a local validator and prints labelled evidence for every step.
This is a task-specific model, not a general Solana assistant. Its scripts call the solana CLI and
helper commands that are not part of a standard Solana install; the exact set is listed under
Required tools.
This is revision v2. The first release (single short operations, SFT + GRPO) is still available as
revision v1.
What changed from v1
- Requests: multi-step requests of 1,500 to 6,000 characters with several labelled cases each (v1: one operation of about 250 characters).
- Programs: trained on 24 generated Anchor programs whose identifiers (program, instruction, account, field and error names, PDA seeds) are drawn at random, and evaluated on 7 more it never saw. v1 knew one program.
- Scripts follow an explicit contract (below): evidence for every case, the exit code is 0 only if the request was done, expected failures are results, keys are derived deterministically.
- No brevity objective. v1 was rewarded for short scripts; v2 prints what a reviewer needs to judge each step.
- Sampling defaults:
generation_config.jsonnow sets greedy decoding withrepetition_penalty1.0 (v1 shippedtop_k20 andrepetition_penalty1.1, which made the model misspell names).
The contract the scripts follow
- Exactly one fenced
bashblock and nothing else. - Every labelled step or case is done, and its result printed under its label: the values asked for, the transaction signature, and for an error its name, code and the program that raised it.
- A call the request expects to fail is a result: the script checks that it failed inside the program (not while the transaction was being built) with the expected error, and goes on.
- Exit code 0 only if every call expected to succeed did and every call expected to fail failed as expected. An unexpected success, a failure before reaching the program or a missing account exits non-zero and says so.
- Helper JSON is kept in a variable and checked (
.ok,.stage) before fields are printed. - Keys are derived from fixed labels (
sha256of the label as the ed25519 or secp256k1 seed), so a second run in a fresh environment creates the same addresses. - Addresses from the request are set once in variables; PDAs given by their seeds are derived with
sol-pda.
Required tools
Measured from the scripts themselves: every command in the 440 training scripts and in the model's 58 held-out replies. No other command appears.
Standard command-line tools
| Tool | What the scripts use |
|---|---|
solana (Agave CLI, trained on 2.3.13) | account <addr> --output json, balance, transfer, transaction-history <addr> |
solana-keygen | pubkey <file> |
node with @solana/web3.js resolvable (NODE_PATH) | deterministic keypair files: Keypair.fromSeed(sha256(label)) |
jq | parsing helper output, building JSON arguments |
curl | JSON-RPC calls (getSignaturesForAddress) |
sed, tail, grep, tr, base64, xxd, mkdir, dirname | text and byte handling |
Environment-specific helpers
None of these ship with Solana. To use the model elsewhere you need equivalents with the same arguments and JSON output.
| Helper | Arguments as the model uses them | Output the model reads |
|---|---|---|
sol-call | <idl> <instruction> --args JSON --accounts JSON [--remaining JSON] [--simulate] | ok, stage, signature, returnData, logs, error.{name,code,program,message} |
sol-account | <idl> <address> or <idl> --all <AccountType> | ok, data.<field>, accounts[] |
sol-pda | `<program-id | idl> ... (str:, pubkey:, u64le:`, ...) |
sol-tx | <signature> --idl <idl> | logs, events |
sol-deploy | <program> | ok, programId, upgradeAuthority |
eth-sign | `<0xprivkey> <0x32-byte digest> --v-base 0 | 27` |
eth-recover | <0xdigest> <0xsignature> | address |
sha256, keccak256 | <0xhex> or --utf8 <text> | the digest as 0x hex |
sol-call accepts integers as numbers or decimal strings, bytes as 0x hex or {"utf8": ...}, structs
as objects; --accounts maps account names to addresses or keypair files, and a keypair given for a
signing account signs. Errors carry the failing program, also when raised through CPI.
Environment conventions
- RPC at
http://127.0.0.1:8899; the CLI and helpers default to it. Default payer and CLI keypair/keys/dev0.json; funded keys/keys/dev1.jsonto/keys/dev3.json. - Program binaries, keypairs and Anchor IDLs under
/artifacts, in whatever layout the prompt lists. /workis writable and persists between scripts.
Usage
Send no system prompt and one user message in this shape:
## Environment
RPC URL: http://127.0.0.1:8899 (inside the environment; the solana CLI and all helpers default to it)
Scripts run as root in /work (writable, persists between scripts of this test).
A program is on chain only once a script of this test, or its shared setup, has deployed it.
Funded keypairs (dev0 is the default payer and CLI keypair):
/keys/dev0.json <pubkey>
...
Artifacts (read-only):
/artifacts/<path>/<program>-keypair.json (program id <pubkey>)
/artifacts/<path>/<program>.so
/artifacts/<path>/<program>.json
...
## Operation request
<facts: program ids, keys and the labels they derive from, PDAs and their seeds, instruction
signatures with accounts in order, expected errors; then labelled cases (a), (b), ...>
Reply with exactly one ```bash fenced block and nothing else.
Decode greedily (temperature 0, repetition_penalty 1). Replies run to about 2,500 tokens; allow up to
6,000 new tokens and serve with a context of at least 12,288 tokens.
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "eriwar/qwen2.5-coder-1.5b-solana-operator"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(repo, torch_dtype="bfloat16", device_map="auto")
messages = [{"role": "user", "content": prompt}] # prompt in the format above
inputs = tok.apply_chat_template(
messages, add_generation_prompt=True, return_tensors="pt", return_dict=True
).to(model.device)
out = model.generate(**inputs, max_new_tokens=6000)
print(tok.decode(out[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True))
With vLLM: vllm serve eriwar/qwen2.5-coder-1.5b-solana-operator --max-model-len 12288 and request temperature=0, repetition_penalty=1.
Training
Supervised fine-tuning only, LoRA (rank 16, alpha 32) merged into the weights: 440 examples, 3 epochs, learning rate 2e-4, sequences up to 8,192 tokens (longest example 5,382).
The examples come from 24 generated Anchor programs in three families: vault-style apps (deposits, fees, pausing, return data), attestation light clients (secp256k1 attestor signatures over a sha256 or keccak256 digest, Borsh proofs, consensus states per height) and router trios (an access manager with role grants, a router that checks roles and calls an app through CPI with remaining accounts, and the app). Requests cover signed attestations (45%), cross-program packet flows (25%), reading the chain (16%), plain calls (9%) and setup (4%), and include traps (a precondition that does not hold, a call that unexpectedly succeeds, a missing account) whose right answer is to report and exit non-zero.
Every training script was executed in a validator container before it was used, and passed: the reply format and command checks, a per-case verifier of chain state and printed evidence, the exit code, and, if it creates keys, an identical rerun in a fresh environment.
Evaluation
58 held-out tasks on 7 programs never used in training, decoded greedily, every script executed in a validator container and checked as above.
| Check | Target | Result |
|---|---|---|
Exactly one closed bash block passing bash -n | 100% | 100% |
| Only commands that exist | >= 99.5% | 100% |
| Whole request done, with evidence for each step | >= 95% | 94.8% |
| Exit code correct, including on traps | >= 99% | 94.8% |
| Claims success it didn't have | <= 0.2% | 0.0% |
| Same addresses on a second run in a fresh environment | 100% | 100% (4 of 4) |
By kind (whole request done): attestation 24/24, reading the chain 12/12, setup 4/4, cross-program packet flows 10/12, plain calls 5/6. The three failures exited non-zero and said why: one address copied with a character missing, and two cases where a PDA seed was written from habit instead of from the request.
Reply time on an RTX 3060 with plain transformers generation (about 40 tokens/s): median 42.6 s, p95
50.7 s. A serving engine is several times faster.
Limitations
- The held-out programs are new instances of the three families above, not unrelated code. Requests of other kinds, or programs with very different structure, are out of distribution.
- 58 held-out tasks is a small evaluation; small kinds (6 or 12 tasks) move by one failure.
- The model can still miscopy a long address or fall back on a familiar identifier instead of the one in the request; its scripts check derived keys against the request and report a mismatch.
- Scripts execute transactions. Run them only against a local or test validator, in a sandbox, and never with keys that hold real funds.
License
Apache 2.0, the same as the base model.