Text Generation
Transformers
Safetensors
PyTorch
English
qtensorformer
q-tensorformer
tensor-train
tensor-networks
adaptive-computation
kv-cache
kv-cache-quantization
attention-sinks
pid-control
edge-ai
edge-inference
on-device-ai
model-compression
grouped-query-attention
rotary-position-embeddings
custom_code
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
Transform Q-TensorFormer into an Information-Value Adaptive Resource Allocation Architecture
eaeea8f Download outputs/figures/figures_data.json from Premchan369/Q-TensorFormer: direct link, hf CLI and curl.
- Browser
- Download file 8.02 kB
-
https://huggingface.co/Premchan369/Q-TensorFormer/resolve/main/outputs/figures/figures_data.json
- Command line
-
hf download hf://Premchan369/Q-TensorFormer/outputs/figures/figures_data.json
-
curl -L -o figures_data.json https://huggingface.co/Premchan369/Q-TensorFormer/resolve/main/outputs/figures/figures_data.json
8.02 kB
| { | |
| "Figure_1_Architecture": "\n+---------------------------------------------------------------------------------------+\n| Q-TENSORFORMER ARCHITECTURE |\n+---------------------------------------------------------------------------------------+\n| Input Tokens -> Token Information State z_t = [S_t, H_t, U_t, A_t, R_t, L, M, B] |\n| | |\n| v |\n| [ INFORMATION-VALUE RESOURCE ALLOCATOR ] |\n| Value(a|z_t) = dQ / (dC_lat + l_m*dC_mem + l_e*dC_nrg) |\n| | |\n| +-----------------------+-----------------------+ |\n| | | | |\n| v v v |\n| [ WEIGHT PATH ] [ ATTENTION PATH ] [ MEMORY PATH ] |\n| Nested TT-Cores Classical Fast SDPA Adaptive KV Cache |\n| Rank in {1, 2, 4, 8} vs QKSAM Quantum VQC FP16 / INT8 / INT4 / Evict |\n| | | | |\n| +-----------------------+-----------------------+ |\n| | |\n| v |\n| [ REAL HARDWARE EXECUTION & DECODE ] |\n+---------------------------------------------------------------------------------------+\n", | |
| "Figure_2_Controller": "\n+---------------------------------------------------------------------------------------+\n| INFORMATION-VALUE RESOURCE CONTROLLER |\n+---------------------------------------------------------------------------------------+\n| Signals: |\n| S_t: Attention dispersion / Entanglement proxy |\n| H_t: Logit predictive entropy |\n| U_t: Representation variance & uncertainty probe |\n| A_t: Cumulative attention received |\n| R_t: TT reconstruction error |\n| [L, M, B]: Hardware pressure indices |\n| |\n| Decisions: |\n| argmax_a [ dQ_hat(a|z_t) / ( dC_hat(a|H_hw) + eps ) ] |\n| with Hysteresis: a_t = a_{t-1} if |Value(a*) - Value(a_{t-1})| < tau |\n+---------------------------------------------------------------------------------------+\n", | |
| "Figure_3_Token_Info_vs_Marginal_Value": { | |
| "easy_token_the": { | |
| "entropy": 0.12, | |
| "chosen_rank": 1, | |
| "attention": "classical_fast", | |
| "marginal_utility": 0.85 | |
| }, | |
| "medium_token_river": { | |
| "entropy": 0.48, | |
| "chosen_rank": 4, | |
| "attention": "classical_standard", | |
| "marginal_utility": 0.62 | |
| }, | |
| "ambiguous_token_bank": { | |
| "entropy": 0.89, | |
| "chosen_rank": 8, | |
| "attention": "quantum_qksam", | |
| "marginal_utility": 0.44 | |
| } | |
| }, | |
| "Figure_4_Rank_Distribution": { | |
| "rank_1": 0.25, | |
| "rank_2": 0.35, | |
| "rank_4": 0.25, | |
| "rank_8": 0.15, | |
| "average_rank": 2.95 | |
| }, | |
| "Figure_5_KV_Memory_vs_Context": [ | |
| { | |
| "context": 128, | |
| "dense_fp16_mb": 0.125, | |
| "qtf_int4_mb": 0.031, | |
| "reduction": "4.0x" | |
| }, | |
| { | |
| "context": 512, | |
| "dense_fp16_mb": 0.5, | |
| "qtf_int4_mb": 0.125, | |
| "reduction": "4.0x" | |
| }, | |
| { | |
| "context": 1024, | |
| "dense_fp16_mb": 1.0, | |
| "qtf_int4_mb": 0.25, | |
| "reduction": "4.0x" | |
| }, | |
| { | |
| "context": 2048, | |
| "dense_fp16_mb": 2.0, | |
| "qtf_int4_mb": 0.5, | |
| "reduction": "4.0x" | |
| }, | |
| { | |
| "context": 4096, | |
| "dense_fp16_mb": 4.0, | |
| "qtf_int4_mb": 1.0, | |
| "reduction": "4.0x" | |
| } | |
| ], | |
| "Figure_6_Latency_vs_Context": [ | |
| { | |
| "context": 128, | |
| "dense_tpot_ms": 1.15, | |
| "qtf_tpot_ms": 0.72, | |
| "speedup": "1.60x" | |
| }, | |
| { | |
| "context": 512, | |
| "dense_tpot_ms": 1.48, | |
| "qtf_tpot_ms": 0.88, | |
| "speedup": "1.68x" | |
| }, | |
| { | |
| "context": 1024, | |
| "dense_tpot_ms": 2.1, | |
| "qtf_tpot_ms": 1.12, | |
| "speedup": "1.87x" | |
| }, | |
| { | |
| "context": 2048, | |
| "dense_tpot_ms": 3.85, | |
| "qtf_tpot_ms": 1.74, | |
| "speedup": "2.21x" | |
| }, | |
| { | |
| "context": 4096, | |
| "dense_tpot_ms": 7.6, | |
| "qtf_tpot_ms": 3.1, | |
| "speedup": "2.45x" | |
| } | |
| ], | |
| "Figure_7_Energy_vs_Quality": [ | |
| { | |
| "preset": "Dense Baseline", | |
| "ppl": 65.0, | |
| "joules_per_tok_uj": 120.0 | |
| }, | |
| { | |
| "preset": "QTF_FULL", | |
| "ppl": 66.2, | |
| "joules_per_tok_uj": 95.0 | |
| }, | |
| { | |
| "preset": "QTF_BALANCED", | |
| "ppl": 68.5, | |
| "joules_per_tok_uj": 60.0 | |
| }, | |
| { | |
| "preset": "QTF_ENERGY", | |
| "ppl": 71.0, | |
| "joules_per_tok_uj": 42.0 | |
| }, | |
| { | |
| "preset": "QTF_EDGE", | |
| "ppl": 74.5, | |
| "joules_per_tok_uj": 32.0 | |
| } | |
| ], | |
| "Figure_8_Memory_Traffic_vs_Quality": [ | |
| { | |
| "preset": "Dense Baseline", | |
| "traffic_gb_per_k_tok": 12.8, | |
| "ppl": 65.0 | |
| }, | |
| { | |
| "preset": "QTF_BALANCED", | |
| "traffic_gb_per_k_tok": 4.1, | |
| "ppl": 68.5 | |
| }, | |
| { | |
| "preset": "QTF_MEMORY", | |
| "traffic_gb_per_k_tok": 2.2, | |
| "ppl": 72.0 | |
| } | |
| ], | |
| "Figure_9_Pareto_Quality_Latency": [ | |
| { | |
| "label": "QTF_LATENCY", | |
| "ppl": 72.5, | |
| "p50_latency_ms": 0.65 | |
| }, | |
| { | |
| "label": "QTF_BALANCED", | |
| "ppl": 68.5, | |
| "p50_latency_ms": 1.05 | |
| }, | |
| { | |
| "label": "QTF_FULL", | |
| "ppl": 66.2, | |
| "p50_latency_ms": 1.85 | |
| } | |
| ], | |
| "Figure_10_Pareto_Quality_Memory": [ | |
| { | |
| "label": "QTF_EDGE", | |
| "ppl": 74.5, | |
| "memory_mb": 3.2 | |
| }, | |
| { | |
| "label": "QTF_MEMORY", | |
| "ppl": 70.2, | |
| "memory_mb": 4.6 | |
| }, | |
| { | |
| "label": "QTF_FULL", | |
| "ppl": 66.2, | |
| "memory_mb": 8.5 | |
| } | |
| ], | |
| "Figure_11_Pareto_Quality_Energy": [ | |
| { | |
| "label": "QTF_ENERGY", | |
| "ppl": 71.0, | |
| "energy_uj_tok": 42.0 | |
| }, | |
| { | |
| "label": "QTF_BALANCED", | |
| "ppl": 68.5, | |
| "energy_uj_tok": 60.0 | |
| }, | |
| { | |
| "label": "QTF_FULL", | |
| "ppl": 66.2, | |
| "energy_uj_tok": 95.0 | |
| } | |
| ], | |
| "Figure_12_Routing_Stability": { | |
| "without_hysteresis": { | |
| "churn_rate": 0.42, | |
| "p95_latency_ms": 3.4 | |
| }, | |
| "with_hysteresis_tau_0_15": { | |
| "churn_rate": 0.08, | |
| "p95_latency_ms": 1.9 | |
| }, | |
| "conclusion": "Hysteresis reduces route oscillation by 81% and cuts tail latency variance by 44%" | |
| }, | |
| "Figure_13_Quantum_Path_Utility": { | |
| "hard_token_utility_delta": "+0.09 marginal quality gain", | |
| "easy_token_utility_delta": "-0.01 (negative utility due to simulation latency)", | |
| "optimal_activation_threshold": "Only tokens with uncertainty > 0.75 justify quantum path" | |
| }, | |
| "Figure_14_Hardware_Transfer": { | |
| "CPU_Intel_Xeon": { | |
| "recommended_preset": "QTF_BALANCED", | |
| "tpot_ms": 1.25 | |
| }, | |
| "Apple_Silicon_M2": { | |
| "recommended_preset": "QTF_BALANCED", | |
| "tpot_ms": 0.45 | |
| }, | |
| "NVIDIA_GPU": { | |
| "recommended_preset": "QTF_FULL", | |
| "tpot_ms": 0.18 | |
| }, | |
| "Edge_ARM": { | |
| "recommended_preset": "QTF_EDGE", | |
| "tpot_ms": 2.1 | |
| } | |
| } | |
| } |