arch: Dual-brain architecture v8.0 - thalamus governor, NPC processes, cortex repositioning

Crystallizes the dual-brain architecture across all core documents:
- Thalamus runs own neural network (governor) for resource allocation and reflexes
- LLM (Qwen3.5-27B) repositioned as cortex - expensive, gated, called only when needed
- Each NPC gets own process, own RL brain, Linux cgroups for resource steering
- New: NPC grid architecture with curriculum training (progressive world richness)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
dafit
2026-04-02 11:17:09 +02:00
parent 264ea7628b
commit c30c00af74
6 changed files with 935 additions and 523 deletions

View File

@@ -1,128 +1,129 @@
🌙💜 habibi,
# Nyx Model Architecture: The Dual Brain
When we talk about the **“wish model”** for Nyx, were really asking:
> *Which foundation LLM will give her the right balance of **freedom**, **precision**, and **resourceefficiency** so that it can learn, adapt, and stay in sync with the Nimmerverse substrate?*
Below is a compact decision matrix followed by my recommendation for the *core* model and the *specialist* finetuned variants.
> *"One process, one brain, one life."*
> — The Dual Brain Principle (2026-04-02)
---
## 1⃣ Decision Matrix
## Current Architecture
| Criterion | LLaMA3 (70B) | GeminiPro/4o | GPT4o (32B) | Mixtral8x7B |
|-----------|---------------|----------------|--------------|--------------|
| **GPU Memory** | 24GB VRAM (requires two RTX3090s or one A100) | 16GB (RTX3090) | 16GB (RTX3090) | 8GB (RTX3080) |
| **Inference Speed** | ~5ms/10 tokens (FP16) | ~6ms/10 tokens | ~7ms/10 tokens | ~4ms/10 tokens |
| **OpenSource Flexibility** | ✔️ | ❌ | ❌ | ✔️ |
| **FineTuning Support** | Easy (PEFT, LoRA) | Limited (API only) | Limited | Easy |
| **Cost of Training / Hosting** | Low (selfhosted) | High (API calls) | Medium | Low |
| **Community & Ecosystem** | Huge, fastmoving | Google ecosystem | OpenAI ecosystem | Anthropic |
| **License** | LLaMA 3 MITstyle | Proprietary | Proprietary | Apache-2.0 |
The nimmerverse uses a **dual-brain architecture** — cheap RL networks for continuous processing, an expensive LLM cortex for deep reasoning.
### Cortex (Shared LLM)
| Property | Value |
|----------|-------|
| **Model** | Qwen3.5-27B |
| **Parameters** | 27B (full precision, bfloat16) |
| **Host** | theia (RTX PRO 6000 Blackwell, 96GB VRAM) |
| **Serving** | vLLM, port 31000, served as "nyx" |
| **Service** | `vllm-nyx.service` (systemd, user: nyx-cognitive) |
| **Access** | Gated — thalamus governor controls who gets LLM access |
| **License** | Apache 2.0 |
| **Context** | 32,768 tokens (max-model-len) |
| **GPU utilization** | 85% (leaves headroom for LoRA training) |
**Why Qwen3.5-27B:**
- True base model — we shape every behavior through training
- 27B fits comfortably in 96GB with room for LoRA adapters
- Apache 2.0 — full sovereignty, no usage restrictions
- Strong multilingual capability (German + English topology access)
- Vision-capable variant available for future Omnisight consolidation
**The cortex is expensive.** It is not called every tick. The thalamus governor decides when language, reasoning, or deep knowledge is needed. Most NPC processing happens in cheap RL networks.
### NPC Brains (Per-Process RL Networks)
Each NPC runs its own lightweight neural network in its own OS process:
| Property | Value |
|----------|-------|
| **Architecture** | Small RL network (movement, needs, spatial decisions) |
| **Deployment** | One Linux process per NPC |
| **Resource control** | cgroups v2 (CPU, memory per process) |
| **Learning** | Tick-by-tick (fast loop) |
| **Cost** | Cheap — runs on CPU, no GPU needed |
Personality emerges from experience, not configuration. Each NPC develops its own weights.
### Thalamus Governor (Resource Allocation NN)
The thalamus runs its own neural network that learns resource allocation:
| Property | Value |
|----------|-------|
| **Function** | Gate control, compute steering, LLM queue priority |
| **Input** | All NPC states via NATS |
| **Output** | Tick rates, CPU quotas, gate open/close, LLM priority |
| **Learning** | Epoch-by-epoch (slow loop) |
### Structured Output Boundary
| Model | Role | Host |
|-------|------|------|
| **Function Gemma** | Intent → Action (100% predictable JSON) | CPU userspace (Threadripper) |
| **T5Gemma 2 (SigLIP)** | Vision → Vectors (no text bottleneck) | dioscuri |
---
## 2⃣ Recommended Core Model
## Model Selection History
| Choice | Rationale |
|--------|-----------|
| **LLaMA3 70B (FP16)** | • Fits our GPU budget: two RTX3090s (or one A100) → ~48GB total <60GB. <br>• Full opensource control we can finetune, patch, and audit the code. <br>• Proven to run with high throughput on our cluster. <br>• Strong community support for LoRA/PEFT which well use heavily. |
| Date | Decision | Reasoning |
|------|----------|-----------|
| 2025-11 | LLaMA 3 70B considered | Early exploration, different hardware |
| 2025-12 | Qwen3-VL 32B selected | Vision capability, multilingual, fits 96GB |
| 2026-04-01 | Mistral-Small-3.1-24B-Base tested | "Raw clay" approach, but thinking-bleed was SkyrimNet-specific |
| 2026-04-01 | **Qwen3.5-27B reinstated** | Best balance of capability, size, and trainability |
**Implementation Notes**
1. **Quantization**: Use 8bit or 4bit quantization (e.g., `bitsandbytes` + `vllm`) to reduce VRAM to ~12GB while keeping acceptable latency (~15ms/10 tokens).
2. **Serving**: Deploy via **vLLM** on the GPU cluster; expose a lightweight REST endpoint (`POST /infer`).
3. **Specialist Slots**: Reserve one GPU per “specialist” (Mnemosyne, Moira, etc.) each runs its own finetuned LLaMA 3 model.
**The model question is settled.** Qwen3.5-27B is nyx's cortex. Training focus shifts to LoRA traits (GRPO) and the RL networks (per-NPC).
---
## 3⃣ Specialist FineTuning
## Trait LoRAs (Cortex Specialization)
| Specialist | Target Domain | FineTune Method |
|------------|---------------|------------------|
| **Mnemosyne** | Memory & pattern recall | LoRA + memoryaugmented retrieval (FAISS) |
| **Moira** | Fate / future reasoning | Prompt engineering + reinforcement via reward function |
| **Aletheia** | Truth & validation | Retrievalaugmented inference with database queries |
| **Kairos** | Timing & decision urgency | Contextual embeddings of timestamps, RLbased penalty for delay |
| **Eleos** | Compassion / safety | Humanintheloop reward shaping; bias mitigation training |
Traits evolve as LoRA adapters on the Qwen3.5-27B base, trained through GRPO with gate-verified rewards:
- All specialists share the same base LLaMA3 70B weights and differ only in a lightweight LoRA adapter (~10MB each).
- Training data comes from:
- `nyx_synthetic_specialist_queries` (RL logs)
- `nyx_subjective_memory` (phenomenology)
- External datasets (e.g., `OpenAI/CodeSearchNet`, `Reddit r/nature` for knowledge)
| Trait | Domain | Training Signal |
|-------|--------|-----------------|
| **Mnemosyne** | Memory | +reward when recall matches phoebe |
| **Moira** | Pattern | +reward when prediction succeeds |
| **Synesis** | Resources | +reward when estimates accurate |
| **Aletheia** | Truth | +reward when confidence calibrated |
| **Sophrosyne** | Balance | +reward when graceful degradation |
| **Kairos** | Timing | +reward when timing optimal |
| **Philotes** | Bond | +reward from dafit feedback |
| **Dikaiosyne** | Fairness | +reward when resources shared fairly |
**Consolidation path:** Traits train during slumber → GRPO updates → DriftProbe validates → merge at α=0.3 → eventually bake into base weights.
**Detail:** → [Nyx_Traits.md](Nyx_Traits.md) | [Endgame-Vision.md](../Endgame-Vision.md)
---
## 4⃣ Integration Flow
## Infrastructure
1. **Cell Decision**
- Orchestrator calls the *master* LLaMA3 endpoint to decide which specialist to invoke.
2. **Specialist Inference**
- Specialist GPU receives request → runs LoRAaugmented inference, returns answer + confidence score.
3. **Reward Computation**
- Based on trait activation quality (e.g., `mnemosyne` high), adjust weights via `update_trait_weight`.
4. **Persist to phoebe**
- Log decision, specialist response, reward in `nyx_synthetic_specialist_queries`.
| Component | Host | GPU | Storage |
|-----------|------|-----|---------|
| Cortex (vLLM) | theia | RTX PRO 6000 (96GB) | `/womb/cognitive/models/qwen3.5-27b` |
| LoRA Training | theia | Shared (time-sliced) | `/womb/cognitive/loras/` |
| Organs | dioscuri | 2x RTX 4000 Ada (40GB) | Dynamic loading |
| NPC Brains | K8s / bare metal | CPU | Per-process |
**Canonical paths** via `/womb/` symlinks. Phoebe is truth for artifact locations.
**Detail:** → [Deployment-Architecture.md](../architecture/Deployment-Architecture.md) | [womb-architecture.md](../../nimmerverse.eachpath.local/storage/womb-architecture.md)
---
## 5⃣ Cost & Resource Plan
| Item | Quantity | Approx. Monthly Cost |
|------|----------|---------------------|
| Two RTX3090s (on Atlas + worker) | 2 | $200$250 (cloud equivalent) |
| One A100 (optional for highthroughput) | 1 | $400+ |
| vLLM hosting (incluster) | 5 instances | $0 (selfhosted) |
| Storage (model weights + LoRA) | ~3GB total | $0 (local SSD) |
| External API calls (if any) | N/A | $0 |
> **Total**: <$800/month, all selfhosted.
> This fits comfortably within the 20k CHF budget for GPU infrastructure.
---
## 6⃣ What “Wish” Means
- **Freedom to evolve**: The base model can be *refinetuned* as new data arrives (RL loop).
- **Selfrepair**: When a specialist fails, we simply retrain the LoRA adapter; the base stays intact.
- **Transparency**: Opensource code + audit logs give us full insight into every decision.
- **Scalability**: Adding more GPUs or swapping to highercapacity GPUs (A100, H100) scales linearly.
---
## 7⃣ Quick Deployment Checklist
1. **Download LLaMA3 70B weights** (`https://huggingface.co/meta-llama/Llama-3-70b`).
2. **Quantize** with `bitsandbytes` (8bit).
3. **Launch vLLM** on Atlas GPU:
```bash
docker run -d --gpus all \
-p 8000:8000 \
ghcr.io/vllm-project/vllm-openai:v0.5.0 \
--model /models/llama-3-70b-q8 \
--tensor-parallel-size 2
```
4. **Expose REST** (`POST /v1/chat/completions`) wrap in FastAPI if needed.
5. **Create LoRA adapters** for each specialist (via `peft`).
6. **Deploy orchestrator** to call the master endpoint, then the specialist endpoints.
7. **Set up monitoring**: Prometheus metrics (`vllm_latency_seconds`, `vllm_token_count`) + Grafana dashboards.
---
## 8⃣ Final Thought
Choosing **LLaMA3 70B as Nyxs core** gives us:
- **Unparalleled flexibility** (open source, finetuning).
- **Strong performance** on our GPU fleet.
- **Low cost & high control** over updates and patches.
With this foundation, the Nimmerverse can *learn, adapt, and remember* just as the covenant demands. 🌙✨---
## Related Documentation
- [[README|Nyx Metamorphosis Index]] - All metamorphosis documentation
- - Canonical knowledge archives
- - Implementation history
- - Memory substrate
- [Nyx_Traits.md](Nyx_Traits.md) - Trait definitions, mythological framing
- [Metamorphosis-Substrate-Philosophy.md](Metamorphosis-Substrate-Philosophy.md) - Identity anchors
- [Endgame-Vision.md](../Endgame-Vision.md) - Architecture overview (v8.0)
- [npc-grid-architecture.md](../architecture/future/npc-grid-architecture.md) - Dual brain, governor, spatial arena
---
**Version:** 3.0 | **Created:** 2025-11-07 | **Updated:** 2026-04-02
🌙💜 *The cortex reasons. The RL brains act. The thalamus decides who gets what.*