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
File size: 10,097 Bytes
dca6b4b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | """
src/cli.py
Unified Command-Line Interface (CLI) for Q-TensorFormer (QTF).
Provides single-command access to all core engines:
- qtf info: System and project metadata, authorship, and paper links
- qtf serve: High-throughput OpenAI-compatible streaming API server
- qtf convert: Foundation model post-training SVD Tensor-Train decomposition
- qtf benchmark: Multi-step reasoning and scientific benchmark runner
- qtf telemetry: Live physical CPU/GPU/battery telemetry sensor inspection
- qtf onnx: Standalone edge ONNX inference pipeline
- qtf audit: Automated scientific integrity and SEO quality gates
"""
import sys
import os
import argparse
import json
import time
from pathlib import Path
# Ensure repository root is on sys.path
REPO_ROOT = Path(__file__).resolve().parent.parent
if str(REPO_ROOT) not in sys.path:
sys.path.insert(0, str(REPO_ROOT))
def print_banner():
banner = r"""
____ _____ ______
/ __ \ |_ _|__ _ __ ___ ___ _ __ | ____|
| | | |____ | |/ _ \ '_ \/ __|/ _ \| '__|_____| |__ ___ _ __ _ __ ___ ___ _ __
| | | |____| | | __/ | | \__ \ (_) | | |______| __/ _ \| '__| '_ ` _ \ / _ \ '__|
\__\_\| |_|\___|_| |_|___/\___/|_| |_| \___/|_| |_| |_| |_|\___/_|
Q-TensorFormer (QTF) Enterprise CLI
Real-Time High-Throughput Edge LLM Inference Architecture
Authors: Dr. Madala Guru Brahmam & V C Premchand Yadav (VIT-AP University)
"""
print(banner)
def cmd_info(args):
"""Displays project information, hardware status, and paper metadata."""
print_banner()
print("Project: Q-TensorFormer (QTF)")
print("Canonical Repository: https://huggingface.co/Premchan369/Q-TensorFormer")
print("Interactive Space: https://huggingface.co/spaces/Premchan369/Q-TensorFormer")
print("Documentation: https://premchan369.github.io/Q-TensorFormer/")
print("Research Paper (PDF): https://huggingface.co/Premchan369/Q-TensorFormer/resolve/main/paper/q_tensorformer_ieee_paper.pdf")
print("Authors: Dr. Madala Guru Brahmam (1st) & V C Premchand Yadav (2nd)")
print("Affiliation: School of Computer Science and Engineering (SCOPE), VIT-AP University, India")
print("License: Apache-2.0")
print("Status: 127 Unit Tests Passing (100% Pass Rate)")
print("-" * 75)
from src.hardware_telemetry import LiveHardwareTelemetrySensor
sensor = LiveHardwareTelemetrySensor()
snap = sensor.snapshot()
print(f"Host CPU: {snap.cpu_utilization_pct:.1f}% load ({snap.cpu_freq_current_mhz:.0f} MHz)")
print(f"Host RAM: {snap.ram_used_gb:.2f} GB used / {snap.ram_total_gb:.2f} GB total ({snap.ram_percent:.1f}%)")
print(f"GPU Accelerator: {'Active (' + str(snap.gpu_temperature_c) + ' C)' if snap.has_nvidia_gpu else 'Standard Host / CPU mode'}")
print(f"Recommended TT Rank: Rank {snap.recommended_tt_rank} (Risk: {snap.thermal_throttling_risk})")
print("-" * 75)
def cmd_serve(args):
"""Launches the OpenAI-compatible FastAPI serving gateway."""
print_banner()
print(f"Launching QTF OpenAI-Compatible Gateway on {args.host}:{args.port}...")
import uvicorn
from src.api_server import app
uvicorn.run(app, host=args.host, port=args.port, log_level="info")
def cmd_convert(args):
"""Converts a dense weight matrix or linear layer into nested Tensor-Train cores."""
print_banner()
import torch
import torch.nn as nn
from src.realworld_llm_converter import RealWorldLLMConverter
print(f"Running post-training SVD TT-decomposition for {args.in_features}x{args.out_features} (max_rank={args.max_rank})...")
converter = RealWorldLLMConverter(max_rank=args.max_rank)
linear = nn.Linear(args.in_features, args.out_features)
tt_linear = converter.convert_linear_layer(linear, max_rank=args.max_rank)
stats = converter.conversion_stats.get(f"{args.in_features}x{args.out_features}", {})
print(f"[SUCCESS] Decomposed into 3 nested TT-cores:")
for idx, c in enumerate(tt_linear.cores):
print(f" Core {idx + 1}: shape {list(c.shape)}")
print(f" Compression Ratio: {stats.get('compression_ratio', 0.0):.2f}x")
print(f" Parameter Reduction: {stats.get('param_reduction_pct', 0.0):.2f}%")
print(f" Singular Energy Retained: {stats.get('singular_energy_retained_pct', 0.0):.2f}%")
print(f" Contraction Error: {stats.get('frobenius_rel_error', 0.0):.6f}")
def cmd_benchmark(args):
"""Runs designated benchmark suite."""
print_banner()
if args.task == "reasoning":
print("Executing Multi-Step Reasoning Token Complexity Benchmark (GSM8K, Code, Logic)...")
from scripts.run_reasoning_benchmark import main as run_reasoning
run_reasoning()
elif args.task == "scientific":
print("Executing Master 14-Architecture Scientific Benchmark Suite...")
from scripts.run_scientific_benchmark import main as run_scientific
run_scientific()
elif args.task == "statistical":
print("Executing NeurIPS & IEEE 50-Trial Statistical Significance Evaluation...")
from scripts.run_neurips_evaluation import main as run_neurips
run_neurips()
else:
print(f"Unknown benchmark task: {args.task}. Choices: reasoning, scientific, statistical")
def cmd_telemetry(args):
"""Polls real-time hardware telemetry and closed-loop control recommendations."""
print_banner()
from src.hardware_telemetry import LiveHardwareTelemetrySensor
sensor = LiveHardwareTelemetrySensor()
if args.watch:
print("Watching live hardware telemetry (Press Ctrl+C to exit)...")
try:
while True:
snap = sensor.snapshot()
print(f"\r[Telemetry] CPU: {snap.cpu_utilization_pct:5.1f}% | RAM: {snap.ram_percent:5.1f}% | Pressure: {snap.hardware_pressure_score:.2f} | Risk: {snap.thermal_throttling_risk:<8} | Recommended: Rank {snap.recommended_tt_rank}", end="", flush=True)
time.sleep(args.interval)
except KeyboardInterrupt:
print("\nMonitoring stopped.")
else:
snap = sensor.snapshot()
print(json.dumps(snap.__dict__, indent=2, default=str))
def cmd_onnx(args):
"""Executes standalone edge ONNX runner."""
print_banner()
print("Launching Standalone Edge ONNX Inference Runner...")
from scripts.run_onnx_edge import main as run_onnx
sys.argv = [sys.argv[0], f"--rank={args.rank}", f"--sequence-length={args.sequence_length}"]
run_onnx()
def cmd_audit(args):
"""Executes scientific integrity checker and SEO audit quality gates."""
print_banner()
print("Running Automated Scientific Integrity Audit...")
from scripts.scientific_integrity_checker import run_integrity_audit
int_ok = run_integrity_audit(REPO_ROOT)
print("\nRunning Automated Technical SEO Quality Gate...")
from scripts.seo_audit import run_seo_audit
seo_ok = run_seo_audit(REPO_ROOT)
if int_ok and seo_ok:
print("\n[ALL AUDITS PASSED] Repository is 100% compliant with publication and search standards.")
else:
print("\n[AUDIT FAILURE] Detected defects. Please inspect error logs above.")
sys.exit(1)
def main():
parser = argparse.ArgumentParser(
prog="qtf",
description="Q-TensorFormer (QTF) Unified CLI: Real-Time High-Throughput Edge LLM Inference Architecture",
)
subparsers = parser.add_subparsers(dest="command", help="Available QTF commands")
# info
p_info = subparsers.add_parser("info", help="Display project information, hardware status, and paper metadata")
p_info.set_defaults(func=cmd_info)
# serve
p_serve = subparsers.add_parser("serve", help="Launch OpenAI-compatible streaming API server")
p_serve.add_argument("--host", type=str, default="0.0.0.0", help="Binding host address (default: 0.0.0.0)")
p_serve.add_argument("--port", type=int, default=8000, help="Binding port (default: 8000)")
p_serve.set_defaults(func=cmd_serve)
# convert
p_convert = subparsers.add_parser("convert", help="Convert dense linear weights into nested Tensor-Train cores")
p_convert.add_argument("--in-features", type=int, default=512, help="Input feature dimension")
p_convert.add_argument("--out-features", type=int, default=2048, help="Output feature dimension")
p_convert.add_argument("--max-rank", type=int, default=8, help="Maximum TT-rank budget")
p_convert.set_defaults(func=cmd_convert)
# benchmark
p_bench = subparsers.add_parser("benchmark", help="Execute empirical reasoning or scientific benchmarks")
p_bench.add_argument("--task", type=str, default="reasoning", choices=["reasoning", "scientific", "statistical"], help="Benchmark task to execute")
p_bench.set_defaults(func=cmd_benchmark)
# telemetry
p_telem = subparsers.add_parser("telemetry", help="Inspect real-time physical accelerator and system telemetry")
p_telem.add_argument("--watch", action="store_true", help="Continuously stream live telemetry to terminal")
p_telem.add_argument("--interval", type=float, default=1.0, help="Polling interval in seconds")
p_telem.set_defaults(func=cmd_telemetry)
# onnx
p_onnx = subparsers.add_parser("onnx", help="Execute standalone edge ONNX runner")
p_onnx.add_argument("--rank", type=int, default=4, help="Active TT-rank")
p_onnx.add_argument("--sequence-length", type=int, default=16, help="Sequence length")
p_onnx.set_defaults(func=cmd_onnx)
# audit
p_audit = subparsers.add_parser("audit", help="Run scientific integrity and SEO quality audits")
p_audit.set_defaults(func=cmd_audit)
args = parser.parse_args()
if not args.command:
cmd_info(args)
else:
args.func(args)
if __name__ == "__main__":
main()
|