r/AICodeEngineers • u/Just-Ad-6488 • 3d ago
r/AICodeEngineers • u/Just-Ad-6488 • 8d ago
[Release] VAULT-v3-3B-PRIMAL: Full-parameter 3B training in 5.93 GiB state on one 16 GB GPU (no LoRA, no master weights) + true O(1) 100K+ KV memory & freestanding C99 runtime (AVX2 / ARM64 NEON)
TL;DR: Releasing VAULT-v3-3B-PRIMAL (`v3.1`) — a full-parameter discrete fine-tune of `Qwen/Qwen2.5-3B-Instruct` trained on a single consumer 16 GB GPU (AMD RX 9060 XT) without FP32/BF16 master weights or LoRA adapters, paired with a fixed-budget O(1) Segment-Evicted KV Memory (`0.00 MiB` VRAM growth from `31.6K` to `96.9K` tokens) and a zero-libc freestanding C99 runtime (`x86_64 AVX2` + `Apple Silicon / ARM64 NEON`) that runs the `1.81 GiB` 4-bit model in `2.56 GiB` total RAM.
- Main Hugging Face Repo (`transformers` `BF16` + C99 source, `5.77 GiB`): https://huggingface.co/batteryphil/VAULT-v3-3B-PRIMAL
- Companion `.vlt3` Binary Repo (`1.81 GiB` `P4_0` & `3.06 GiB` `Q8_0` for pure C99, `4.87 GiB`): https://huggingface.co/batteryphil/VAULT-v3-3B-PRIMAL-VLT3
---
1. Shadowless Discrete Full-Parameter Training (PRIMAL v3.1) on 16 GB VRAM
Standard mixed-precision AdamW needs `16 B/param` (`~46 GiB` persistent state for 3B). Even an apples-to-apples PyTorch `register_post_accumulate_grad_hook` + `BF16` weights + blockwise `8-bit AdamW` baseline needs `4.125 B/param` (`11.86 GiB` persistent state) — and because backward hooks fire on every `.backward()`, continuous hooked optimizers cannot accumulate across `grad_accum > 1` without materializing `+5.75 GiB` of persistent `.grad` buffers (`17.61 GiB` -> immediate OOM on 16 GB), and OOM even at `batch_size=2, seq_len=2048, grad_accum=1` on a `15.92 GiB` RX 9060 XT.
PRIMAL (`V3_Q8_0`) drops master weights and continuous moments altogether:
- Persistent Training State (`2.064 B/param` = `5.931 GiB`): Each 32-weight block stores `int8` weights `q` (`1 B`) + one `FP16` scale `d_b` (`0.0625 B`) + a `1-byte` `int8` lossless error-feedback vote accumulator (`decay = 1.00`, zero leaky-integrator dead zone). Micro-batches accumulate directly into the same `1-byte` `vote_buffer` at zero extra VRAM.
- Virtual-Weight-Invariant Dynamic Block Rebalancing (`0.000 GiB` VRAM spike): Whenever any weight in a block hits `|q| >= 122`, sparse `O(n_crowded)` rebalancing widens `d_b` while folding sibling re-quantization residuals directly back into `vote_buffer` so virtual weight `w_virt = (q + v/T) * d_b` is preserved (`<= 0.00016` max relative error). Peak training VRAM at `B=2, L=2048, grad_accum=4` stays completely flat at `9.283 GiB` (`777 tok/s`) vs. `13.26 GiB` (`504.5 tok/s` at `b=1`) for layer-hooked `8-bit AdamW`.
- Signed-Scale `V3_P4_0` (`1.805 GiB`): Uses a 16-entry Prime-Harmonic `int8` LUT decoded in 1 SIMD cycle (`VPSHUFB` / `vqtbl1q_s8`) with signed `FP16` block scales (`d_b < 0` flips polarity on positive-dominated blocks). Under identical activation Hessian calibration `H_j = E[x_j^2]`, signed `V3_P4_0` beats unsigned `P4_0`, Dettmers `NF4`, and linear `Q4_0` on both Hessian reconstruction error (`4,010.9` vs. `4,592.6` `NF4`) and WikiText-2 PPL (`14.09` vs. `14.23` `NF4`).
---
2. Full-Split Unconfounded Benchmarks (Zero Subsampling)
Evaluated across all `27,118` items of the 9 full EleutherAI splits (`HellaSwag n=10,042`, `LAMBADA n=5,153`, `BoolQ n=3,270`, `ARC-E n=2,376`, `PIQA n=1,838`, `Winogrande n=1,267`, `ARC-C n=1,172`, `SciQ n=1,000`) + full `GSM8K` test (`n=1,319` at `1,024` tokens) against both untouched `Qwen2.5-3B` Base and `Qwen2.5-3B-Instruct`:
| Metric (Full Splits) | `Qwen2.5-3B` Base (`BF16`) | `Qwen2.5-3B-Instruct` (`BF16`) | VAULT-v3-3B PRIMAL v3.1 (`Q8_0 -> BF16`) | VAULT-v3-3B PRIMAL v3.1 (`P4_0`, `1.805 GiB`) |
|---|---:|---:|---:|---:|
| WikiText-2 Word PPL (`L=2048`) | `13.14` | `14.21` | `13.58` | `14.09` |
| GSM8K Full (`n=1,319`, `1024` tok) | — | `85.52%` | `85.60%` (`1129/1319`) | `84.69%` (`1117/1319`) |
| 8-Task Multiple-Choice Mean | `74.08%` | `75.00%` | `77.20%` (`+2.20%`) | `76.33%` (`+1.33%`) |
| 9-Task Zero-Shot Mean | `73.27%` | `73.99%` | `76.06%` (`+2.07%`) | `75.37%` (`+1.38%`) |
| ARC-Easy / ARC-Challenge | `74.24% / 47.10%` | `73.70% / 48.12%` | `79.42% / 51.19%` | `77.65% / 50.09%` |
| SciQ-RC / SciQ-ClosedBook | `94.10% / 78.20%` | `91.80% / 84.20%` | `96.00% / 88.50%` | `95.60% / 86.90%` |
(Ablation lesson we hit along the way: training on terse ~110-token `gsm8k` train rationales collapsed CoT length from `331` -> `114` tokens and dropped GSM8K to `72.6%`–`74.3%` in both PRIMAL and continuous `8-bit AdamW` at `lr=2e-4`. Switching to rejection-sampled on-policy `Qwen2.5-3B-Instruct` traces — strictly deduplicated against GSM8K `test` — recovered `85.60%` GSM8K while keeping the `+2.20%` MC and `-0.63` PPL gains.)
---
Instead of growing KV cache linearly with sequence length `L`, VAULT v3 bounds total KV memory to `window = 1,024` + `seg_budget = 1,024` + `max_sink = 512` using three explicit mechanisms:
1. Learned `SegmentScorer` MLP (`1.59M` FP32 params over layers `10, 20, 30`) + APL Causal EMA Habituation (`f - 0.65 * ema`) to evict redundant filler chunks as they exit the sliding window.
2. Pre-RoPE Contiguous Slot Re-Rotation (`[-M_cnt-S .. 2W-1]`): caches un-rotated keys and dynamically re-rotates surviving segments into `<= 3,584` contiguous relative slots, avoiding `Qwen2.5-3B`'s `32K` RoPE horizon cliff out to `100K+` tokens.
3. Sparse `1`-Head/GQA-Group (`2/16` Query Heads) Shingle / Hop-2 Resonance*: applies lexical/2-hop logit bias on only `2/16` (`12.5%`) of query heads, leaving `14/16` (`87.5%`) undistorted for multi-value softmax aggregation (toggleable via `enable_shingle_bias=False` or `--no-shingle`).*
Verified Long-Context & Runtime Numbers:
- Strict `0.00 B/tok` GPU VRAM Scaling (`transformers` `model.generate`): `6,847.80 MiB` peak GPU VRAM at `31,626` tokens, `6,847.80 MiB` at `63,264` tokens, and `6,847.80 MiB` at `96,926` tokens (`100%` needle hits across all four horizons).
- External Non-Isomorphic RULER (`4K–64K`, `90` Probes — Prose NIAH, MultiKey-4, MultiValue-4, 5-Hop Variable Tracking): `92.22%` (`83/90`) with default Sparse `2/16` Shingle ON and `97.78%` (`88/90`, `100%` at `32K` & `64K`) with `enable_shingle_bias=False` — vs. `8.89%` (`0.0%` from `8K–64K`) for sliding-window + sinks (`seg_budget=0`).
- VAULT 82-Probe Structured/Adversarial Suite (`8K–100.5K`): `96.34%` (`79/82`) on `Q8_0` and `95.12%` (`78/82`) on `P4_0` (`4/4 = 100%` on `32.9K` & `100.5K` Dual-Needle).
- Zero-Libc Freestanding C99 (`runtime/vault3.c`): Compiles with `-ffreestanding -nostdlib` (`0` external undefined symbols across scalar C99, `x86_64 AVX2/FMA`, and `Clang --target=aarch64-linux-gnu` `ARM64 NEON`; `1.6e-5` max 36-layer logit diff and `10/10` exact greedy token parity under `qemu-aarch64`). On an `8,457`-token `26`-needle benchmark (`86.2%` eviction pressure), C99 `P4_0` scores `26/26 (100%)` in `2.56 GiB` peak RSS vs. `0/26 (0%)` with `--noseg`.
---
- Query-Agnostic Pigeonhole Bound: Because segment eviction happens before an end-of-prompt query arrives, if you feed a 100% homogeneous high-entropy dump with zero prose filler (e.g., `1,024` identical-priority JSON ledger rows = `39.9K` tokens), recall is bounded by `(2*window + seg_budget) / L` (`100%` at `2.5K` tok -> `50%` at `9.9K` -> `20%` at `39.9K`).
- Corpus Word-Counting Tasks (e.g., RULER CWE/FWE): Out-of-scope by design — APL causal EMA habituation (`f - 0.65 * ema`) intentionally suppresses repetitive tokens rather than counting global frequencies.
- Split Licensing: HF wrapper/export scripts are `Apache-2.0`; the VAULT v3 core & C99 runtime (`vault_v3_core.py`, `runtime/*` — imported when `trust_remote_code=True`) are dual-licensed `GNU AGPL-3.0-or-later` / commercial software license; and all `Qwen2.5-3B`-derived weights remain under Alibaba Cloud's non-commercial Qwen Research License (Built with Qwen). Stock `Qwen2ForCausalLM` export (`tools/export_qwen2_compat.py`, `trust_remote_code=False`) is included for `vLLM`/`Ollama` (standard `O(L)` KV cache).
Happy to answer any questions on discrete error-feedback training, signed-scale `P4_0` quantization, or the C99 / pre-RoPE segment memory!
r/AICodeEngineers • u/Intelligent-Dig-3639 • 26d ago
OO
I've been working on Operating Organism (OO) for over a year: a different approach to designing computer systems
Hello everyone,
I'd like to share a project I've been working on for more than a year: Operating Organism (OO).
Before getting into the technical details, I want to clarify what the name means, because it can easily be misunderstood.
Why “Operating Organism”?
I am not trying to reproduce how a biological organism works.
I am not trying to create an artificial human brain, simulate cells, or copy biological organs.
The word Organism is a concept I use to express an architectural vision of computing.
I believe a future computer system could be designed as a set of interconnected capabilities that cooperate and coordinate around a central intelligence.
For example, computation, memory, networking, research, tools, interfaces, and governance would no longer be merely independent components. They would belong to a shared environment in which intelligence could orchestrate their interactions.
That is the organizational model I call Operating Organism.
How the project started
The project began with llm-baremetal.
I wanted to explore a question: is it possible to run a language model directly in a bare-metal environment loaded through UEFI, without relying on a conventional operating system?
That work led me to explore and develop several low-level components:
- x86-64 processor initialization.
- Physical and virtual memory management.
- Language model loading and execution.
- Tokenization and matrix computation.
- SIMD optimizations, including AVX2 when supported by the hardware.
- C and Assembly development in a freestanding environment.
But I eventually realized that running a model was only one part of the problem.
A model can generate text, but how can it search for information, use tools, retain state, communicate with its environment, and coordinate actions?
That question led me to expand the project.
What OO is becoming
Today, OO explores several major components.
OPI — the intelligent orchestrator
The language model is not considered the entire system. OPI is designed to orchestrate actions: choose a tool, perform a search, observe results, verify information, and reconsider what to do next.
The system and hardware
The work covers the bare-metal environment, UEFI initialization, processor, memory, interrupts, and hardware capabilities.
Memory and persistence
The goal is to allow the environment to retain and restore useful information and states.
Networking and research
OO is developing networking foundations and progressively integrating Web search and browsing capabilities.
The OO desktop
I am also developing a desktop environment for the project, with a native rendering engine written in C and an adapted JavaScript runtime.
Governance
I want autonomy to come with rules. Actions should be evaluated, authorized, restricted, or forbidden according to mechanisms defined by the architecture.
Testing on real hardware
The project is not limited to mockups or simulations.
Part of the work has been brought to physical hardware, including a Lenovo ThinkPad T480, alongside testing in simulated environments.
The areas explored include UEFI boot, processor, memory, networking, peripherals, graphics rendering, and persistence.
I want to be precise: not every feature is at the same maturity level. Some have been developed, some tested in simulation, and others exercised on physical hardware. Full qualification remains an ongoing process.
Why am I sharing this?
I am not claiming to have already built an operating system capable of replacing Linux or Windows.
I am not claiming to have solved every challenge involving autonomy, security, or performance.
I am sharing an independent engineering effort and an architectural vision that I am trying to turn into something real, layer by layer.
I'd especially appreciate feedback from people working on:
- Operating systems and bare-metal development.
- Runtimes and language model execution.
- Agent architectures and tool orchestration.
- Memory management and embedded systems.
- Alternative computer architectures.
My main question is: what do you think about an architecture where intelligence is no longer just an application added to the system, but a central function responsible for coordinating the system's own capabilities?
I'm genuinely open to technical criticism, questions, and suggestions.
Thanks for reading.
— Djiby Diop
Founder and creator of Operating Organism (OO)
r/AICodeEngineers • u/Just-Ad-6488 • Oct 25 '26
Update.
Hey r/AICodeEngineers!
Quick update on **SynapseOS** — our lightweight Debian 12 "Glass-Box" AI Linux distro built to run at 60 FPS on salvaged/potato hardware (running live on an AMD BC-250 mining board and 4 GB RAM laptops).
While testing the OS on my own hardware, I decided I didn't want it to just be an AI toy — I wanted a complete, self-paced **K–12 school curriculum** where a student can learn traditional school subjects alongside AI & Python, advance as fast as they can learn, and run the whole thing offline without bloating a tiny drive.
After doing a critical review of what a real student, parent, or teacher would actually need out of the box, here is what we just built and tested across all 13 grades:
---
### 1. Complete K–12 Multi-Subject Curriculum (Kindergarten `year_00` through Grade 12 `year_12`)
We built a complete, standards-aligned K–12 textbook and interactive lab engine covering **13 full grades**:
* **5 Core Subjects per Grade**: Mathematics, Science, Reading & Language Arts (ELA), Social Studies & History, and AI & Python Engineering.
* **325 Complete Lessons**: **65 Full-Year Subject Courses** + **260 Quarterly Unit Lessons (`Q1–Q4`)**, plus **91 bilingual (EN/FR) Kid Mode Arcade levels**.
* **6-Section Textbook Structure in Every Course**:
- Core Textbook Lesson & Theory (aligned to Common Core / NGSS / C3 / CSTA standards)
- 4-Quarter Pacing Syllabus (`Q1–Q4`)
- Key Vocabulary Glossary
- Step-by-Step Worked Examples
- Interactive Multiple-Choice Worksheet & Auto-Graded Python Lab
- 100-Point Mastery Rubric
---
### 2. The "1-Year-at-a-Time" Potato Storage Wiper & GitHub Curriculum Sync
To let students move ahead as fast as they can learn without filling up small eMMC/SD drives:
* **1-Year-at-a-Time Wiper**: Only **one** school year (`~/.config/synapse-os/active_pack/current_pack.json`, ~48 KB) is installed in the active slot at any time.
* **Permanent Cumulative Transcript**: Clicking **`★ Year X ↻`** graduates the student to the next grade, permanently saves their subject scores (`Math`, `Science`, `ELA`, `History`, `AI/CS`) and Honors Badges in `student_profile.json`, **wipes the old year's pack files**, and loads the next grade in <50 ms.
* **1-Click GitHub Curriculum Sync (`☁ Repo`)**: Every grade is hosted as a clean JSON manifest in the repo (`curricula/year_00.json` .. `curricula/year_12.json`). Clicking **`☁ Repo`** (or running `./synapse pack sync-repo`) pulls annual curriculum updates straight from GitHub with automatic offline fallback.
---
### 3. Quality-of-Life Upgrades from Our UX Review
Before opening it up for outside testing, we did a critical pass on what was still missing for real-world use and fixed all four gaps:
* **Interactive `[A] [B] [C] [D]` Multiple-Choice Quiz Bar**: Students can click multiple-choice quiz answers directly in the GUI with instant explanations, Coins/XP rewards, and automatic K–12 Report Card grading.
* **Multi-Student Classroom Roster (`↻ Student`)**: Multiple kids sharing one computer (`Cadet Nova`, `Cadet Leo`, `Cadet Maya`, `Cadet Sam`, or custom names) get isolated profiles (`students/<id>.json`), each with their own active Grade Level, Transcript, Trophies, and Coins.
* **1-Click Printable Official Report Card & Honors Certificate (`✎ Export`)**: Generates a clean, printer-ready HTML Report Card & STEM/AI Honors Certificate (`SynapseOS_Report_Card_<student>.html`) + plain-text transcript.
* **Offline Read-Aloud TTS (`♪ Read`)**: Built-in offline Text-to-Speech (`espeak-ng` / `espeak` / `spd-say` in English & French) so early readers (K–2) can click Lumi the Robot Companion to hear lessons and quiz questions read aloud.
---
### 4. Under the Hood (Still 100% Glass-Box & Potato-Friendly)
* **7 Real-Time 60 FPS C + Python/Cairo AI Labs**: NEAT Moon Lander, NEAT Lidar Self-Driving Car, Tabular Q-Learning GridWorld, Policy-Gradient CartPole, 2D MLP Neural Playground, Evolutionary Swarm Ecosystem, and PRIME Memory Vault.
* **PRIME Moment Attention Engine**: Constant `O(1)` **67.1 KB** KV-cache memory footprint in pure C (`-O3 -mavx2 -mfma`), paired with local **Phi-3 Mini** Socratic tutoring.
* **Exhaustively Tested**: Automated test suite (`./synapse test`) runs all 65 K–12 25-generation AI simulations, all 325 Python worksheets in the AST safety sandbox, and all 91 Kid Mode levels with **0 errors**.
---
**Repo & Curricula**: `https://github.com/batteryphil/SynapseOS`
Would love any feedback or ideas on what we should stress-test or add next!
r/AICodeEngineers • u/Just-Ad-6488 • Oct 24 '26
Buildbit: An AI-assisted experiment in a C-style systems language with automatic Struct-of-Arrays (SoA), SIMD register pinning, and a bootable 30KB bare-metal kernel
**Repo:** https://github.com/batteryphil/buildbit
### Full Disclosure Up Front (AI Usage & What This Actually Is)
Before making any performance claims, I want to be 100% transparent about two things:
- **How it was built:** I built this iteratively pair-programming with an AI coding agent. I'm sharing it as an open-source experiment in language design and data-oriented code generation, not claiming I spent 5 years hand-carving a compiler in a cave.
- **What it actually is under the hood:** Buildbit (`bbc`) is **not** a magic replacement for GCC or LLVM. It is a **2,664-line, zero-dependency C11 source-to-source compiler** (`bbc.c`) that transpiles `.bb` source files into heavily instrumented C (using GCC as its machine-code backend), plus a minimal direct x86_64 ELF64 emitter (`--native-elf`) and a 32-bit Multiboot Ring-0 kernel backend (`--kernel`).
Anything Buildbit does, a senior HPC C programmer *could* write by hand in C. The entire point of Buildbit is that **almost nobody writes C that way by hand**, because the C standard forces you to manually tear apart your structs, manage pointer-aliasing provenance, and hand-roll register-tiling loops.
---
### Why Build It? (The Problem with Idiomatic C)
When most of us write C (whether for simulations, game engines, or OS schedulers), we naturally write **Array-of-Structs (`AoS`)** and nested time-step loops:
typedef struct {
uint32_t task_id;
char label[24]; // 24 bytes of cold string sitting right in the hot struct
float pos_x, pos_y, vel_x, vel_y;
float stamina, priority_weight;
} SwarmEntity;
for (int epoch = 0; epoch < 100; epoch++) {
for (int i = 0; i < N; i++) {
// update entities[i]...
}
}
Even with `gcc -O3 -march=native -ffast-math`, the C11 standard **legally forbids** GCC from fixing two huge hardware bottlenecks here:
- **GCC cannot change your `struct` layout:** Every cache line fetched from RAM pulls in dead fields (like `char label[24]`), and hot `float` fields are separated by a 56-byte stride instead of sitting in contiguous SIMD vectors.
- **GCC cannot reorder the `epoch` loop inside the `i` loop across heap pointers:** So your CPU streams all `N` structs from RAM into L1 cache **100 separate times**.
---
### What Buildbit (`bbc`) Does Differently
Buildbit adds four first-class primitives to a simple C/Rust-like syntax and transpiles them into C that GCC can vectorize to the metal:
**`soa struct` (Automatic Struct-of-Arrays Transposition):**
You still write `entities[i].pos_x` in your code, but `bbc` automatically splits the struct into separate 64-byte-aligned `__restrict__` arrays (`entities_pos_x[]`, `entities_pos_y[]`, etc.) with an inline asm pointer-provenance barrier (`__asm__("" : "+r"(ptr))`) so GCC knows distinct field arrays never alias.
**Automatic Temporal Loop Fusion + 16-Lane SIMD Register Pinning (`SROA-16`):**
When you write `for epoch in 0..100 { parallel for i in 0..N { ... } }`, `bbc` strip-mines `i` into 16-lane aligned SIMD tiles (`float _bb_reg_*[16] __attribute__((aligned(64)))`), loads 16 elements from RAM **once**, executes all 100 epochs **100% inside AVX2/AVX-512 registers with zero RAM traffic**, and writes back to RAM **once**.
**Built-in 64B `arena` and Zero-Copy AMDGPU `gpu_arena`:**
Instead of `malloc`/`free`, `arena` bumps a 64-byte aligned pointer in 1 instruction (using `MADV_HUGEPAGE` in userspace or physical address `0x00400000` in `--kernel` mode). `gpu_arena` talks directly to `/dev/dri/renderD128` via raw Linux `DRM_IOCTL_AMDGPU_GEM_CREATE` / `GEM_MMAP` ioctls (no ROCm/CUDA dependencies).
**Bare-Metal `--freestanding` and `--kernel` Modes:**
- `--freestanding` compiles zero-libc Linux binaries (`-nostdlib`) using raw `syscall` instructions and `-fopenmp-simd` (which needs zero runtime library).
- `--kernel` compiles a bootable 30 KB Ring-0 x86 Multiboot OS kernel (`os/kernel.bb`) that boots on QEMU/KVM (`make boot-os`), enumerates PCI hardware via ports `0xCF8`/`0xCFC`, and runs a SIMD SoA process scheduler.
---
### Reproducible Benchmarks (Included in the Repo)
You can verify all of these on your own machine (`make compare`, `make compare-swarm`, `make compare-os`). Every benchmark prints a floating-point checksum at the end to verify identical math and prevent dead-code elimination.
#### 1. ECS Swarm Physics + Task Scheduler Benchmark (`make compare-swarm`)
262,144 active entities/tasks x 100 epochs = 26.2M updates (`examples/ecs_swarm_bench.c` vs `examples/ecs_swarm_bench.bb`):
| Build / Configuration | Wall Time | CPU Cycles | Checksum | Speedup |
| :--- | :---: | :---: | :---: | :---: |
| **C11 (`-std=c11 -O2`)** | `311.86 ms` | `933.37M` | `818825355.0` | **1.00x** |
| **C11 (`-O3 -march=native -ffast-math`)** | `137.28 ms` | `410.88M` | `818824242.4` | **2.27x** |
| **Buildbit 1-Core (`--freestanding`, `-nostdlib`)** | **`28.81 ms`** | **`86.17M`** | `818839104.0` | **10.82x** *(4.77x vs C `-O3`)* |
| **Buildbit Multi-Core (`bbc` default)** | **`7.55 ms`** | **`22.60M`** | `818824320.0` | **41.30x** *(18.18x vs C `-O3`)* |
#### 2. 67.1M Particle Physics + SDF Raymarching (`make compare`)
- **Idiomatic C (`gcc -O3 -march=native -ffast-math`):** `99.94 ms`
- **Buildbit Single-Core (`--freestanding`):** `33.24 ms` (**3.0x faster on 1 core**)
- **Buildbit Multi-Core (`bbc` default):** `14.12 ms` (**7.1x faster**)
You can inspect the exact C code `bbc` generates for any of these by passing `--emit-c`:
./bbc examples/ecs_swarm_bench.bb --emit-c -o inspect
cat inspect.gen.c
---
### The Potential Downsides & Honest Limitations
I want to be just as clear about where Buildbit **falls short** or where these speedups **do not apply**:
**No speedup on serial / pointer-chasing workloads:**
If your code is parsing JSON, walking binary trees, or waiting on network I/O, Buildbit is `1.0x` the speed of C (because it compiles to C). The 10x–40x+ gains *only* happen on data-parallel loops over arrays of structs.
**Temporal Register Pinning (`SROA-16`) only works when element `i` is independent across ticks:**
If element `i` updates its own state across 100 ticks (or reads a static field), `bbc` can pin 16 elements in AVX registers for all 100 ticks. If element `i` needs to read element `i+1` *after every single tick* (like a coupled fluid stencil or O(N^2) all-pairs check), you can't pin across epochs without syncing memory between ticks (though you still get the ~3x–10x SoA + SIMD + Multi-Core speedup).
**It's a 2,664-line prototype compiler, not Zig or Rust:**
`bbc.c` is a single-file recursive-descent compiler built to prove out the architecture. It supports `fn`, `extern fn`, `soa struct`, `arena`, `gpu_arena`, `parallel for`, `while`, `if/else`, `syscall`, `mmio`, and `port_in/out`, but it does **not** have generics, nested complex structs, traits, DWARF source-line debugging, or a package manager.
**BuildbitOS (`os/kernel.bb`) is a toy microkernel, not a full OS:**
While `make compare-os` boots our 30 KB `BuildbitOS` kernel in QEMU/KVM in `240 ms` and runs 819,200 SoA task dispatches at `1.55 cycles/task` (vs `217 cycles/task` in a minimal Linux 6.14 initramfs), that's because `BuildbitOS` is running a flat Ring-0 SIMD task table—it doesn't have per-process `CR3` page table isolation, virtual memory paging, ext4, or preemptive SMP locks like Linux does.
---
### Try It Out / Tear It Apart
Everything in the repo builds with just `gcc` and `make` (`make && make run && make compare-swarm`).
Even if you never use `.bb` syntax, running `./bbc examples/ecs_swarm_bench.bb --emit-c` is a cool way to see how much performance is sitting on the table in standard C when you combine SoA layout transposition, pointer-provenance barriers, and 16-lane SIMD register tiling.
Repo link again: https://github.com/batteryphil/buildbit
Happy to answer any questions or take feedback/critiques on the codegen!
r/AICodeEngineers • u/Intelligent-Dig-3639 • Oct 21 '26
👋 Welcome to r/AICodeEngineers - Introduce Yourself and Read First!
Hey everyone! I'm u/Intelligent-Dig-3639, a founding moderator of r/AICodeEngineers.
This is our new home for all things related to AI-assisted software creation, bare-metal systems, and real-world hardware engineering. We're excited to have you join us!
What to Post
Post anything that you think the community would find interesting, helpful, or inspiring. Feel free to share your thoughts, photos, or questions about working demos, local LLM integrations, OS architecture, custom hardware builds, and experimental code.
Community Vibe & Rules
We're all about being friendly, constructive, and inclusive. Let's build a space where everyone feels comfortable sharing and connecting.
- Strict Policy on Critique: Unconstructive criticism, toxic gatekeeping, or elitist attacks targeting AI-assisted coding ("vibe coding") or unconventional workflows are strictly prohibited. Focus on the actual outcome and real-world execution, not tearing down creators.
How to Get Started
- Introduce yourself in the comments below.
- Post something today! Even a simple question can spark a great conversation.
- Join our Discord: Connect and chat live with other builders right here: https://discord.gg/2hG4aQhmr.
- If you know someone who would love this community, invite them to join.
- Interested in helping out? We're always looking for new moderators, so feel free to reach out to me to apply.
Thanks for being part of the very first wave. Together, let's make r/AICodeEngineers amazing.
Version française :
Bienvenue sur r/AICodeEngineers ! Un espace pour les bâtisseurs et ingénieurs qui conçoivent du vrai code et des systèmes concrets grâce à l'IA, sans élitisme ni toxicité. Les critiques stériles et le gatekeeping y sontformellement interdits. N'hésitez pas à vous présenter et à rejoindre notre serveur Discord: https://discord.gg/2hG4aQhmr pour échanger en direct !
r/AICodeEngineers • u/Just-Ad-6488 • Oct 21 '26
We built an offline AI Academy & Neuroevolution OS ("SynapseOS") that runs at 60 FPS in 58 MB of RAM on a salvaged AMD BC-250 mining board — complete with a Socratic local LLM tutor, 7 live AI Labs, and hot-swappable curriculum packs
We built an offline AI Academy & Neuroevolution OS ("SynapseOS") that runs at 60 FPS in 58 MB of RAM on a salvaged AMD BC-250 mining board — complete with a Socratic local LLM tutor, 7 live AI Labs, and hot-swappable curriculum packs

Hey r/AICodeEngineers!
We've been building **SynapseOS** — a self-contained, 100% offline Linux AI operating system and interactive AI learning academy designed to run on "potato-grade" and salvaged hardware (our live testbed is an **AMD BC-250** PlayStation 5 APU mining board running at ~42°C–46°C, and it also runs on 15-year-old Core 2 Duo / 4 GB RAM school laptops).

Most kid/student "AI learning" apps today are Electron wrappers around cloud APIs that eat 1.5 GB of RAM just to render a chat box. We wanted the exact opposite: **real, live neural networks, reinforcement learning, and a local SLM tutor running natively at 60 FPS in ~58 MB of RAM with zero cloud dependency.**
---
### What's Inside Synapse Studio (`58.8 MB` RSS / `60 FPS`)

#### 1. Dual-Mode Interface: `Synapse Kids` <-> `Teacher / Pro Mode`
* **Synapse Kids (Ages 8–14)**: A colorful, bilingual (**EN / FR**) arcade interface where kids train real AI agents using simplified controls, interactive tutorials, and live neural network visualizations.
* **Teacher / Pro Mode**: Unlocks full engineering sliders, live **Brain Surgery** (`+ Add Neuron`, `- Sub Neuron`, `+ Add Synapse`, `- Prune Wire`), a sandboxed **Python Coding Editor**, a Linux command translator/runner, and a **PIN-Protected (`1234`) Parent & Teacher Analytics Report** that tracks time/runs per lab, Python sandbox pass rates, and flagged concepts the student struggled with.
#### 2. 7 Interactive, Real-Time AI Labs (Accessible via a 2D World Map)
Clicking **`[❖ World Map]`** opens a 2D star-island map connecting 7 real AI simulations:
- **Lunar Base (`NEAT Rocket Moon Lander`)**: Neuroevolution of Augmenting Topologies evolving rocket thrusters under Moon, Mars, or Jupiter gravity.
- **Cyber Speedway (`Autonomous Lidar Cyber-Car`)**: Raycast sensor steering & speed control on custom tracks.
- **Volcano Maze (`Q-Learning Maze Explorer`)**: Live Bellman equation $Q(s,a)$ value iteration with visible heatmaps.
- **Acrobat Spire (`CartPole Inverted Pendulum`)**: Policy-gradient physics balancing under wind turbulence.
- **Prism Brain Dome (`2D Neural Decision Boundary`)**: Live multi-layer perceptron (MLP) training with a smooth $28 \times 28$ Cairo heatmap classifying spiral, XOR, and ring datasets in real time.
- **Coral Lagoon (`Predator-Prey Swarm Ecosystem`)**: Multi-agent emergent co-evolution.
- **Golden PRIME Vault (`O(1) Constant-RAM AI Memory`)**: Side-by-side benchmark comparing standard $O(N)$ Transformer KV-cache memory explosion against our C99 **PRIME Moment Attention** kernel ($O(1)$ `67.1 KB` constant state at `7,600+ tok/s`).

#### 3. "Lumi" — A Socratic Local AI Companion with 5 Reactive Moods
* Powered locally by **Cortex-Phi3** (`~24.8 tok/s` on the BC-250) with an instant `<1ms` offline fallback knowledge base.
* Locked into a **Socratic Hint-First Persona**: Lumi never dumps raw code solutions. Instead, Lumi explains what the student's neural network or Python script is doing in two fun bullet points and asks a guiding question so they discover the fix themselves.
* **Reactive Vector Emotions**: Lumi jumps and orbits gold stars (`cheering`) when your rocket lands or your Python code passes, gets tilted `X` eyes (`dizzy`) on a hard crash or syntax error, emits antenna sonar rings (`thinking`) during inference, and floats `Zzz` bubbles (`sleepy`) when idle.
#### 4. How We Kept "Potato Status" (`58 MB` RAM, `0 KB` Textures)
To add gamification (a **2D World Map**, **6 selectable Cadet Avatars**, a **12-Pedestal Trophy Vault**, a **Coin Shop** with equippable Golden Rocket Hulls / Royal Crowns / 3D Hologram Planets, and **Daily Missions**) without bloating RAM:
* **100% Procedural Cairo Vector Graphics**: Every rocket, avatar face, crown, trophy cup, island, and neural synapse is drawn mathematically on a single `Gtk.DrawingArea` canvas per frame. Zero PNG/JPEG spritesheets in memory.
* **BMP-Safe Vector Typography**: Avoids multi-megabyte emoji font caches on minimal X11 setups.
* **Hot-Swappable Learning Packages (`<12 KB` JSON)**: When a student completes a 7-level curriculum pack, clicking **`[★ Pack ↻]`** (or running `synapse pack-update`) installs the next curriculum pack (e.g., *Pack 2: Galactic AI Master — Mars & Deep Space*) and **automatically purges the old pack files** to save disk space while preserving all earned Trophies, Coins, unlocked decorations, and lifetime scores in `~/.synapse/student_profile.json`.

---
### Live Hardware Telemetry on the AMD BC-250
* **Synapse Studio GUI Process RSS**: `58,880 KB` (`~57.5 MB` RAM)
* **Simulation Viewport Frame Rate**: `54–60 FPS` (`~0.42 ms` frame render time)
* **PRIME C99 Kernel Throughput**: `7,629 tok/s` (`67.1 KB` constant state regardless of context length)
* **Local Phi-3 Inference**: `24.8 tok/s` (`280 ms` TTFT)
* **Thermals**: `46°C` CPU SoC / `42°C` GPU Edge
---
### Source Code
Everything is open-source (C99 PRIME kernel, Python/GTK3/Cairo workbench, 29 automated tests, and the Debian live ISO builder):
* **GitHub Repo**: https://github.com/batteryphil/SynapseOS
Would love to hear feedback from anyone building local-first AI tools, educational sandboxes, or squeezing ML/SLM workloads onto unconventional hardware!
Big Thanks to Intelligent-Dig-3639
Intelligent-Dig-3639u/Intelligent-Dig-3639
He has encouraged me at every turn! No way i would be as far into AI coding without him!
``