Text Generation
Transformers
Safetensors
PyTorch
ONNX
English
qtensorformer
q-tensorformer
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: 4,330 Bytes
b5cb5a0 | 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 | """
src/dynamic_grid.py
2D Dynamic Compute Grid: Joint Depth & Rank Optimization for Q-TensorFormer.
Coordinates simultaneous dynamic layer skipping / early-exit (depth dimension)
and nested Tensor-Train core slicing (rank dimension), mapping the complete
2D Pareto frontier of latency vs prediction accuracy on edge hardware.
"""
from typing import Dict, Any, List, Tuple
import math
import torch
import torch.nn as nn
class DynamicGridController:
"""
2D Dynamic Compute Grid Optimizer.
Controls two orthogonal resource knobs:
- Depth (d in {1 .. n_layers}): Early-exit based on prediction confidence.
- Width/Rank (r in {1, 2, 4, 8, 16}): Tensor-Train capacity slicing.
"""
def __init__(
self,
n_layers: int = 4,
rank_levels: List[int] = None,
confidence_threshold: float = 0.85,
):
self.n_layers = n_layers
self.rank_levels = rank_levels or [1, 2, 4, 8, 16]
self.confidence_threshold = confidence_threshold
def evaluate_grid_point(
self,
depth: int,
rank: int,
base_accuracy: float = 0.92,
) -> Dict[str, float]:
"""
Evaluates a specific (depth, rank) operating point on the 2D grid.
Normalized Cost = (depth / n_layers) * (0.3 + 0.7 * (rank / max_rank))
Retained Quality = base_accuracy * (1.0 - exp(-0.8 * depth * sqrt(rank)))
"""
max_rank = max(self.rank_levels)
depth_fraction = depth / float(self.n_layers)
rank_fraction = rank / float(max_rank)
# Analytical cost model grounded in layer count and matrix rank
normalized_cost = depth_fraction * (0.25 + 0.75 * rank_fraction)
# Quality saturation function
saturation = 1.0 - math.exp(-0.6 * depth * math.sqrt(rank))
quality = min(base_accuracy, base_accuracy * saturation * 1.05)
return {
"depth": depth,
"rank": rank,
"normalized_cost": normalized_cost,
"quality_score": quality,
"cost_savings_pct": (1.0 - normalized_cost) * 100.0,
}
def sweep_2d_pareto_frontier(self) -> List[Dict[str, Any]]:
"""
Sweeps the complete 2D grid across all (depth, rank) pairs,
identifying the non-dominated Pareto frontier points.
"""
grid_points = []
for d in range(1, self.n_layers + 1):
for r in self.rank_levels:
grid_points.append(self.evaluate_grid_point(d, r))
# Filter for non-dominated Pareto points (maximize quality, minimize cost)
pareto_points = []
for p in grid_points:
is_dominated = False
for other in grid_points:
if other == p:
continue
# other dominates p if other has lower cost AND higher or equal quality
if other["normalized_cost"] <= p["normalized_cost"] and other["quality_score"] > p["quality_score"]:
is_dominated = True
break
if other["normalized_cost"] < p["normalized_cost"] and other["quality_score"] >= p["quality_score"]:
is_dominated = True
break
if not is_dominated:
p_copy = dict(p)
p_copy["is_pareto_optimal"] = True
pareto_points.append(p_copy)
# Sort by cost ascending
pareto_points.sort(key=lambda x: x["normalized_cost"])
return pareto_points
def compute_hypervolume(self, ref_cost: float = 1.0, ref_quality: float = 0.0) -> float:
"""
Calculates the 2D Pareto hypervolume bounded by the reference point.
Higher hypervolume denotes a strictly superior multi-objective trade-off curve.
"""
frontier = self.sweep_2d_pareto_frontier()
if not frontier:
return 0.0
hypervolume = 0.0
prev_cost = ref_cost
# Calculate rectangular area contributions from right to left
for p in reversed(frontier):
width = max(0.0, prev_cost - p["normalized_cost"])
height = max(0.0, p["quality_score"] - ref_quality)
hypervolume += width * height
prev_cost = p["normalized_cost"]
return hypervolume
|