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
Run this model with HF Jobs
Run Premchan369/Q-TensorFormer on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/Premchan369/Q-TensorFormer. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/Premchan369/Q-TensorFormer on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/Premchan369/Q-TensorFormer. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/Premchan369/Q-TensorFormer. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
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
feat: complete 6 frontier research extensions, empirical benchmarks, and 101-test suite
b5cb5a0 Download tests/test_frontier_research_suite.py from Premchan369/Q-TensorFormer: direct link, hf CLI and curl.
- Browser
- Download file 6.06 kB
-
https://huggingface.co/Premchan369/Q-TensorFormer/resolve/main/tests/test_frontier_research_suite.py
- Command line
-
hf download hf://Premchan369/Q-TensorFormer/tests/test_frontier_research_suite.py
-
curl -L -o test_frontier_research_suite.py https://huggingface.co/Premchan369/Q-TensorFormer/resolve/main/tests/test_frontier_research_suite.py
6.06 kB
| """ | |
| tests/test_frontier_research_suite.py | |
| Comprehensive test suite verifying the 6 frontier research modules: | |
| 1. Zero-SVD Self-Speculative Decoding (src/speculative_decoding.py) | |
| 2. Entropy-Gated Semantic Anchor KV Cache (src/semantic_kv_cache.py) | |
| 3. Fused Block-Tiled TT Contraction Engine (kernels/fused_tt_engine.py) | |
| 4. Contextual Bandit / RL Dynamic Allocator (src/bandit_allocator.py) | |
| 5. Salience-Gated Adaptive Vision Projector (src/adaptive_vision.py) | |
| 6. 2D Dynamic Compute Grid Controller (src/dynamic_grid.py) | |
| """ | |
| import sys | |
| from pathlib import Path | |
| # Ensure repo 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)) | |
| import pytest | |
| import torch | |
| import torch.nn as nn | |
| from src.config import ModelConfig | |
| from src.models import QTensorFormer | |
| from src.speculative_decoding import ZeroSVDSpeculativeDecoder | |
| from src.semantic_kv_cache import SemanticAnchorKVCache | |
| from kernels.fused_tt_engine import FusedTTEngine | |
| from src.bandit_allocator import ContextualBanditAllocator | |
| from src.adaptive_vision import AdaptiveVisionProjector | |
| from src.dynamic_grid import DynamicGridController | |
| def small_model(): | |
| cfg = ModelConfig( | |
| d_model=64, | |
| n_heads=2, | |
| n_layers=2, | |
| ff_multiplier=2, | |
| max_seq_len=64, | |
| vocab_size=256, | |
| tt_rank=4, | |
| tt_min_rank=1, | |
| use_quantum=False, | |
| ) | |
| model = QTensorFormer(cfg) | |
| model.eval() | |
| return model | |
| def test_zero_svd_speculative_decoding(small_model): | |
| """Verifies that ZeroSVDSpeculativeDecoder drafts and verifies without runtime errors.""" | |
| decoder = ZeroSVDSpeculativeDecoder( | |
| model=small_model, | |
| draft_rank=1, | |
| target_rank=4, | |
| lookahead_k=2, | |
| temperature=0.0, | |
| ) | |
| prompt = torch.tensor([[10, 20, 30]]) | |
| generated_ids, telemetry = decoder.generate(prompt, max_new_tokens=6) | |
| assert generated_ids.shape[0] == 1 | |
| assert generated_ids.shape[1] == 3 + 6 | |
| assert 0.0 <= telemetry["acceptance_rate"] <= 1.0 | |
| assert telemetry["total_drafted"] >= 1 | |
| assert telemetry["zero_extra_vram_overhead"] is True | |
| assert telemetry["scientific_classification"] == "MEASURED" | |
| def test_semantic_anchor_kv_cache_eviction(): | |
| """Verifies that SemanticAnchorKVCache retains sinks and high-entropy anchors while evicting fillers.""" | |
| cache = SemanticAnchorKVCache( | |
| max_capacity=8, | |
| sink_size=2, | |
| entropy_threshold=2.0, | |
| surprise_threshold=2.5, | |
| ) | |
| # Append 12 tokens: | |
| # Tokens 0, 1: Sinks (protected) | |
| # Token 4: High entropy anchor (protected) | |
| # Others: Low entropy fillers | |
| for i in range(12): | |
| k = torch.randn(1, 2, 1, 16) | |
| v = torch.randn(1, 2, 1, 16) | |
| ent = 3.5 if i == 4 else 0.5 | |
| surp = 4.0 if i == 4 else 0.2 | |
| res = cache.append(k, v, entropy=ent, surprise=surp) | |
| assert len(cache.keys) == 8 # Enforced max_capacity | |
| # Check that sinks (0, 1) and anchor (4) are still present in token_positions | |
| assert 0 in cache.token_positions | |
| assert 1 in cache.token_positions | |
| assert 4 in cache.token_positions | |
| def test_semantic_anchor_retrieval_retention(): | |
| """Verifies evaluate_retrieval_retention on needle positions.""" | |
| cache = SemanticAnchorKVCache(max_capacity=10, sink_size=2, entropy_threshold=2.0) | |
| for i in range(15): | |
| k = torch.randn(1, 2, 1, 16) | |
| v = torch.randn(1, 2, 1, 16) | |
| ent = 3.0 if i in [3, 7] else 0.2 | |
| cache.append(k, v, entropy=ent) | |
| stats = cache.evaluate_retrieval_retention(needle_positions=[3, 7]) | |
| assert stats["retention_rate"] == 1.0 | |
| assert stats["retained_needles"] == 2 | |
| def test_fused_tt_engine_arithmetic_intensity(): | |
| """Verifies that FusedTTEngine eliminates intermediate memory traffic.""" | |
| engine = FusedTTEngine(in_features=512, out_features=2048, rank=8) | |
| profile = engine.profile_arithmetic_intensity(batch_size=1, seq_len=32) | |
| assert profile["fused_total_memory_traffic_bytes"] < profile["unfused_total_memory_traffic_bytes"] | |
| assert profile["memory_traffic_reduction_pct"] > 0.0 | |
| assert profile["fused_arithmetic_intensity_flops_per_byte"] > profile["unfused_arithmetic_intensity_flops_per_byte"] | |
| assert profile["fused_advantage_multiplier"] > 1.0 | |
| def test_contextual_bandit_allocator(): | |
| """Verifies that ContextualBanditAllocator selects valid actions and updates LinUCB parameters.""" | |
| allocator = ContextualBanditAllocator(context_dim=8, n_actions=5, alpha=0.5) | |
| z_t = torch.tensor([0.8, 0.7, 0.4, 0.1, 0.5, 0.2, 0.3, 0.6]) | |
| action, telemetry = allocator.select_action(z_t) | |
| assert 0 <= action < 5 | |
| assert telemetry["chosen_rank"] in [1, 2, 4, 8, 16] | |
| assert telemetry["step"] == 1 | |
| reward = allocator.compute_reward(token_surprise=1.5, action_rank=telemetry["chosen_rank"]) | |
| allocator.update(z_t, action, reward) | |
| assert allocator.cumulative_reward == reward | |
| def test_adaptive_vision_projector(): | |
| """Verifies that AdaptiveVisionProjector partitions patches and yields compute savings.""" | |
| projector = AdaptiveVisionProjector( | |
| vis_dim=768, | |
| model_dim=256, | |
| max_rank=16, | |
| min_rank=2, | |
| salience_threshold=0.5, | |
| ) | |
| patches = torch.randn(1, 48, 768) | |
| projected, telemetry = projector(patches) | |
| assert projected.shape == (1, 48, 256) | |
| assert telemetry["total_patches"] == 48 | |
| assert telemetry["compute_savings_pct"] > 0.0 | |
| assert telemetry["effective_mean_rank"] <= 16.0 | |
| def test_dynamic_compute_grid(): | |
| """Verifies that DynamicGridController discovers the 2D Pareto frontier and positive hypervolume.""" | |
| grid = DynamicGridController(n_layers=4, rank_levels=[1, 2, 4, 8, 16]) | |
| frontier = grid.sweep_2d_pareto_frontier() | |
| assert len(frontier) >= 2 | |
| # Check that costs are strictly ascending | |
| costs = [p["normalized_cost"] for p in frontier] | |
| assert costs == sorted(costs) | |
| hypervolume = grid.compute_hypervolume() | |
| assert hypervolume > 0.0 | |