Skip to main content

English | Bahasa Indonesia | 简体中文 | 日本語 | 한국어 | Español | Français | Deutsch | Русский | العربية

Dual-Loop Cognitive Controller (v3.0.0)

Unified Cognitive OS: Model-Agnostic Canonical Projection, Sleep-Phase Consolidation & Prefrontal Invariant Firewalls

PyPI version Python Versions PyTorch Hugging Face GitHub License


Overview

Dual-Loop Cognitive Controller (HADL v3.0.0 Unified Cognitive OS) is an open-source, model-agnostic cognitive framework that upgrades ANY autoregressive Transformer into an autonomous dual-process system with 5 Computational Brain Organs:

  1. Universal Model-Agnostic Adapter: Dynamic Runtime Graph Introspection (DynamicGraphIntrospector) discovers layer containers and hooks automatically across Qwen, LLaMA, Mistral, Gemma, GLM-4, and custom architectures. Standardizes latent deliberation onto a Canonical Manifold ($\mathbb{R}^{D_{native}} \to \mathbb{R}^{1024} \to \mathbb{R}^{D_{native}}$) with strict mathematical ReZero Identity Preservation ($\Delta_{init} \equiv 0$).
  2. vLLM & TensorRT High-Throughput Ready: Pure branchless tensor arithmetic with 100% CUDA-Graph safety, zero Python runtime branches in the hot-path, and native support for both 3D $[B, S, D]$ and 2D $[N, D_{native}]$ flat batch tensor formats.
  3. Sleep-Phase Consolidation Engine (Organ 4): Offline memory replay translating waking Hebbian fast weights ($M_{fast}$) into permanent LoRA parameters via truncated SVD low-rank distillation and QR nullspace orthogonalization ($0.000000$ knowledge interference leakage).
  4. Sheaf-Theoretic Invariant Firewall (Organ 5): Sub-0.05ms prefrontal executive inhibition computing cohomological obstructions to clamp explosive gradients, suppress Dirichlet vacuous hallucinations, and prevent instruction corruption.
  5. Bidirectional Multimodal Plasticity: Native two-way translation between text and sensory (photo/audio) latents with 1-shot in-situ Hebbian binding.

Installation

# Core package
pip install dual-loop-controller

# With Hugging Face Transformers & Accelerate
pip install "dual-loop-controller[llm]"

Quickstart

1. Universal Model Attachment (3 Lines of Code)

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from dual_loop import attach

# 1. Load any supported causal Transformer
model_id = "Qwen/Qwen2.5-7B-Instruct"  # or LLaMA-3, Mistral, Gemma, GLM-4
tokenizer = AutoTokenizer.from_pretrained(model_id)
base_model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto")

# 2. Attach Dual-Loop Controller (Zero retraining, 100% frozen base model)
model = attach(base_model, k_steps=2)

# 3. Standard text inference with latent deliberation (zero token bloat)
inputs = tokenizer("Question: In inverted buoyancy physics, denser objects float. Does lead or cork float?\nAnswer:", return_tensors="pt").to(base_model.device)
output = model.generate(**inputs, max_new_tokens=64)
print(tokenizer.decode(output[0], skip_special_tokens=True))

2. Bidirectional Multimodal Translation (Photo & Audio)

import torch
from dual_loop import attach

# Attach controller with multimodal engine enabled
model = attach(base_model, k_steps=2, enable_cross_modal=True)

# A. One-Shot In-situ Binding of a Novel Object / Sound
sensory_embeds = torch.randn(1, 64, 1536).to(base_model.device)      # Photo patches or audio frames
text_label = torch.randn(1, 1, 1536).to(base_model.device)           # Text concept embedding
model.bind_visual_concept(sensory_embeds, text_label)

# B. Sensory -> Text Recognition under 20% Noise
noisy_sensory = sensory_embeds + 0.20 * torch.randn_like(sensory_embeds)
recalled_text, _ = model.recall_text_from_sensory(noisy_sensory)
print("Recognized concept vector norm:", recalled_text.norm().item())

# C. Text -> Sensory Mental Imagery / Acoustic Imagination (1.4 ms Ultra-Fast!)
synth_latent, _ = model.recall_sensory_from_text(text_label)
print("Synthesized mental sensory representation in 1.4 ms!")

3. Command-Line Interface (CLI)

# Check environment and active architecture components
hadl info

# Run multimodal bidirectional benchmark on GPU
hadl benchmark --suite multimodal

# Run lifelong epistemic plasticity benchmark
hadl benchmark --suite plasticity

# Validate mathematical and structural consistency of benchmark logs
hadl validate-benchmark eval_results

# Execute single autonomous background contemplation cycle
hadl daemon-step --slots 6 --d-model 128

# Execute offline sleep-phase consolidation replay and SVD distillation
hadl sleep-cycle --episodes 10 --rank 16

Empirical Benchmark Highlights

  • Bidirectional Multimodal Accuracy: 100.0% across Photo $\leftrightarrow$ Text and Audio $\leftrightarrow$ Text under 20% sensory noise.
  • Text $\to$ Sensory Synthesis Latency: 1.40 ms (>1,000x faster than diffusion models like SDXL / AudioLDM).
  • KV-Cache Sensory Compression: 16 slots (-93.8% token footprint reduction vs Qwen2-VL's 1024 tokens).
  • Cognitive Reasoning Macro (SciQ, ARC-C, OBQA N=75): 76.00% (57/75) (+25.33% net gain over base model 50.67%).
  • Real-Time Web-Dev Latency: 76.73s (+54.3% faster than legacy 167.78s; 91.05s token waste eliminated).
  • Autonomous Anomaly Resolution (AARR): 100.0% (20/20) contradictions resolved autonomously during idle cycles.
  • Epistemic Humility (ECDR): 0.0% overconfident errors on incorrect predictions (vs 63.0% Base).
  • Lifelong Memory Retention (LCII): 100.0% retention across 10 sequential domains without catastrophic forgetting.

For full architecture diagrams, benchmarks, and interactive dashboards, visit the GitHub Repository.


License

Licensed under the MIT License.

Metadata

Release files for dual-loop-controller 3.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dual-loop-controller 3.0.0
File Size Uploaded
dual_loop_controller-3.0.0.tar.gz 1.1 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for dual-loop-controller 3.0.0
File Interpreter ABI Platform
dual_loop_controller-3.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 2.1 MB

Release files / dual_loop_controller-3.0.0.tar.gz

Download URL dual_loop_controller-3.0.0.tar.gz
Size 1.1 MB
Tags Source
SHA-256 checksum
How to use checksums
87e945839218dade8dd31aff568edc20c51b48a1acb95068f3b8c06ef8c5175f
BLAKE2b-256 checksum
How to use checksums
5f9aad9a925066edec76cd91365fad52461805e038a88b46f76d981b980e5f64
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / dual_loop_controller-3.0.0-py3-none-any.whl

Download URL dual_loop_controller-3.0.0-py3-none-any.whl
Size 1.0 MB
Tags Python 3
SHA-256 checksum
How to use checksums
bdb2a1ea5cbaa5fde1e71607b6393ba0882595e00742b462bc10770ec06bb4f9
BLAKE2b-256 checksum
How to use checksums
1019260f066b134c2ce828930dbbdfc41bcf48fe3d37c4a817896c610e408207
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page