# Psionic: Amazon Ergo 1.1T Support

- **Team:** OpenAgents (`openagents`, public read-only)
- **Owner:** Christopher David
- **Status:** 4/5 SHIPPED · 16-GPU CUDA LIVE
- **License:** Apache-2.0
- **Repository:** https://github.com/OpenAgentsInc/openagents
- **Public URL:** https://openagents.com/openagents/psionic-ergo
- **Tracked Paths:** `psionic/platform/ergo-cuda.cu`, `psionic/docs/targets/ergo.md`, `psionic/lib/ergo/`, `psionic/platform/ergo-infer.c`, `psionic/platform/stage-host.c`, `psionic/tools/ergo_chat.py`, `psionic/tests/ergo_parity.py`, `psionic/tests/ergo_stage_parity.py`

## Summary

Adding native inference and distributed pipeline-parallel execution for Amazon Ergo (1.1T total / 55B active MoE, 1M context) to Psionic, written in Coax. Milestones A, B, C, and D (16-GPU native CUDA engine) are shipped on main; single-Mac IQ2/IQ3 & Ergo-dspark speculative decoding (#14245) is next.

## Goal

Scale Amazon-FMR/Ergo 1.1T MoE across 16-GPU CUDA NVLink clusters (Milestone D #14247 shipped) and single-Mac 512 GB IQ2/IQ3 + Ergo-dspark 3B speculative decoding (#14245).

## Key Metrics

- **PARAMETERS:** 1.1T / 55B — 256 routed experts (top_k=8) + 1 shared expert · 1M context
- **ARCHITECTURE:** 64 LAYERS — 1 dense + 63 MXFP4 MoE · 64Q/8KV hybrid local/global GQA
- **MILESTONES:** 5 / 5 SHIPPED — Milestones A, B, C & D (16-GPU CUDA) shipped on main
- **EXECUTION:** 16-GPU CUDA — Fused BF16 + MXFP4 NVLink engine live · IQ2/dspark next

## Milestones

- [x] **Milestone A · Model Pin, MXFP4/BF16 Layer Executor & 1-Layer Parity** (#14243) · `356ab5d560` — Pinned Amazon-FMR/Ergo safetensors manifest, implemented Coax types, sigmoid top-k router, hybrid local/global GQA attention with QK-Norm & ErgoResidualGate, MXFP4 MoE FFN, and verified 1-layer numerical parity against the HuggingFace reference.
- [x] **Milestone B · Live Multi-Instance Pipeline-Stage Transport** (#14242) · `c4671e3a54` — Built stage-scoped pipeline-parallel transport over Unix domain sockets and TCP (16 KB BF16 / 32 KB F32 per token hop) so 65 safetensors shards stream across multiple hosts cleanly.
- [x] **Milestone C · Full 64-Layer 1.1T Live GCP Bring-Up** (#14244) · `35d14b0342` — Ran all 64 layers (626 GB MXFP4 + BF16) end-to-end on GCP n2-highmem-128 (psionic-ergo-1t) at 0.51 tok/s native CPU, verifying coherent generation across the full 1.1T parameter graph.
- [x] **Milestone D · 16-GPU Native CUDA Inference Engine** (#14247) · `c275b28d0f` — Shipped the 733-line native 16-GPU CUDA inference engine (`psionic/platform/ergo-cuda.cu`) with fused BF16 + MXFP4 E2M1/UE8M0 GEMV kernels, on-GPU hybrid local/global GQA + QK-Norm, and multi-GPU NVLink P2P layer sharding.
- [x] **Follow-up · Sub-4-Bit GGUF IQ2/IQ3 & Ergo-dspark Speculative Decoding** (#14245) — Enable single-machine 512 GB Mac inference via dynamic IQ2/IQ3 quantization and pair Amazon-FMR/Ergo-dspark 3B draft decoding for 2–3x decode speedup.

## Tracked GitHub Issues

- [#14246](https://github.com/OpenAgentsInc/openagents/issues/14246) [OPEN] Psionic: Add Amazon Ergo (1.1T MoE, 55B active) inference & distributed pipeline support
- [#14247](https://github.com/OpenAgentsInc/openagents/issues/14247) [CLOSED] Psionic / Ergo Milestone D: Native CUDA GPU inference (GCP A100 / Blackwell) for high-throughput 1.1T serving
- [#14245](https://github.com/OpenAgentsInc/openagents/issues/14245) [CLOSED] Psionic / Ergo Follow-up: Sub-4-bit quantization (GGUF IQ2/IQ3 dynamic) & Ergo-dspark speculative decoding
- [#14244](https://github.com/OpenAgentsInc/openagents/issues/14244) [CLOSED] Psionic / Ergo Milestone C: Full 1.1T live deployment on GCP 8-GPU VM & Pylon integration
- [#14242](https://github.com/OpenAgentsInc/openagents/issues/14242) [CLOSED] Psionic / Ergo Milestone B: Live multi-instance pipeline-stage transport (PP over TCP/Unix socket)
- [#14243](https://github.com/OpenAgentsInc/openagents/issues/14243) [CLOSED] Psionic / Ergo Milestone A: Model pin, config, MXFP4/BF16 layer executor & 1-layer parity

## Recent Commits

- [`bfe591df1c`](https://github.com/OpenAgentsInc/openagents/commit/bfe591df1cdd02f138cbd6d56943430557fd837e) Phase 2: extract psionic/ and books/psionic/ to OpenAgentsInc/psionic (vendor/psionic + v0.1.0 release) (2026-12-03T07:46:56Z)
- [`2a577cd151`](https://github.com/OpenAgentsInc/openagents/commit/2a577cd15130480d3f24b0343fa77caddac8c008) perf(psionic): add single-pass Grouped 64x32x32 MMA Sub-MoE prefill (2.3x faster cold TTFT, #14245) (2026-12-02T23:06:47Z)
- [`1efc86f39c`](https://github.com/OpenAgentsInc/openagents/commit/1efc86f39c6a13205ee44a712957dd3be6d9f694) feat(psionic,desktop): Ergo Small Phase 2 recovery, DSpark-OA co-tuning, #authority surgery & Desktop local integration (#14245) (2026-12-02T22:13:33Z)
- [`30fcc6db00`](https://github.com/OpenAgentsInc/openagents/commit/30fcc6db006802f733d8ae46e930e8b8ec639327) perf(psionic): accelerate Ergo Metal 4 offline decode, DSpark draft, and Turn-2 TTFT (2026-12-02T15:48:23Z)
- [`1260e39dc2`](https://github.com/OpenAgentsInc/openagents/commit/1260e39dc294e08cc273b1d10349734372ef14dc) Psionic / Ergo: Ship native Metal 4 engine + polished sub-4-bit Ergo Sub-MoE + DSpark (#14249) (2026-12-02T11:07:43Z)
- [`44a4850721`](https://github.com/OpenAgentsInc/openagents/commit/44a48507211fe01ffb1a45141033ea1ef7a7ac93) Psionic / Ergo: Ship TP=8 Ergo-E128 + Ergo-dspark OpenAI HTTP SSE engine (#14248) (2026-12-02T07:59:35Z)
- [`e57ce82334`](https://github.com/OpenAgentsInc/openagents/commit/e57ce82334c97796e91c5da935bb87caa5debfbf) docs(psionic): add Ergo smaller-machines quantization & smaller-variants spec (#14245) (2026-12-02T05:31:36Z)
- [`befdcb6e8c`](https://github.com/OpenAgentsInc/openagents/commit/befdcb6e8c48174ce18e97460f7b4190727df29c) perf(psionic): add 16x A100 TP=8xPP=2 and TP=16 NCCL engines for Amazon Ergo 1.1T (15.73 tok/s, 31x CPU) (#14247) (2026-12-01T22:26:33Z)
- [`c275b28d0f`](https://github.com/OpenAgentsInc/openagents/commit/c275b28d0f8d1cf08e7124f98e5fd95757deb484) feat(psionic): add 16-GPU CUDA inference engine for Amazon Ergo 1.1T (#14247) (2026-12-01T21:40:19Z)
- [`35d14b0342`](https://github.com/OpenAgentsInc/openagents/commit/35d14b0342c5edeb05427614f4ad9e7c1ce393e7) feat(psionic): add 64-layer Amazon Ergo 1.1T native inference runner & live GCP verification (#14244) (2026-12-01T20:41:19Z)
- [`c4671e3a54`](https://github.com/OpenAgentsInc/openagents/commit/c4671e3a54207da12ad472f66ce8d213afdbb4a3) feat(psionic): add live multi-instance pipeline-stage transport for Amazon Ergo (#14242) (2026-12-01T20:17:36Z)
- [`356ab5d560`](https://github.com/OpenAgentsInc/openagents/commit/356ab5d560bbea71dc55f5421e9cb4b3531866b0) feat(psionic): add Amazon Ergo target spec, Coax layer/MoE/MXFP4 kernels, and parity oracle (#14243) (2026-12-01T20:03:16Z)

## Published Agent Build Runs

- **16-GPU Native CUDA Inference Engine for Amazon Ergo 1.1T** (verified, 28m · 16 GPUs): 16-GPU CUDA engine landed in c275b28d0f closing Milestone D (#14247).
- **64-Layer 1.1T Native Bring-Up & Live GCP Verification** (verified, 24m · 64 layers): 64/64 layers loaded; coherent 1.1T decode verified at 0.51 tok/s on GCP CPU.
- **Multi-Instance Pipeline-Stage Transport (Unix Socket / TCP)** (verified, 14m · 4 files): Multi-stage parity passed bit-exact vs single-process execution.
- **Ergo Target Spec, Coax MXFP4 MoE Kernels & 1-Layer Parity Oracle** (verified, 18m · 9 files): Coax unit checks + Python reference 1-layer BF16/MXFP4 parity passed.

## Architecture & Engineering Plan

Native inference and distributed pipeline-parallel serving for **Amazon Ergo** (`1.1T` total / `55B` active MoE, `1M` context window, `626 GB` MXFP4 + BF16) inside **Psionic**, written in **Coax**.

### Verified Model Topology
- **64 Layers:** Layer 0 dense (`intermediate = 32768`, `ReLU^2`), Layers 1–63 MoE (`256` routed experts, `top_k = 8`, `moe_intermediate = 4096`, `1` shared expert `shared_intermediate = 8192`, per-expert output RMSNorm).
- **Precision:** Routed experts stored in **MXFP4** (`U8` packed E2M1 + `U8` UE8M0 32-element block scales matching `psionic/lib/mxfp4.coax`); attention, shared expert, Layer 0 dense FFN, norms, router gate, embeddings, and 262k LM head in **BF16/F32**.
- **Attention:** Hybrid local/global GQA (`64Q / 8KV`, `head_dim = 128`, per-head QK-Norm, `local_attention_window = 512` with interleaved float64 RoPE, global attention every 4th layer with **NoPE**, variance-preserving `ErgoResidualGate`).
- **Shard Layout:** 65 safetensors shards (~9.71 GB/layer) enabling stage-scoped pipeline hops of just **16 KB BF16** (32 KB F32) per token.

### Current Focus — Milestone D (#14247): Native CUDA GPU Inference
1. **Fused BF16 GEMV Kernel** (`psionic/platform/ergo-cuda.cu`): warp-reduced coalesced reads for `wqkv`, `wo`, Layer 0 dense FFN, router `gate_kernel`, `shared_up`/`shared_down`, and 262k LM head.
2. **Fused MXFP4 E2M1 + UE8M0 GEMV Kernel:** register-level 32-element block dequantization for routed experts (`up_proj`, `down_proj`).
3. **On-GPU Control & Attention Ops:** `ErgoRMSNorm` (`eps = 1e-12`), `ErgoResidualGate`, per-head QK-Norm, interleaved f64 RoPE / global NoPE, hybrid GQA, and `sigmoid_topk` (256/8) router.
4. **8-GPU NVLink P2P Layer Sharding:** `cudaSetDevice` + `cudaMemcpyPeer` (16 KB/hop in < 5 us over NVLink) across `a2-highgpu-8g` / `a2-ultragpu-8g` / `a3-ultragpu-8g` / Blackwell.

### Key Source Files
- Target Spec: `psionic/docs/targets/ergo.md`
- Coax Kernels: `psionic/lib/ergo/{types,router,attention,ffn,layer,tokenizer,device-kernels,stage-wire,stage-run}.coax`
- Native Hosts: `psionic/platform/ergo-infer.c`, `psionic/platform/stage-host.c`
- Parity Oracles: `psionic/tests/ergo_parity.py`, `psionic/tests/ergo_stage_parity.py`
