A token-compressed DSL (.psudo), a Polish-prefix intermediate representation ( pIR), a borrow-checked safe Rust transpiler, and a pure-Rust 2-bit ternary (TQ2_0) inference engine—built to run local code synthesis inside a 4 GB VRAM budget.
flowchart LR
A[".psudo DSL"] --> B["pIR (Polish-prefix IR)"]
B --> C["pseudo-engine (100M TQ2_0 + PDA Mask)"]
C --> D["Borrow Checker & Sandbox"]
D --> E["Safe Rust (0 unwrap)"]
| Metric | Value |
|---|---|
| Primary Model Footprint | 47.0 MB (100.7M params,TQ2_0 2-bit ternary weights) |
| Context Compression | 45–60% fewer tokens than surface syntax viapIR |
| Syntax Error Rate | 0% at decode time via Pushdown Automaton (PirPdaConstraint ) masking |
| Runtime Dependencies | Zero (pure Rust, memmap2 , no CUDA/C++ toolchains required) |
| Training Dataset | ~7,800 borrow-checked & sandbox-verified trajectories |
Both quantized .gguf checkpoints (47.0 MB and 23.2 MB) ship right in this repo, and everything compiles with plain cargo (zero C++, Python, or CUDA dependencies):
git clone https://github.com/steveSujo/psudo.git
cd psudo
cargo build --release && ./target/release/psudo demo
I wanted to run and train coding models on my own machine—not rent bigger GPUs or burn cloud token quotas on every loop and helper function.
My laptop has an NVIDIA GTX 1660 Ti with 4 GB of VRAM and limited RAM, so running frontier models locally is out of the question. Instead of seeing those limits as the problem, I treated them as creative constraints: how can I make the best out of this? Finding a creative solution is way more fun than throwing raw power at the problem or trying to vertically scale my PC.
Running a small, limited model with 2-bit precision (TQ2_0) shrinks the VRAM footprint enough to live comfortably alongside an IDE and compiler—and exploring how far that tiny model can push raw coding power became the whole point:
- A tiny surface language (
.psudo): Python-indented, minimal punctuation, almost zero boilerplate tokens. - Lowering to safe Rust (
pseudo-transpiler): A toy language has no ecosystem. To build real binaries, verified and borrow-checked.psudolowers into safe Rust (0``.unwrap()or.expect()calls) and compiles withcargo. - The Cactus & Needle spark: SeeingCactus andNeedle —2-bit on-device models (
29M–121Mparams in8–29 MB) beating much larger models on constrained tool calls—showed what tight constraints can do. - "What if?":* What if I trained a ~100M 2-bit ternary model (
TQ2_0) whose only job is writing atomic.psudofunction bodies locally, while I (or a frontier LLM) stay at the orchestrator level?*
Asking a 100M model to emit verbose surface syntax wastes half its context window on keywords and whitespace. Instead, the model emits pIR (Pseudo Intermediate Representation)—a Polish-prefix S-expression format where fn is f, let is v, return is r, if is ?, and while is w:
// Surface .psudo (what humans read)
fn clamp_val(val, lo, hi)
if val < lo
return lo
if val > hi
return hi
return val
// Wire pIR (what the 100M model emits)
f clamp_val (val lo hi) [
? (< val lo) [ r lo ]
? (> val hi) [ r hi ]
r val
]
That trade buys two things:
-
45–60% fewer tokens per function body.
-
0% syntax errors at decode time:
pseudo-engineruns a pushdown automaton (PirPdaConstraint) over the8,192-token BPE vocab and masks out invalid tokensbefore sampling. -
pseudo-100m-tq2_0.gguf(100.7Mparams,47.0 MB) — Primary:d_model = 768,14layers,12heads (4KV heads),FFN = 2048,vocab = 8,192,max_seq_len = 512,TQ2_0ternary weights ({-1, 0, 1}). Auto-discovered bypsudo synthfor ~15-line atomic stubs (guards, math, loops, JSON/KV helpers). -
pseudo-33m-tq2_0.gguf(33.6Mparams,23.2 MB) — Embedded Fallback:d_model = 512,8layers,8heads (4KV heads). Baked into thepsudobinary for offline smoke tests if no external.ggufis present.
Both were distilled from Qwen/Qwen2.5-Coder-7B-Instruct-AWQ plus a synthetic generator—every sample had to pass type checking, borrow checking, and sandbox execution in headless psudo before being compiled to canonical pIR (~7,800 verified trajectories across <pir>, <error> 1-shot auto-heal, <zettel>, and <clarify>).
Requires Rust 1.75+. Build both binaries ( psudo and pseudo-engine):
cargo build --release
examples/ ships three pre-built workspace capsules (psudo.bin) with mock sandbox data in .pseudo/sandbox/:
./target/release/psudo check examples/log-incident-filter/psudo.bin --all-modules
./target/release/psudo build examples/log-incident-filter/psudo.bin --run
./target/release/psudo build examples/sensor-alert-monitor/psudo.bin --run
./target/release/psudo build examples/quota-fee-calculator/psudo.bin --run
Your code lives inside a single signed capsule file (psudo.bin). You (or an outer coding agent) declare signatures, stubs, and tests; psudo synth fills in the bodies locally.
psudo init my-app --template blank --with-docs && cd my-app
psudo vfs stub compute_fee units rate free_tier \
--directive "if units <= free_tier return 0, else return (units - free_tier) * rate"
psudo synth --write
psudo dag --format mermaid
psudo contract
psudo vfs test test_fee --call "compute_fee(15, 2, 10)" --expect "10"
psudo vfs wire --entry main_task --call "print(compute_fee(15, 2, 10))" --return "0"
psudo check -a
psudo test
psudo run --call "compute_fee(15, 2, 10)"
psudo build --run
When I tested outer LLM agents with this CLI, they kept peeking at the .psudo source and hand-writing functions instead of using psudo synth. So psudo vfs show --all and psudo synth --print stay locked unless you pass the key:
- Question:"What jumped over the lazy dog?"
- Key:
--reveal-code "the slow pink elephant"
For agent harnesses, psudo-orchestrator and psudo mcp (stdio JSON-RPC) are included. Run psudo --help, psudo docs, or psudo -s for the full reference.
This is not a polished product. It is an exploration of an idea with plenty of sharp corners:
- Keep stubs atomic: A
100M2-bit model cannot write an HTTP server in one shot. Give it small, single-purpose functions (guards, clamping, arithmetic, simple loops, KV/JSON helpers). - Grammar masking != semantic intelligence: The PDA mask guarantees valid
pIRbrackets and ops, so an out-of-distribution prompt still produces valid syntax—just logically wrong fallback code. - Strict 4-space indentation &
//comments: 2-space indents and tabs fail withE002;#comments fail withE001. - Sealed
psudo.binfeels weird at first: Keeping source inside a masked binary capsule is deliberately awkward for manual editing—it exists to keep outer agents in the orchestrator seat. - Bimodal CPU speeds:
pseudo-engine --benchmarkswings between fast runs whenmemmap2pages are hot and slow runs on cold pages or OS background scheduling. - Windows-first mileage: Most testing happened on Windows 11. Rebuilding while
psudo.exeis running hits Windows file locks, and Linux/macOS paths have less mileage.
Expect bugs! I'll keep tweaking the language and the tiny model as I experiment.
| Path | Description |
|---|---|
pseudo-lang/ |
.psudo lexer, parser, borrow checker,psudo.bin VFS capsule, contract generator, andpsudo CLI |
pseudo-engine/ |
Pure-Rust zero-copy GGUF parser, TQ2_0 ternary kernels, 2-tier INT8 KV cache, PDA sampler, and--daemon |
pseudo-transpiler/ |
Deterministic IR lowering between .psudo and safe, zero-unwrap() Rust |
examples/ |
Pre-built capsules ( log-incident-filter ,sensor-alert-monitor ,quota-fee-calculator ) |
templates/ |
Source .psudo templates and.pseudo/sandbox/ fixtures forpsudo init |
.agents/skills/ |
psudo-orchestrator skill for LLM harnesses |