🚀 DeepSeek-R1-8B-PolySurgery

Subtitle: Running 32k-Context 8B Reasoning on a 6 GB Consumer Laptop GPU via Zero-Backpropagation Closed-Form Weight Surgery and In-Situ KV Compaction.
Author: Dr. A. Emre ÇETİN (Computational Systems and Cognitive Architectures, Izmir, Turkey)
Official Paper: ResearchGate Publication 414060833
GitHub Repository: github.com/aemre-cetin/idempotent-poly
Patent Base: U.S. Patent Application No. 64/148,668 & 64/148,679 (Patent Pending, Conf #5890)
Hardware Evaluated: NVIDIA RTX PRO 500 Blackwell Generation Laptop GPU (6 GB VRAM), 32 GB RAM.


💡 What is DeepSeek-R1-8B-PolySurgery?

State-of-the-art reasoning models like DeepSeek-R1-Distill-Llama-8B suffer from two major barriers when deployed on consumer hardware:

  1. Weight Footprint: Feed-Forward Networks (SwiGLU) represent 70.2% of total model parameters (5.64 Billion out of 8.03B).
  2. Reasoning Chain KV-Cache Explosion: Multi-thousand-token <think> ... </think> chains consume up to 4.0 GB of VRAM for KV-cache alone at 32k context, causing immediate Out-Of-Memory (OOM) crashes on 6 GB / 8 GB consumer GPUs.

DeepSeek-R1-8B-PolySurgery solves both simultaneously:

  • idempotent-poly: Replaces SwiGLU with degree-$K=3$ Chebyshev orthogonal polynomial tensor operators solved in 50.74 seconds across all 32 layers via closed-form algebraic normal equations: $$C^* = (\Phi(X)^T \Phi(X) + \lambda I)^{-1} \Phi(X)^T Y$$
  • idempotent-kv: Applies zero-copy in-situ idempotent permutation compactor achieving 50% KV memory compaction with 0-byte peak auxiliary allocation.

Result: A full 8B reasoning system with 32k context capability compressed from 9.2 GB VRAM down to 4.78 GB VRAM, running stably on a 6 GB laptop GPU without OOM.


📊 Benchmark Results

1. In-Situ Weight Surgery (All 32 Layers)

Metric Original SwiGLU (DeepSeek-R1) Chebyshev PolyFFN ($K=3$) Delta / Savings
FFN Parameters Per Layer 176,160,768 (176.16M) 67,108,864 (67.11M) -61.90% Parameters
Total Model FFN Parameters 5,637,144,576 (5.64B) 2,147,483,648 (2.15B) -3.49 Billion Parameters Removed!
Total Model Parameters 8,030,000,000 (8.03B) 4,540,339,072 (4.54B) -43.5% Model Total
Full Surgery Time (32 Layers) Days of GPU fine-tuning 50.74 Seconds (0.85 min) Instant Zero-Backprop
Peak VRAM During Surgery > 16 GB < 400 MB Extremely lightweight
Layer Forward Pass Latency 100.73 ms 40.43 ms 2.49x Faster Inference! ⚡

2. KV-Cache Scaling Under Long <think> Chains

Context Length (Tokens) Standard GQA KV Cache Idempotent-KV Cache Net Memory Saved
2,048 Tokens 256.0 MB 128.0 MB -128.0 MB (-50.0%)
4,096 Tokens 512.0 MB 256.0 MB -256.0 MB (-50.0%)
8,192 Tokens 1.00 GB 0.50 GB -0.50 GB (-50.0%)
16,384 Tokens 2.00 GB 1.00 GB -1.00 GB (-50.0%)
32,768 Tokens 4.00 GB 2.00 GB -2.00 GB (-50.0%)

Zero-Auxiliary In-Place Verification:

Tensor Pointer (Pre-Compaction)  : 0x3aa15400100
Tensor Pointer (Post-Compaction) : 0x3aa15400100
Verification: In-situ idempotent permutation reused the exact physical memory address.
Zero O(N) auxiliary allocation buffers created.

3. VRAM Footprint on 6 GB Laptop GPU

[Standard DeepSeek-R1-8B @ 32k Context]
Weights (Q4_K_M) : 4.92 GB
KV-Cache (32k)   : 4.00 GB
Overhead/Act     : 0.30 GB
TOTAL VRAM       : 9.22 GB  ❌ CRASHES (OOM on 6 GB GPU)

[Idempotent Surgery + Compaction @ 32k Context]
Weights (PolyFFN): 2.78 GB
KV-Cache (Idem)  : 2.00 GB
Overhead/Act     : 0.20 GB
TOTAL VRAM       : 4.98 GB  ✅ RUNS STABLY (Under 6 GB VRAM limit!)

💻 Quickstart & Benchmark Reproduction

Install dependencies:

pip install idempotent-poly idempotent-kv torch llama-cpp-python

Run the verified benchmark directly:

# Clone and run the benchmark from GitHub:
# git clone https://github.com/aemre-cetin/idempotent-poly.git
# python idempotent-poly/examples/deepseek_r1_8b_surgery_benchmark.py

📜 Citation & Licensing

@article{cetin2026idempotentpoly,
  title={Hardware-Accelerated Orthogonal Polynomial Tensor Operators, Zero-Backpropagation Closed-Form Algebraic Solvers, and In-Situ Weight Surgery for Deep Neural Networks},
  author={Çetin, A. Emre},
  journal={ResearchGate Publication 414060833},
  year={2026},
  doi={10.13140/RG.2.2.33890.85442}
}

Protected under U.S. Patent Application Nos. 64/148,668 & 64/148,679 (Patent Pending). Non-commercial research permitted.

Downloads last month
477
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for aecetin/DeepSeek-R1-8B-PolySurgery

Finetuned
(170)
this model