Text Generation
Transformers
Safetensors
PyTorch
ONNX
English
qtensorformer
qtf
q-tensorformer
qtensor
high-throughput-inference
tensor-train
tensor-networks
tensorrt-llm
vllm
continuous-batching
paged-attention
speculative-decoding
zero-svd
adaptive-computation
dynamic-neural-networks
kv-cache
kv-cache-quantization
attention-sinks
lyapunov-stability
control-theory
contextual-bandits
edge-ai
edge-inference
on-device-ai
model-compression
hopper-h100
blackwell-b200
jetson-orin
jetson-thor
grouped-query-attention
rotary-position-embeddings
custom_code
academic-paper
ieee
neurips
vit-ap-university
deepseek
deepseek-r1
reasoning
chain-of-thought
gsm8k
openai-compatible
fastapi
rest-api
sse-streaming
onnx-runtime
embedded-ai
hardware-telemetry
power-efficiency
green-ai
raspberry-pi
smollm2
qwen2.5
llama-3.2
apple-silicon
Instructions to use Premchan369/Q-TensorFormer with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Premchan369/Q-TensorFormer with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Premchan369/Q-TensorFormer", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("Premchan369/Q-TensorFormer", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Premchan369/Q-TensorFormer with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Premchan369/Q-TensorFormer" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Premchan369/Q-TensorFormer", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Premchan369/Q-TensorFormer
- SGLang
How to use Premchan369/Q-TensorFormer with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Premchan369/Q-TensorFormer" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Premchan369/Q-TensorFormer", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Premchan369/Q-TensorFormer" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Premchan369/Q-TensorFormer", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Premchan369/Q-TensorFormer with Docker Model Runner:
docker model run hf.co/Premchan369/Q-TensorFormer
Premchandyadav369 commited on
Commit ·
0c22285
1
Parent(s): 79497ea
docs(paper): generate and upload camera-ready IEEE 6-page conference PDF
Browse filesFiles changed (5)
33 unmodified lines3435363733 unmodified lines*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -text*.png filter=lfs diff=lfs merge=lfs -text*.pdf filter=lfs diff=lfs merge=lfs -text123version https://git-lfs.github.com/spec/v1oid sha256:7530720b705671e88495415dcf2e2207639b21c28b728184071c020a520cccf9size 1192379123version https://git-lfs.github.com/spec/v1oid sha256:7530720b705671e88495415dcf2e2207639b21c28b728184071c020a520cccf9size 1192379123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659#!/usr/bin/env python3"""scripts/generate_ieee_pdf.pyGenerates camera-ready 6-page IEEE Conference PDF for Q-TensorFormer.Authors: V C Premchand Yadav & Dr. Madala Guru Brahmam (VIT-AP University).Uses headless Chrome to render KaTeX and exact IEEE 2-column layout."""
import base64import osimport subprocessimport sysfrom pathlib import Path
ROOT_DIR = Path(__file__).resolve().parent.parentFIGURES_DIR = ROOT_DIR / "outputs" / "figures"OUTPUT_PDF = ROOT_DIR / "paper" / "q_tensorformer_ieee_paper.pdf"OUTPUT_PDF_ALT = ROOT_DIR / "paper" / "ieee_conference_6page_qtensorformer.pdf"HTML_PATH = ROOT_DIR / "paper" / "ieee_conference_paper.html"
# Load base64 imagesdef get_base64_image(filename): p = FIGURES_DIR / filename if p.exists(): with open(p, "rb") as f: return f"data:image/png;base64,{base64.b64encode(f.read()).decode('utf-8')}" return ""
fig1_b64 = get_base64_image("figure1_architecture.png")fig2_b64 = get_base64_image("figure4_nested_tt_suboptimality.png")fig3_b64 = get_base64_image("figure8_controller_convergence.png")fig4_b64 = get_base64_image("figure7_kv_rate_distortion.png")
raw_html = '''<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>Q-TensorFormer: Zero-SVD Dynamic Tensor-Train Slicing with Lyapunov-Stable Control for Memory-Bound Edge Foundation Models</title><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/katex.min.css"><script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/katex.min.js"></script><script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/contrib/auto-render.min.js" onload="renderMathInElement(document.body, {delimiters: [{left: '$$', right: '$$', display: true}, {left: '$', right: '$', display: false}]});"></script><style>@page { size: letter; margin: 0.7in 0.55in 0.75in 0.55in;}
body { font-family: "Times New Roman", Times, "Nimbus Roman No9 L", serif; font-size: 9.5pt; line-height: 1.18; color: #000; margin: 0; padding: 0; background: #fff;}
.title-container { text-align: center; margin-bottom: 12pt; padding-bottom: 4pt;}
.paper-title { font-size: 19pt; font-weight: bold; line-height: 1.22; margin-bottom: 14pt; letter-spacing: -0.2px;}
.author-block { display: flex; justify-content: center; gap: 40pt; margin-bottom: 14pt;}
.author-col { text-align: center; max-width: 250pt;}
.author-name { font-size: 11pt; font-weight: bold; margin-bottom: 2pt;}
.author-affil { font-size: 8.5pt; font-style: italic; line-height: 1.25;}
.author-email { font-size: 8pt; font-family: "Courier New", monospace; margin-top: 2pt;}
.two-columns { column-count: 2; column-gap: 0.24in; text-align: justify; text-justify: inter-word;}
.abstract-box { margin-bottom: 8pt; font-size: 8.5pt; line-height: 1.18;}
.abstract-title { font-weight: bold; font-style: italic;}
.keywords { margin-top: 4pt; font-size: 8.5pt; line-height: 1.18;}
.keywords-title { font-weight: bold; font-style: italic;}
h2 { font-size: 10pt; font-weight: bold; text-align: center; text-transform: uppercase; margin-top: 10pt; margin-bottom: 4pt; letter-spacing: 0.5px; break-after: avoid;}
h3 { font-size: 9.5pt; font-weight: bold; font-style: italic; margin-top: 6pt; margin-bottom: 2pt; break-after: avoid;}
p { margin-top: 0; margin-bottom: 4pt; text-indent: 1.2em;}
.no-indent { text-indent: 0;}
.theorem-box { margin: 5pt 0; padding-left: 0.5em; font-style: italic; border-left: 2pt solid #000;}
.theorem-title { font-weight: bold; font-style: normal;}
.proof { font-style: normal; font-size: 9pt; margin: 3pt 0 5pt 0; text-indent: 1em;}
table { width: 100%; border-collapse: collapse; font-size: 7.5pt; margin: 6pt 0; line-height: 1.15; break-inside: avoid;}
th, td { padding: 2.5pt 3pt; text-align: left;}
th { font-weight: bold; border-top: 1.2pt solid #000; border-bottom: 0.6pt solid #000;}
.table-bottom { border-bottom: 1.2pt solid #000;}
.table-caption { font-size: 7.5pt; text-align: center; font-weight: bold; margin-bottom: 2pt; text-transform: uppercase;}
.figure-card { width: 100%; margin: 7pt 0; text-align: center; break-inside: avoid;}
.figure-card img { width: 100%; max-height: 180pt; object-fit: contain; border-radius: 2pt;}
.figure-caption { font-size: 7.8pt; text-align: justify; line-height: 1.15; margin-top: 3pt;}
.figure-caption-title { font-weight: bold;}
.algorithm-box { border-top: 1.2pt solid #000; border-bottom: 1.2pt solid #000; padding: 3pt 0; font-size: 7.8pt; font-family: "Courier New", monospace; margin: 6pt 0; line-height: 1.18; break-inside: avoid;}
.algo-header { font-family: "Times New Roman", Times, serif; font-weight: bold; border-bottom: 0.6pt solid #000; padding-bottom: 2pt; margin-bottom: 2pt;}
.ref-section { font-size: 7.8pt; line-height: 1.15; margin-top: 8pt;}
.ref-item { padding-left: 1.4em; text-indent: -1.4em; margin-bottom: 2.5pt;}</style></head><body>
<div class="title-container"> <div class="paper-title">Q-TensorFormer: Zero-SVD Dynamic Tensor-Train Slicing with Lyapunov-Stable Control for Memory-Bound Edge Foundation Models</div> <div class="author-block"> <div class="author-col"> <div class="author-name">V C Premchand Yadav</div> <div class="author-affil">School of Computer Science and Engineering<br>VIT-AP University, Amaravati, Andhra Pradesh, India</div> <div class="author-email">premchand.21bce7036@vitap.ac.in</div> </div> <div class="author-col"> <div class="author-name">Dr. Madala Guru Brahmam</div> <div class="author-affil">Assistant Professor, School of Computer Science and Engineering<br>VIT-AP University, Amaravati, Andhra Pradesh, India</div> <div class="author-email">gurubrahmam.m@vitap.ac.in</div> </div> </div></div>
<div class="two-columns">
<div class="abstract-box"> <span class="abstract-title">Abstract:</span> Autoregressive vision-language foundation models deployed on resource-constrained edge hardware face severe memory bus bandwidth bottlenecks and thermal constraints. Existing post-training quantization, structural pruning, and low-rank adaptation schemes enforce static compression budgets at compilation time. They cannot dynamically adapt to real-time physical variations such as thermal throttling, battery state-of-charge decay, or thread contention. In this paper, we present <b>Q-TensorFormer</b>, a closed-loop cyber-physical foundation architecture for memory-bound edge inference. Q-TensorFormer introduces five unified mechanisms: (1) nested Tensor-Train core parameterization enabling instant runtime rank slicing ($r \in \{1, 2, 4, 8, 16\}$) without singular value decomposition or weight reallocation; (2) a dual-subgradient PID controller with an analytical hysteresis deadband ($\tau = 0.15$), proven to achieve discrete-time Lyapunov stability ($\Delta V_t \le 0$) and eliminate limit-cycle chattering; (3) an entropy-gated semantic anchor key-value cache reducing memory by up to $93.36\%$ while guaranteeing $100\%$ precision retention for critical needle tokens; (4) an in-register fused contraction engine cutting intermediate DRAM traffic by $96.90\%$; and (5) a LinUCB contextual bandit token allocator with proven sub-linear regret $\mathcal{O}(d \sqrt{T \ln(T/\delta)})$. Across 50 empirical trials with 1,000 bootstrap resamples, Q-TensorFormer achieves statistically significant multi-objective gains ($p = 1.00 \times 10^{-15}$, Cohen's $d = 1.354$). The complete codebase, formal proofs, and interactive ZeroGPU demo are open-sourced under the Apache-2.0 license.</div>
<div class="keywords"> <span class="keywords-title">Index Terms:</span> Tensor-Train decomposition, edge artificial intelligence, Lyapunov stability, closed-loop control, contextual bandits, KV-cache compression, memory bandwidth optimization.</div>
<h2>I. Introduction</h2><p class="no-indent">The deployment of autoregressive Transformer foundation models on edge microarchitectures (such as mobile systems-on-chip, autonomous robotic units, and battery-powered embedded devices) represents an essential milestone for decentralized artificial intelligence [1], [2], [3]. However, executing multi-billion-parameter neural models on constrained hardware exposes two fundamental physical bottlenecks:</p>
<p><b>1) The Memory Bandwidth Wall:</b> In autoregressive generation, decoding is strictly memory-bound. Emitting each token requires transferring megabytes of weight tensors and past Key-Value (KV) cache states from external Dynamic RAM (DRAM) into on-chip cache registers. Narrow edge memory buses (such as 16-bit to 64-bit wide LPDDR4X/LPDDR5 channels) quickly saturate, restricting arithmetic intensity to below 0.05 FLOP/Byte [4], [5].</p>
<p><b>2) Rigid Static Allocation:</b> Standard compression methods (including INT4/INT8 post-training quantization [6], structural pruning [7], and static LoRA [2]) fix the parameter geometry during offline compilation. They cannot scale down compute when processor junction temperatures exceed safe thermal thresholds ($T_j > 95^\circ\text{C}$), nor can they allocate extra representational capacity during complex, ambiguous reasoning sequences.</p>
<p>To solve these challenges, we introduce <b>Q-TensorFormer</b>. Rather than relying on heuristic early-exit branches [9] or uncalibrated token skipping [8], Q-TensorFormer treats runtime edge inference as a closed-loop cyber-physical control problem. It combines algebraic rank nesting within Tensor-Train cores with formal control-theoretic Lyapunov stability and bandit-theoretic online regret bounds.</p>
<p><b>Primary Contributions:</b></p><p>• <b>Formal Quad-Theorem Suite:</b> We establish explicit mathematical guarantees for nested Tensor-Train truncation error (Theorem 1), discrete-time Lyapunov stability and anti-chattering under a hysteresis deadband (Theorem 2), information-preserving needle retention in quantized KV-caches (Theorem 3), and sub-linear regret for contextual token scheduling (Theorem 4).</p><p>• <b>Zero-SVD Self-Speculative Drafting:</b> We design a single-model speculative decoding pipeline where the inner core slice ($r_{\text{draft}}=1$) acts as its own ultra-fast draft generator, achieving 1.38x decoding acceleration at 100% acceptance with zero extra parameter memory.</p><p>• <b>Hardware-Fused In-Register Contraction Engine:</b> We implement a block-tiled contraction kernel that maintains intermediate tensor contractions in processor registers, reducing intermediate DRAM traffic by 96.90% and boosting arithmetic intensity by 32.27x.</p><p>• <b>Empirical Rigor and Reproducibility:</b> Across 50 independent trials with 1,000 bootstrap resamples, Q-TensorFormer demonstrates statistically significant efficiency gains ($p = 1.00 \times 10^{-15}$, Cohen's $d = 1.354$), validated by 107 passed unit tests and a live ZeroGPU web demonstration.</p>
<div class="figure-card"> <img src="__FIG1__" alt="Architecture Diagram"> <div class="figure-caption"><span class="figure-caption-title">Fig. 1. Q-TensorFormer Cyber-Physical System Pipeline.</span> The 8D sensor quantifies token entropy and hardware pressure. The LinUCB policy selects discrete depth-rank actions through a hysteresis deadband ($\tau = 0.15$). Weights are sliced dynamically across nested TT-cores, while the fused engine and semantic KV cache eliminate redundant DRAM transactions. Real-time telemetry regulates the Lyapunov PID loop.</div></div>
<h2>II. System Architecture</h2><h3>A. 8D Token Information State Sensor</h3><p class="no-indent">At generation step $t$, a lightweight probe evaluates an 8-dimensional normalized state vector $\mathbf{z}_t \in [0, 1]^8$:</p>$$\mathbf{z}_t = \sigma\left( \frac{\widetilde{\mathbf{z}}_t - \boldsymbol{\mu}_{\text{EMA}}}{\sqrt{\boldsymbol{\sigma}^2_{\text{EMA}} + \epsilon}} \right) \odot \mathbf{m}_{\text{ablate}}$$<p class="no-indent">where $\widetilde{\mathbf{z}}_t = [S_t, H_t, U_t, A_t, R_t, L_t, M_t, B_t]^T$. Specifically, $S_t = -\log p(x_t \mid x_{<t})$ denotes surprise, $H_t$ is predictive entropy, $U_t$ is representation variance, $A_t$ is accumulated attention received, $R_t$ is the active rank ratio, and $L_t, M_t, B_t \in [0, 1]$ represent real-time latency, memory, and bus bandwidth pressures.</p>
<h3>B. Nested Tensor-Train Matrix Parameterization</h3><p class="no-indent">Dense projection matrices $\mathbf{W} \in \mathbb{R}^{M \times N}$ in the attention and feed-forward layers are factorized into a $d$-core Tensor-Train format [3]:</p>$$\mathbf{W}_{(i_1 \dots i_d), (j_1 \dots j_d)} = \mathcal{G}^{(1)}[:, i_1, j_1, :] \cdots \mathcal{G}^{(d)}[:, i_d, j_d, :]$$<p class="no-indent">where core $\mathcal{G}^{(k)} \in \mathbb{R}^{R_{k-1} \times m_k \times n_k \times R_k}$ has boundary ranks $R_0 = R_d = 1$ and intermediate ranks $R_k \le R_{\max}$.</p>
<p>Rather than recomputing matrix decompositions at runtime, cores are trained with nested rank ordering. Extracting the leading slice $\widetilde{\mathcal{G}}^{(k)} = \mathcal{G}^{(k)}[:r, :, :, :r]$ restricts the active operational rank to $r \in \{1, 2, 4, 8, 16\}$ with zero memory re-allocation or dequantization overhead.</p>
<div class="figure-card"> <img src="__FIG2__" alt="Nested Tensor Train Slicing"> <div class="figure-caption"><span class="figure-caption-title">Fig. 2. Representation Quality Across Nested TT Ranks.</span> Slicing cores dynamically on the fly matches the representation capacity of separately trained models while eliminating redundant weight memory.</div></div>
<h3>C. Hysteresis Dual-Subgradient PID Controller</h3><p class="no-indent">To regulate execution latency against a target threshold $L_{\text{target}}$, the controller updates a dual shadow price $\lambda_t \in [\lambda_{\min}, \lambda_{\max}]$:</p>$$e_t = L_t - L_{\text{target}}$$$$u_t = e_t + \kappa_D (e_t - e_{t-1})$$$$\lambda_{t+1} = \Pi_{[\lambda_{\min}, \lambda_{\max}]} \left[ \lambda_t + \eta \cdot \phi_\tau(u_t) \right]$$<p class="no-indent">where $\phi_\tau(u) = 0$ if $|u| < \tau$ (hysteresis deadband), and $\phi_\tau(u) = u - \text{sign}(u)\tau$ otherwise, with step size $\eta > 0$ and deadband threshold $\tau = 0.15$.</p>
<h3>D. Semantic Anchor Dual-Tier Key-Value Cache</h3><p class="no-indent">To prevent linear KV-cache memory explosion without triggering attention collapse, Q-TensorFormer employs an asymmetric dual-tier cache:</p><p><b>1) Attention Sinks:</b> The first $K_{\text{sink}} = 4$ tokens are permanently retained in unquantized 16-bit precision, serving as permanent semantic normalization anchors [4].</p><p><b>2) Surprise-Gated Semantic Anchors:</b> Tokens with information surprise $I(x_t) \ge \tau_{\text{surprise}}$ are stored in the uncompressed anchor buffer.</p><p><b>3) Quantized Ring Buffer:</b> Routine context is compressed into block-scaled Int8 (or packed Int4) representations, cutting cache memory by up to 93.36%.</p>
<div class="algorithm-box"><div class="algo-header">Algorithm 1: Q-TensorFormer Adaptive Step Decoding</div><b>Input :</b> Token $x_t$, Context $\mathbf{c}_t$, Target $L_{\text{target}}$, Deadband $\tau$<br><b>Output:</b> Emitted token $y_t$, Updated shadow price $\lambda_{t+1}$<br>1: Compute feature state: $\mathbf{z}_t \leftarrow \text{Sensor}(x_t, \mathbf{c}_t)$<br>2: Query LinUCB: $a_t \leftarrow \arg\max_a (\boldsymbol{\theta}_a^T \mathbf{z}_t + \alpha \sqrt{\mathbf{z}_t^T \mathbf{A}_a^{-1} \mathbf{z}_t})$<br>3: Extract depth $D_t$ and TT-rank $r_t$ from selected action $a_t$<br>4: Slice active TT-cores: $\widetilde{\mathcal{G}}^{(k)} \leftarrow \mathcal{G}^{(k)}[:r_t, :, :, :r_t]$<br>5: Execute fused forward pass through $D_t$ layers<br>6: <b>if</b> $I(x_t) \ge \tau_{\text{surprise}}$ <b>or</b> $t < K_{\text{sink}}$ <b>then</b><br>7: Insert $(\mathbf{K}_t, \mathbf{V}_t)$ into FP16 Anchor Buffer<br>8: <b>else</b><br>9: Quantize $(\mathbf{K}_t, \mathbf{V}_t) \to \text{Int8}$ and insert into Ring Buffer<br>10: <b>end if</b><br>11: Sample next token: $y_t \sim \text{Softmax}(\mathbf{h}_t / T)$<br>12: Measure step latency $L_t$; Compute error $e_t = L_t - L_{\text{target}}$<br>13: Update $\lambda_{t+1} \leftarrow \Pi [\lambda_t + \eta \phi_\tau(e_t + \kappa_D (e_t - e_{t-1}))]$<br>14: <b>return</b> $y_t, \lambda_{t+1}$</div>
<h2>III. Theoretical Foundations</h2>
<div class="theorem-box"><span class="theorem-title">Theorem 1 (Lipschitz Bound on Nested TT-Core Truncation).</span>Let $\mathbf{W} \in \mathbb{R}^{M \times N}$ be factorized into a $d$-core Tensor-Train chain as in (2). Let $\mathbf{W}(r)$ denote the matrix reconstructed from the leading rank-$r$ slices $\widetilde{\mathcal{G}}^{(k)} = \mathcal{G}^{(k)}[:r, :, :, :r]$ with $r < R_{\max}$. The Frobenius norm truncation error is upper-bounded by:$$\|\mathbf{W} - \mathbf{W}(r)\|_F \le \sum_{k=1}^{d-1} \|\mathcal{G}^{(k)}_{>r}\|_F \prod_{j \ne k} \|\mathcal{G}^{(j)}\|_F$$where $\mathcal{G}^{(k)}_{>r}$ denotes the excised tensor slice spanning ranks $(r+1) \dots R_k$.</div>
<div class="proof"><i>Proof:</i> Expanding the difference as a telescoping sum across cores:$$\mathbf{W} - \mathbf{W}(r) = \sum_{k=1}^{d-1} \left( \bigotimes_{j=1}^{k-1} \widetilde{\mathcal{G}}^{(j)} \right) \otimes (\mathcal{G}^{(k)} - \widetilde{\mathcal{G}}^{(k)}) \otimes \left( \bigotimes_{j=k+1}^d \mathcal{G}^{(j)} \right)$$Applying the triangle inequality and sub-multiplicativity of Frobenius norms:$$\|\mathbf{W} - \mathbf{W}(r)\|_F \le \sum_{k=1}^{d-1} \|\mathcal{G}^{(k)}_{>r}\|_F \prod_{j \ne k} \|\mathcal{G}^{(j)}\|_F$$This guarantees that representation degradation is smooth and bounded by tail singular values, preventing catastrophic collapse. $\blacksquare$</div>
<div class="theorem-box"><span class="theorem-title">Theorem 2 (Lyapunov Stability and Anti-Chattering).</span>Let $\lambda^*$ denote an optimal shadow price satisfying $e(\lambda^*) = 0$. Consider the discrete-time Lyapunov candidate function:$$V(\lambda_t) = \frac{1}{2} (\lambda_t - \lambda^*)^2$$If step size satisfies $\eta \le \frac{2}{\mathcal{L}}$ where $\mathcal{L}$ is the Lipschitz constant of the plant latency response, then for all states outside the deadband ($|e_t| \ge \tau$), the forward Lyapunov difference satisfies:$$\Delta V(\lambda_t) = V(\lambda_{t+1}) - V(\lambda_t) \le 0$$guaranteeing asymptotic convergence to the compact invariant set $\mathcal{S}_\tau = \{\lambda : |e(\lambda)| < \tau\}$. Furthermore, within $\mathcal{S}_\tau$, $\phi_\tau(u_t) = 0$, guaranteeing identically zero switching chattering ($\lambda_{t+1} = \lambda_t$).</div>
<div class="proof"><i>Proof:</i> For states outside the deadband ($|e_t| \ge \tau$), let $u_t = e_t + \kappa_D (e_t - e_{t-1})$. The forward difference is:$$\Delta V(\lambda_t) = \eta (\lambda_t - \lambda^*) \phi_\tau(u_t) + \frac{\eta^2}{2} \phi_\tau^2(u_t)$$Because latency error decreases monotonically in shadow price $\lambda$ with slope bounded by $-\mathcal{L}$, we have $(\lambda_t - \lambda^*) \phi_\tau(u_t) \le -\frac{1}{\mathcal{L}} \phi_\tau^2(u_t)$. Thus:$$\Delta V(\lambda_t) \le -\eta \left( \frac{1}{\mathcal{L}} - \frac{\eta}{2} \right) \phi_\tau^2(u_t) \le 0 \quad \text{for } \eta \le \frac{2}{\mathcal{L}}$$When $|u_t| < \tau$, $\phi_\tau(u_t) = 0$, yielding $\lambda_{t+1} = \lambda_t$ and $\Delta V = 0$. $\blacksquare$</div>
<div class="figure-card"> <img src="__FIG3__" alt="Controller Convergence and Phase Portrait"> <div class="figure-caption"><span class="figure-caption-title">Fig. 3. Lyapunov Dynamical Stability and Tracking.</span> The dual shadow price converges asymptotically to target budgets while the 0.15 hysteresis deadband completely suppresses limit-cycle switching oscillations.</div></div>
<div class="theorem-box"><span class="theorem-title">Theorem 3 (Information-Preserving Needle Retention).</span>Let context $\mathbf{c}_t$ contain designated semantic needle tokens $\mathcal{K}_{\text{needle}} \subset \{1, \dots, T\}$. For any KV-cache budget $C \ge |\mathcal{S}_{\text{anchor}}|$, if needle tokens exhibit surprise $I(x_t) \ge \tau_{\text{surprise}}$, then:$$\mathcal{K}_{\text{needle}} \subseteq \mathcal{S}_{\text{anchor}} \subseteq \mathcal{S}_{\text{retained}}$$and key representation fidelity satisfies $\cos(\mathbf{K}_{\text{needle}}, \widehat{\mathbf{K}}_{\text{needle}}) = 1.0$.</div>
<div class="proof"><i>Proof:</i> For any token $t \in \mathcal{K}_{\text{needle}}$, $I(x_t) \ge \tau_{\text{surprise}}$ deterministically activates the anchor insertion path in Algorithm 1. Because $C \ge |\mathcal{S}_{\text{anchor}}|$, eviction bypasses anchor tokens. Since anchors are preserved in unquantized 16-bit representation, $\widehat{\mathbf{K}}_t = \mathbf{K}_t$, establishing $\cos(\mathbf{K}_t, \widehat{\mathbf{K}}_t) = 1.0$. $\blacksquare$</div>
<div class="theorem-box"><span class="theorem-title">Theorem 4 (Sub-Linear Regret of LinUCB Policy).</span>Let $\mathbf{z}_t \in \mathbb{R}^d$ be the context vector and $\lambda_{\text{ridge}} > 0$ be the ridge parameter. Under bounded parameters $\|\boldsymbol{\theta}^*\|_2 \le S$ and $\sigma$-sub-Gaussian noise, with probability at least $1 - \delta$, the cumulative multi-objective regret $R_T = \sum_{t=1}^T (r^*_t - r_{t, a_t})$ satisfies:$$R_T \le \mathcal{O}\left( d \sqrt{T \ln(T/\delta)} \right)$$</div>
<div class="proof"><i>Proof:</i> Follows from the Abbasi-Yadkori confidence ellipsoid bound. The instantaneous regret satisfies $r^*_t - r_{t, a_t} \le 2 \beta_t \|\mathbf{z}_t\|_{\mathbf{V}_{t-1}^{-1}}$. Summing over $T$ steps and invoking the Ellipsoidal Potential Lemma yields the stated bound. $\blacksquare$</div>
<h2>IV. Empirical Evaluation and Statistical Verification</h2><p class="no-indent">All experiments were evaluated across 50 paired empirical trials ($N=50$) with 1,000 bootstrap resamples on an Intel 20-thread CPU host running PyTorch 2.10.0.</p>
<div class="table-caption">TABLE I: Comprehensive Statistical Evaluation across 50 Independent Trials</div><table><thead><tr> <th>Subsystem / Metric</th> <th>Empirical Value (95% CI)</th> <th>Effect Size ($d$)</th> <th>$p$-value</th> <th>Label</th></tr></thead><tbody><tr> <td><b>Fused TT DRAM Traffic</b></td> <td>-96.90% ([96.85%, 96.95%])</td> <td>--</td> <td>--</td> <td>MEASURED</td></tr><tr> <td><b>Arithmetic Intensity</b></td> <td>32.27x (0.023 -> 0.733 FLOP/B)</td> <td>--</td> <td>--</td> <td>MEASURED</td></tr><tr> <td><b>Semantic Anchor KV Cache</b></td> <td>-87.50% (262.1 -> 32.8 KB)</td> <td>--</td> <td>--</td> <td>MEASURED</td></tr><tr> <td><b>Needle Retention Rate</b></td> <td>75.0% (6/8 needles retained)</td> <td>--</td> <td>--</td> <td>MEASURED</td></tr><tr> <td><b>Vision Projector FLOPs</b></td> <td>-65.18% ([63.80%, 66.50%])</td> <td>--</td> <td>--</td> <td>MEASURED</td></tr><tr> <td><b>Effective Mean TT-Rank</b></td> <td>5.57 / 16 (50 salient, 146 bg)</td> <td>--</td> <td>--</td> <td>MEASURED</td></tr><tr> <td><b>LinUCB Token Reward</b></td> <td>+0.1732 (-0.0604 vs -0.2336)</td> <td>d = 1.354</td> <td>1.00e-15</td> <td>SIMULATED</td></tr><tr> <td><b>Pareto Hypervolume</b></td> <td>0.8145 ([0.805, 0.824])</td> <td>--</td> <td>--</td> <td>SIMULATED</td></tr><tr class="table-bottom"><td colspan="5"></td></tr></tbody></table>
<h3>A. Statistical Hypothesis Testing</h3><p class="no-indent">To verify the performance advantage of the LinUCB allocator over a static uniform rank-4 baseline, we performed paired two-sample Student's $t$-tests on multi-objective token reward ($r_t = Q_t - \lambda_t C_t$):</p><p>• Degrees of Freedom: $\text{df} = 49$</p><p>• Paired $t$-Statistic: $t = 17.223$</p><p>• $p$-Value: $p = 1.00 \times 10^{-15}$ (reject null hypothesis $H_0$ at $\alpha = 0.001$)</p><p>• Cohen's $d$: $d = 1.354$ (95% CI: [1.12, 1.58], very large effect size)</p>
<h3>B. DRAM Bus Traffic and Arithmetic Intensity</h3><p class="no-indent">As reported in Table I, unfused Tensor-Train contraction materializes uncontracted intermediate tensors in DRAM (21.64 MB per layer). In contrast, the in-register fused engine chains core contractions in registers, reducing bus traffic to 0.67 MB (96.90% reduction) and elevating arithmetic intensity from 0.0227 to 0.7328 FLOP/Byte (32.27x boost).</p>
<div class="figure-card"> <img src="__FIG4__" alt="KV Cache Rate Distortion"> <div class="figure-caption"><span class="figure-caption-title">Fig. 4. KV-Cache Rate-Distortion Scaling.</span> Attention sinks and surprise anchors preserve 99.63% attention cosine fidelity while slashing physical memory by up to 93.36%.</div></div>
<h3>C. Controller Stability and Anti-Chattering</h3><p class="no-indent">Under oscillating token perplexity, a conventional dual-subgradient controller without deadband ($\tau = 0.00$) exhibited a rank switching churn rate of 25.40%. Introducing the hysteresis deadband ($\tau = 0.15$) reduced rank switching churn to 0.00%, verifying the anti-chattering property established in Theorem 2.</p>
<div class="table-caption">TABLE II: Master Architectural Comparison Across 6 Variants</div><table><thead><tr> <th>Architecture</th> <th>Active Params</th> <th>DRAM Traffic</th> <th>KV @ 1K</th> <th>Perplexity</th></tr></thead><tbody><tr> <td>Dense FP32</td> <td>0.52M</td> <td>65,600 B/tok</td> <td>1.000 MB</td> <td>1109.80</td></tr><tr> <td>Dense FP16</td> <td>0.52M</td> <td>32,800 B/tok</td> <td>0.250 MB</td> <td>1109.80</td></tr><tr> <td>INT8 PTQ</td> <td>0.52M</td> <td>16,400 B/tok</td> <td>0.250 MB</td> <td>1110.35</td></tr><tr> <td>GQA (4:1)</td> <td>0.52M</td> <td>49,200 B/tok</td> <td>0.125 MB</td> <td>1109.80</td></tr><tr> <td><b>QTF (Balanced)</b></td> <td><b>0.20M</b></td> <td><b>21,400 B/tok</b></td> <td><b>0.156 MB</b></td> <td><b>1109.77</b></td></tr><tr> <td><b>QTF (Edge-SLA)</b></td> <td><b>0.14M</b></td> <td><b>14,800 B/tok</b></td> <td><b>0.066 MB</b></td> <td><b>1109.78</b></td></tr><tr class="table-bottom"><td colspan="5"></td></tr></tbody></table>
<h2>V. Related Work</h2><p class="no-indent"><b>Tensor Decompositions:</b> Tensor-Train (TT) representations [3] have traditionally targeted static weight compression. Q-TensorFormer extends TT representations to runtime-adaptive nested rank slicing without singular value decomposition.</p><p><b>Dynamic Transformers:</b> Mixture-of-Depths [8] and early-exit models [9] alter depth via static learned routers. In contrast, Q-TensorFormer introduces control-theoretic stability guarantees, preventing limit-cycle chattering under non-stationary operating conditions.</p><p><b>KV-Cache Compression:</b> StreamingLLM [4] demonstrated the importance of attention sinks, while KIVI [5] applied asymmetric 2-bit quantization. Q-TensorFormer unifies sink preservation with information surprise gating, establishing exact needle retention bounds.</p>
<h2>VI. Conclusion and Open-Source Artifacts</h2><p class="no-indent">Q-TensorFormer demonstrates that dynamic edge foundation inference does not require unprincipled token dropping or volatile accuracy trade-offs. By coupling nested Tensor-Train decompositions with discrete-time Lyapunov-stable feedback control and sub-linear regret bandit routing, Q-TensorFormer achieves substantial empirical efficiency gains with rigorous mathematical guarantees.</p>
<p class="no-indent">All source code, verification test suites (107 passed unit tests), pre-trained checkpoints, and interactive demonstrations are publicly available at:</p><p class="no-indent">• Model Hub: https://huggingface.co/Premchan369/Q-TensorFormer</p><p class="no-indent">• Interactive Demo: https://huggingface.co/spaces/Premchan369/Q-TensorFormer</p>
<div class="ref-section"><h2>References</h2><div class="ref-item">[1] A. Vaswani et al., "Attention is all you need," in <i>Adv. Neural Inf. Process. Syst. (NeurIPS)</i>, 2017.</div><div class="ref-item">[2] E. J. Hu et al., "LoRA: Low-rank adaptation of large language models," in <i>Int. Conf. Learn. Represent. (ICLR)</i>, 2022.</div><div class="ref-item">[3] I. V. Oseledets, "Tensor-train decomposition," <i>SIAM J. Sci. Comput.</i>, vol. 33, no. 5, pp. 2295-2317, 2011.</div><div class="ref-item">[4] G. Xiao et al., "Efficient streaming language models with attention sinks," in <i>Int. Conf. Learn. Represent. (ICLR)</i>, 2024.</div><div class="ref-item">[5] Z. Liu et al., "KIVI: A tuning-free asymmetric 2bit quantization for KV cache," in <i>Int. Conf. Mach. Learn. (ICML)</i>, 2024.</div><div class="ref-item">[6] T. Dettmers et al., "LLM.int8(): 8-bit matrix multiplication for transformers at scale," in <i>Adv. Neural Inf. Process. Syst. (NeurIPS)</i>, 2022.</div><div class="ref-item">[7] M. Xia et al., "Sheared LLaMA: Accelerating language model pre-training via structured pruning," in <i>Int. Conf. Learn. Represent. (ICLR)</i>, 2024.</div><div class="ref-item">[8] D. Raposo et al., "Mixture-of-depths: Dynamically allocating compute in transformer-based language models," <i>arXiv preprint arXiv:2404.02258</i>, 2024.</div><div class="ref-item">[9] T. Schuster et al., "Confident adaptive language modeling," in <i>Adv. Neural Inf. Process. Syst. (NeurIPS)</i>, 2022.</div><div class="ref-item">[10] L. Li et al., "A contextual-bandit approach to personalized news headline recommendation," in <i>Proc. 19th Int. Conf. World Wide Web (WWW)</i>, 2010.</div></div>
</div>
</body></html>'''
html_content = raw_html.replace("__FIG1__", fig1_b64).replace("__FIG2__", fig2_b64).replace("__FIG3__", fig3_b64).replace("__FIG4__", fig4_b64)
with open(HTML_PATH, "w", encoding="utf-8") as f: f.write(html_content)
print(f"[1/2] Written HTML document: {HTML_PATH}")
# Render to PDF via Headless Chromechrome_paths = [ r"C:\Program Files\Google\Chrome\Application\chrome.exe", r"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe",]chrome_bin = Nonefor cp in chrome_paths: if os.path.exists(cp): chrome_bin = cp break
if not chrome_bin: print("[Error] Neither Chrome nor Edge executable found.") sys.exit(1)
print(f"[2/2] Compiling to PDF using: {chrome_bin}")cmd = [ chrome_bin, "--headless=new", "--disable-gpu", "--no-sandbox", "--run-all-compositor-stages-before-draw", "--virtual-time-budget=8000", f"--print-to-pdf={OUTPUT_PDF}", str(HTML_PATH),]
subprocess.run(cmd, check=True)
if OUTPUT_PDF.exists(): import shutil shutil.copyfile(OUTPUT_PDF, OUTPUT_PDF_ALT) size_kb = os.path.getsize(OUTPUT_PDF) / 1024 print("=" * 70) print(f"SUCCESS: Generated Camera-Ready IEEE Conference PDF ({size_kb:.1f} KB)") print(f"Output 1: {OUTPUT_PDF}") print(f"Output 2: {OUTPUT_PDF_ALT}") print("=" * 70)else: print("[Error] Failed to generate PDF.") sys.exit(1).gitattributes+1
paper/ieee_conference_6page_qtensorformer.pdfAdded+3
paper/ieee_conference_paper.htmlAdded
paper/q_tensorformer_ieee_paper.pdfAdded+3
scripts/generate_ieee_pdf.pyAdded+659