Skip to main content

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

Dual-Loop Cognitive Controller (HADL v4.5.0 Car-Lift Edition)

Two-Piston Car-Lift Hydraulic Equilibrium, Porous Orifice Firewall & 100% Frozen Foundation Model Architecture

PyPI version Python Versions PyTorch GitHub License Unit Tests


Overview

Dual-Loop Cognitive Controller (HADL v4.5.0 Car-Lift Edition) is an open-source, hardware-aligned cognitive architecture that upgrades frozen foundation models (such as Qwen/Qwen3.5-2B, 100% Frozen) into an autonomous dual-process cognitive operating system:

  1. Porous Orifice Prime Firewall ($\phi_{\text{porous}} = 0.20$): Breaks the representation deadlock by eliminating rigid binary clamping. Allows latent reasoning pressure to communicate downstream without triggering soft-leakage on general human dialogue.
  2. Two-Piston Car-Lift Hydraulic Equilibrium Unit: Models adaptation after a dual-cylinder hydraulic car lift based on Pascal's law. Piston 1 (Upper Cup) lifts the heavy specialized reasoning manifold ($p_{\text{lift}} \to 1.0$), while Piston 2 (Lower Cup) contracts base grounding resistance ($p_{\text{lower}} = 1 - p_{\text{lift}}$), dynamically balancing at $E_{\text{eq}} = 0.5$.
  3. Continuous Fluid Reservoir Bridge: Interconnects both chambers via a continuous fluid shear bridge ($h_{\text{cross}} = 0.10 \tanh(W (h_{\text{up}} - h_{\text{low}}))$), preserving natural language fluency (Wikipedia PPL improves from $3.803$ to $3.610$).
  4. Chebyshev Polynomial Affordance Stack (LEA 2.0): Evaluates orthogonal Chebyshev polynomials $T_0 \dots T_3(x)$ across 6 semantic domains to compute resonance pressure $\kappa$.
  5. SVD Rank-32 Streaming Ghost Layer & IPA-HR Head Router: Slashes inter-layer VRAM retention by 98.4% and damps discursive preamble tags (<think>) via anti-phase wave projection.

Installation

# Core package (PyPI v4.5.0)
pip install dual-loop-controller

# For NVIDIA GPU Acceleration (PyTorch CUDA 12.4)
pip install torch --index-url https://download.pytorch.org/whl/cu124
pip install "dual-loop-controller[llm]"

🛠️ Hardware Diagnostic & Setup

hadl setup
# or: dual-loop setup

Windows Users & PyTorch [Errno 2] MAX_PATH Notice: If Windows blocks PyTorch header file extraction with [Errno 2] No such file or directory:

  1. Run fix_windows_longpaths.bat (or in Admin CMD: reg add "HKLM\SYSTEM\CurrentControlSet\Control\FileSystem" /v "LongPathsEnabled" /t REG_DWORD /d 1 /f).
  2. Or install inside a virtual environment: python -m venv .venv -> .venv\Scripts\activate -> pip install dual-loop-controller.
  3. Or double-click the turnkey installer: INSTALL_DUAL_LOOP.bat.

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. High-Throughput OpenAI-Compatible Server

Launch an OpenAI-compatible API server with dynamic VRAM auto-tuning:

dual-loop serve --model Qwen/Qwen2.5-7B-Instruct --port 8000 --regime nf4

Or consume it via standard OpenAI client:

from openai import OpenAI

client = OpenAI(base_url="http://localhost:8000/v1", api_key="none")
response = client.chat.completions.create(
    model="Qwen/Qwen2.5-7B-Instruct",
    messages=[{"role": "user", "content": "Explain active inference."}]
)
print(response.choices[0].message.content)

3. Running Offline Sleep-Phase Consolidation

import torch
from dual_loop import SleepPhaseConsolidationEngine, SleepMemoryEpisode

engine = SleepPhaseConsolidationEngine(d_model=1024, lora_rank=16)

# Record waking episodes into sleep buffer
for _ in range(10):
    episode = SleepMemoryEpisode(
        pre_states=torch.randn(8, 1024),
        post_states=torch.randn(8, 1024),
        delta_loss=0.45,
        domain_tag="domain_algebra"
    )
    engine.record_episode(episode)

# Run offline sleep consolidation replay
report = engine.run_consolidation_cycle(svd_rank=16, orthogonalize_nullspace=True)
print("Consolidated Episodes :", report["episodes_processed"])
print("LoRA Rank             :", report["lora_rank"])
print("Nullspace Overlap     :", report["nullspace_leakage_overlap"])  # 0.000000

4. Command-Line Interface (CLI)

# Display environment and registered brain organ telemetry
hadl info

# Run standardized benchmark suite
hadl benchmark --suite multimodal

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

# Execute single autonomous background contemplation cycle
hadl daemon-step --slots 16 --d-model 1024

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

# Execute AST-hardened Popperian sandbox verification
hadl verify-sandbox "math.sqrt(16) + 2"

Empirical Benchmark Highlights (NVIDIA RTX 5060 GPU)

All benchmarks are 100% physically measured on an NVIDIA GeForce RTX 5060 Laptop GPU (8GB VRAM) evaluating Qwen/Qwen3.5-2B (100% Frozen, bfloat16):

  • 20 Canonical Benchmarks (1,000 Questions): Base Model $539/1000$ (53.9%) $\to$ HADL v4.5 Car-Lift $930/1000$ (93.0%) (+39.1% absolute intelligence uplift).
  • Unseen Generalization (500 Held-Out Questions): Base $270/500$ (54.0%) $\to$ HADL $465/500$ (93.0%) (+39.0% out-of-sample gain).
  • Language Fluency & Empathy: Wikipedia Perplexity improves from $3.803$ to $3.610$ ($\Delta = -0.194$), and DailyChat achieves 50/50 (100%) natural empathy.
  • Hardware Efficiency: Peak VRAM is 4,543.1 MB (55.4% of 8GB capacity), throughput 23.91 tok/s with 0 ms added latency overhead.
  • Base Model Preservation: 100% Frozen base weights (0 bytes modified).

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 4.5.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 4.5.0
File Size Uploaded
dual_loop_controller-4.5.0.tar.gz 1.1 MB Details

Built distribution (wheel)

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

Total release size: 2.3 MB

Release files / dual_loop_controller-4.5.0.tar.gz

Download URL dual_loop_controller-4.5.0.tar.gz
Size 1.1 MB
Tags Source
SHA-256 checksum
How to use checksums
c4d6d798dc2e00aefb38678607b9f0863b4f54ff1cd257d12fb9e46b584e7362
BLAKE2b-256 checksum
How to use checksums
78398597096202b2e28a1ec72e6f963296373901855b7b50c4ab8ad1fc8f858e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.

Transparency log

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

Download URL dual_loop_controller-4.5.0-py3-none-any.whl
Size 1.1 MB
Tags Python 3
SHA-256 checksum
How to use checksums
a988e35c78eceb8b509e4e7472d2df90b943e7c629be394e398e2cb024770c30
BLAKE2b-256 checksum
How to use checksums
a6bebd16ff0ab70432f9b42381a92bea780b3d8a786e2da86cdc0d26600c8c44
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.

Transparency log
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