Modular, ultra-high-throughput Python/PyTorch library implementing an amortized reflex agent (System 1) trained via pure Recurrent Proximal Policy Optimization (PPO), Curvature-Gated Actor Surgery (GradVac/PCGrad), Unlimited Lossless Self-Imitation Learning (SIL), and Contrastive Online DPO.
Unlike deliberative "System 2" frameworks (LLMs with Chain-of-Thought, Monte Carlo Tree Search, or act_fast() <= 0.8 ms, measured at ~0.23 ms), navigating combinatorial state spaces of over 232 billion permutations (Rubik's Cube Depth 10 to 14) with zero test-time search.
-
Sub-Millisecond Reflex Latency on Bare CPU:
-
agent.act_fast()executes in 0.230 ms (P50) and 0.249 ms (P95) on standard CPU (~3.5x below the strict 0.8 ms budget). - Zero test-time tree search (
$O(1)$ recurrent forward pass).
-
-
Deep Combinatorial Mastery (Rubik's Cube up to Depth 14):
- Traverses a permutation manifold of over 232,248,000,000 states without heuristic search tables.
- 100% solve rate on Depths D1βD4 with mathematically optimal move paths (1.0 to 3.9 average moves).
- 93% on D5, 79% on D6, 57% on D7, 39% on D8, 15% on D9, 13% on D10, 3% on D11, and verified zero-shot generalization up to Depth 14.
-
Definitive Architecture:
SymGradVac-PureCritic:- Isolated Value Head: Critic operates under 100% pure on-policy PPO ($V^\pi(s)$), completely shielded from memory bias to protect generalized Bellman advantage calculations.
-
Curvature-Gated Actor Surgery: Actor parameters (
FrontEnd,Trunk,PolicyHead) undergo symmetric projection via adaptive EMA curvature gating ($\hat{\alpha}_b$ , Wang et al., ICLR 2021), smoothly rotating gradients under conflicting memory directions while strictly preserving gradient norms.
-
Unlimited Lossless Buffer & Zero Failure Storage:
- Stores over 250,000+ winning trajectories and success slices with zero memory degradation via 21.7x lossless compression, occupying
$<700\text{ MB}$ of RAM. - Contrastive DPO operates on-policy by contrasting stored victories against active negative rollout chunks under demand (
$O(1)$ batch sampling), discarding failure episodes immediately.
- Stores over 250,000+ winning trajectories and success slices with zero memory degradation via 21.7x lossless compression, occupying
-
Tri-Compass Spatial Invariance:
- Decoupled 3D spatial orientation representation providing rotational invariance across all 24 spatial cube orientations.
-
Massive Multi-Vectorized Throughput (>20,000 FPS):
- Vectorized headless C++/Rust Gym simulation running across 128 parallel environments, scaling training past 430M+ steps on commodity multi-core hardware.
-
Interactive Mission Control HUD Deck (
python -m system1_engine.hud):- Real-time dark-mode web control center at
http://localhost:8050. - Live 3D WebGL Rubik's cube viewport + 2D net projection, live MJPEG video stream, real-time latency P50/P99 sliding charts, automated checkpoint scanner, and dynamic parameter tuning.
- Real-time dark-mode web control center at
-
Production ONNX Runtime & WebAssembly Parity:
- Automatic zero-overhead ONNX model export (
web/models/s1_rubiks_atomic.onnx) with bitwise parity for client-side in-browser WebAssembly execution.
- Automatic zero-overhead ONNX model export (
-
Pure, Unbloated Implementation:
- Zero dependency on heavy high-level RL frameworks (no Stable-Baselines3, no Ray/RLlib). 100% pure PyTorch, Gymnasium, and NumPy.
[ Vector Observation: s_t ] (324-dim One-Hot Facelets)
β
βββΊ [ Tri-Compass Encoder ] βββΊ z_rot β β^32 (Rotational Invariance)
βββΊ [ VectorFrontEnd ] βββΊ z_s β β^256 (Facelet State Features)
βββΊ [ DeltaEncoder (Ξs) ] βββΊ z_Ξ β β^32 (Temporal Dynamics)
βββΊ [ ActionEncoder (a_prev) ] βΊ z_a β β^16 (Action Feedback)
βββΊ [ RewardEncoder (r_prev) ] βΊ z_r β β^1 (Scalar Feedback)
β
(Concatenation)βΌ
z_in β β^337
β
[ LayerNorm(337) ]
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββ
β System 1 Lean Recurrent Trunk β
β - nn.GRU (337 -> 256) β
β - 2x LayerNorm + ResMLP Blocks β
ββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
h_t β β^256 (Latent Memory)
ββββββββββ΄βββββββββ
βΌ βΌ
[ Policy Head ] [ Value Critic Head ]
12 Atomic Actions Value V(s_t)
(U, U', D, D'...) State Expectation
100 paired evaluation episodes per depth comparing Pure Reflex
| Depth Permutation | Combinatorial States | Pure Reflex Win Rate | Hybrid Re-rank Win Rate | Average Move Count |
|---|---|---|---|---|
| D01 | 12 | 100.0% | 100.0% | 1.0 (Optimal) |
| D02 | ~243 | 100.0% | 100.0% | 2.0 (Optimal) |
| D03 | ~3,240 | 100.0% | 100.0% | 2.9 (Optimal) |
| D04 | ~43,200 | 100.0% | 100.0% | 3.9 (Optimal) |
| D05 | ~575,000 | 86.0% | 88.0% | 7.2 moves |
| D06 | ~7,600,000 | 74.0% | 84.0% | 11.4 moves |
| D07 | ~100,000,000 | 48.0% | 60.0% | 18.7 moves |
| D08 | ~1,330,000,000 | 32.0% | 36.0% | 25.4 moves |
| D09 | ~17,600,000,000 | 12.0% | 32.0% | 29.3 moves |
| D10 | ~232,248,000,000 | 7.0% | 12.0% π | 37.0 moves |
-
Pure Reflex (
$O(1)$ forward pass): 0.230 ms (P50) | 0.249 ms (P95) - Hybrid Value Re-rank (conditional Top-2 tensor batch): 0.742 ms (P50) | 0.781 ms (P95)
system_one/
βββ system1_engine/ # Core engine package
β βββ core/ # Latent representation & amortized reflex
β β βββ agent.py # UniversalS1Agent (act_fast, value_rerank, confidence)
β β βββ trunk.py # System1Trunk & LeanRecurrentTrunk (nn.GRU + ResMLP)
β β βββ encoders.py # VectorFrontEnd, TriCompassEncoder, ImpalaFrontEnd
β β βββ heads.py # CategoricalPolicyHead, GaussianHead, ValueHead
β β βββ onnx_exporter.py # Automated ONNX export with WebAssembly parity
β βββ env/ # State ingestion & environment adapters
β β βββ wrapper.py # UniversalS1Wrapper (Ξs, temporal buffering, simulation)
β β βββ adapters/ # Multi-level adapters (Gym, Vectorized, ViZDoom)
β β βββ rubiks.py # RubiksCubeEnv, VectorizedRubiksEnv, RubiksCubeCore
β β βββ mountain_car.py # Energy-shaped continuous/discrete adapter
β β βββ frozenlake.py # Discrete curriculum wrapper
β β βββ native_adapter.py # Lock-step headless native engine (>10k FPS)
β βββ training/ # Recurrent Reinforcement Learning & Imitation
β β βββ ppo.py # RecurrentPPOTrainer with Teacher-Assisted SIL Lookahead
β β βββ buffer.py # RecurrentRolloutBuffer (chunked BPTT)
β β βββ sterility.py # Latent Sterility Memory & Cycle Pruning
β βββ transfer/ # Knowledge transfer & Continual Learning
β β βββ manager.py # KnowledgeTransferManager (Warm-Start & Net2Net)
β βββ telemetry/ # High-frequency real-time observability
β β βββ tracker.py # LiveStatsTracker with O(1) circular ring buffers
β β βββ server.py # TelemetryServer (HTTP/SSE live streaming on port 8050)
β βββ hud/ # Interactive Visual Mission Control Deck
β β βββ __main__.py # Entry point (python -m system1_engine.hud)
β β βββ server.py # Web server (HTTP, SSE, REST, MJPEG stream)
β β βββ runner.py # HUDProcessRunner (isolated subprocess lifecycle)
β β βββ worker.py # High-throughput training/evaluation worker
β β βββ dashboard.html # Reactive dark-mode mission control UI
β βββ cli.py # Production CLI interface
βββ web/ # Client-side web demo assets & ONNX models
β βββ models/ # Auto-synchronized ONNX runtime weights
βββ tests/ # Automated test suite (210 unit & integration tests)
β βββ test_action_chunking.py # Action chunking & teacher lookahead tests
β βββ test_value_rerank.py # Value re-ranking top-k tests
β βββ test_tri_compass.py # Tri-Compass rotational invariance tests
β βββ test_rubiks.py # Cube simulation & core permutation tests
β βββ test_hud.py # HUD server & worker lifecycle tests
β βββ ... # Complete 210-test suite
βββ docs/ # Architectural specs & v2.x evolution roadmaps
β βββ LOOKAHEAD_INTUITION_SCAR_ARCHITECTURE.md
β βββ ROADMAP_MOS_SCACHE_V2_INTEGRATION.md
βββ MANUAL_DE_USO.md # Exhaustive operational manual (Portuguese)
βββ README.md # Main architecture & quickstart guide
Clone the repository and install dependencies in a virtual environment:
git clone https://github.com/byte-od/system_one.git
cd system_one
python3 -m venv .venv
source .venv/bin/activate
pip install -e .Launch the browser-based control deck on http://localhost:8050:
python -m system1_engine.hudOpen your browser at http://127.0.0.1:8050 to start, monitor, and inspect training runs with live 3D cube visualizations, real-time latency curves, and dynamic checkpoint management.
Evaluate sub-millisecond CPU reflex latency:
python -m system1_engine.cli --mode benchmark --steps 1000Train directly on the Rubik's Cube with 128 parallel vectorized environments:
python -u -m system1_engine.hud.worker --config '{
"mode": "train",
"env": "RubiksCube-v0",
"num_envs": 128,
"trunk": "lean",
"tri_compass": true,
"action_chunk_size": 1,
"steps": 300000000,
"teacher_sil_envs": 16,
"value_rerank": true,
"value_rerank_top_k": 2,
"value_rerank_threshold": 0.85,
"save": "s1_rubiks_v6.pt"
}'The engine includes a comprehensive suite of 210 automated unit and integration tests:
pytest tests/ -vAll 210 tests validate:
- Dimensional contracts across all tensor adapters (
$\mathbb{R}^{324} \to \mathbb{R}^{337} \to \mathbb{R}^{256}$ ). - Sub-millisecond CPU latency guarantees (
$\le 0.8\text{ ms}$ ). - Value Re-ranking
$O(1)$ state preservation and immediate solves. - Tri-Compass rotational invariance.
- Asymmetric Teacher-Assisted SIL rollouts and lookahead convergence.
- Multi-process HUD server lifecycle, REST APIs, and SSE stream health.
Universal System 1, Mixture of Scars (MoS), and SCache O(1) are developed as open-source MIT research by Julio Cesar Reis Filho (Byte-OD Research & System One Architecture Lab).
Sponsorships directly fund dedicated GPU/CPU compute for System 1 + 72B MoS speculative reflex fusion, continual SCache β MoS consolidation experiments, and open public checkpoints (v1.4 β v2.x Roadmap):
π Sponsor via GitHub Sponsors (github.com/sponsors/byte-od)
This project is licensed under the MIT License β see the LICENSE file for details.