Metadata-Version: 2.4
Name: shifter-engine
Version: 0.1.0
Summary: Local inference engine and Shifter quantization library
License-Expression: Apache-2.0
Requires-Python: >=3.10
Requires-Dist: numpy<3,>=1.26
Requires-Dist: pydantic<3,>=2.11
Requires-Dist: PyYAML<7,>=6
Requires-Dist: huggingface-hub<3,>=1.1
Requires-Dist: tokenizers<1,>=0.21
Requires-Dist: jinja2<4,>=3.1.6
Requires-Dist: nvidia-cuda-runtime<14,>=13
Requires-Dist: nvidia-cublas<14,>=13
Provides-Extra: test
Requires-Dist: pytest<10,>=8; extra == "test"
Description-Content-Type: text/markdown

# Shifter Quantization — Massive Speedups for Local Inference with Hardware-Native Kernels

We built Shifter to run quantized language models on local GPUs and serve them
through an OpenAI-compatible chat API. We designed SQ and SHI to keep weights
compact in GPU memory and use native integer matrix operations for inference.
Shifter supports single-GPU, text-only serving on Linux with NVIDIA CUDA.

[Read the paper](https://arxiv.org/abs/2611.33080)

## Performance highlights

On one RTX 5090, we measured **32,039 prompt tokens/s** for Qwen3.6-35B-A3B
SQ4 with a 7,680-token prompt and **784 output tokens/s** on single-request
structured MTP3 decode. With eight requests decoding concurrently, we
measured **1,721.5 aggregate output tokens/s** versus **1,380.7** for NInfer
groupwise integer in the report's concurrent MTP3 benchmark.

For Qwen3.8-27B, we use 4,096-token prompts in the 2-bit and 8-bit comparisons
and the 7,680-token prompt from the NInfer repository in the 4-bit comparison.
We compare SHI2 against Bartowski's Q2_K checkpoint in llama.cpp, SQ4
against NInfer's groupwise INT checkpoint, and SQ8 against vLLM online FP8.

| Shifter format | │ | Shifter prefill (tok/s) | Baseline prefill (tok/s) | Prefill vs. baseline | │ | Shifter WikiText-2 KL | Baseline WikiText-2 KL | Baseline / Shifter KL |
| --- | :---: | ---: | ---: | ---: | :---: | ---: | ---: | ---: |
| 2-bit SHI2<br><sub>&nbsp;</sub> | │<br><sub>│</sub> | 11,662.4<br><sub>&nbsp;</sub> | 3,090.7<br><sub>(llama.cpp)</sub> | **3.77×**<br><sub>&nbsp;</sub> | │<br><sub>│</sub> | 0.15537<br><sub>&nbsp;</sub> | 0.16627<br><sub>(llama.cpp)</sub> | **1.07×**<br><sub>&nbsp;</sub> |
| 4-bit SQ4<br><sub>&nbsp;</sub> | │<br><sub>│</sub> | 8,221.9<br><sub>&nbsp;</sub> | 3,331.9<br><sub>(NInfer)</sub> | **2.47×**<br><sub>&nbsp;</sub> | │<br><sub>│</sub> | 0.01970<br><sub>&nbsp;</sub> | 0.03256<br><sub>(NInfer)</sub> | **1.65×**<br><sub>&nbsp;</sub> |
| 8-bit SQ8<br><sub>&nbsp;</sub> | │<br><sub>│</sub> | 9,206.3<br><sub>&nbsp;</sub> | 7,226.8<br><sub>(vLLM)</sub> | **+27.4%**<br><sub>&nbsp;</sub> | │<br><sub>│</sub> | 0.00211<br><sub>&nbsp;</sub> | 0.00774<br><sub>(vLLM)</sub> | **3.67×**<br><sub>&nbsp;</sub> |

## Quickstart

Activate your Python environment, then install Shifter and start the server.

```sh
pip install shifter-engine
shifter serve hif1000/Qwen3.8-27B-SQ4-GGUF
```

Your first launch downloads the model. Once the server is ready, send a test
request from another terminal.

```sh
curl -sS http://127.0.0.1:8000/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "hif1000/Qwen3.8-27B-SQ4-GGUF",
    "messages": [{"role": "user", "content": "What is the capital of France?"}],
    "chat_template_kwargs": {"enable_thinking": false},
    "max_tokens": 48,
    "temperature": 0
  }'
```

A successful response contains “Paris” in `choices[0].message.content`. See the
[serving flags](docs/serving.md#quick-start) for context size, concurrency, and MTP.

## Build from source

Check the [system requirements](#requirements-and-supported-models) and clone
the repository with your Python environment active.

```sh
git clone https://github.com/yufenghuang/shifter.git
cd shifter
```

For RTX 50-series GPUs, use the optimized Blackwell build.

```sh
pip install . -Ccmake.define.CMAKE_CUDA_ARCHITECTURES=120a
```

For other supported NVIDIA GPUs, use the default build.

```sh
pip install .
```

## Requirements and supported models

| Requirement | Supported configuration |
| --- | --- |
| Host | Linux x86-64 or AArch64 |
| GPU | One NVIDIA GPU with compute capability 8.0 or later and a driver compatible with the CUDA Toolkit |
| Python | 3.10 or later |
| Source build | C and C++20 compilers, CMake 3.28 or later, and CUDA Toolkit 13.2 or later in the 13.x series |
| GPU memory | Enough VRAM for the model weights and request state at your chosen context size and concurrency |

See the [installation guide](docs/install.md) for GPU-specific builds and troubleshooting.

We support text generation with compatible Shifter GGUF checkpoints for Qwen3.5
dense and MoE architectures. Serve a model by its Hugging Face ID or a local
GGUF path.

These GGUF checkpoints contain SQ and SHI tensor formats that require a
compatible reader.

| Hugging Face repository | WikiText-2 KL ↓ | RTX 5090 prefill (tok/s) | RTX 5090 structured MTP3 (tok/s) | RTX A6000 structured MTP3 (tok/s) |
| --- | ---: | ---: | ---: | ---: |
| [hif1000/Qwen3.8-27B-SQ2-GGUF](https://huggingface.co/hif1000/Qwen3.8-27B-SQ2-GGUF) | 0.15322 | 8,378.4 | — | 109.7 |
| [hif1000/Qwen3.8-27B-SHI2-GGUF](https://huggingface.co/hif1000/Qwen3.8-27B-SHI2-GGUF) | 0.15537 | 11,662.4 | — | 108.5 |
| [hif1000/Qwen3.8-27B-SQ4-GGUF](https://huggingface.co/hif1000/Qwen3.8-27B-SQ4-GGUF) | 0.01970 | 8,221.9 | 242.6 | 95.7 |
| [hif1000/Qwen3.8-27B-SHI4-GGUF](https://huggingface.co/hif1000/Qwen3.8-27B-SHI4-GGUF) | 0.01373 | 10,252.3 | 212.1 | 87.3 |
| [hif1000/Qwen3.8-27B-SQ8-GGUF](https://huggingface.co/hif1000/Qwen3.8-27B-SQ8-GGUF) | 0.00211 | 9,206.3 | — | 59.8 |
| [hif1000/Qwen3.6-35B-A3B-SQ4-GGUF](https://huggingface.co/hif1000/Qwen3.6-35B-A3B-SQ4-GGUF) | 0.01828 | 32,039.0 | 784.0 | 337.8 |

We report WikiText-2 KL and RTX 5090 throughput from the paper. The RTX 5090
prefill runs use 4,096-token prompts for 2-bit and 8-bit models and 7,680-token
prompts for 4-bit models. A dash indicates that the paper has no RTX 5090
structured MTP3 result for that model. We measured the RTX A6000 throughput separately. [Benchmark paper](https://arxiv.org/abs/2611.33080).

## SQ4 throughput across GPUs

We use NInfer's 7,680-token needle-retrieval prompt for prefill and its JSONL,
CSV, and SQL prompts for single-request structured MTP3 decode. On a
7,680-token prompt, Shifter SQ4 on an RTX 4090 prefills **30–83% faster**
than NInfer groupwise INT on an RTX 5090. The table below shows the measured
prefill and decode rates in tokens/s.

| GPU | Qwen3.8-27B prefill | Qwen3.8-27B decode | Qwen3.6-35B-A3B prefill | Qwen3.6-35B-A3B decode |
| --- | ---: | ---: | ---: | ---: |
| RTX A6000 (Shifter SQ4) | 2,723.8 | 97.0 | 10,828.8 | 331.0 |
| RTX 3090 (Shifter SQ4) | 2,915.7 | 111.5 | 11,354.8 | 391.9 |
| RTX 5090 (NInfer groupwise INT) | 3,331.9 | 214.7 | 17,705.4 | 779.6 |
| RTX 4090 (Shifter SQ4) | 6,098.7 | 148.9 | 23,093.3 | 532.3 |
| RTX 5090 (Shifter SQ4) | 8,221.9 | 242.6 | 32,039.0 | 784.0 |

Across the four GPUs we tested with Shifter, prefill throughput tracks peak dense INT8 TOPS
(R² = 0.987–0.992), and structured MTP3 decode throughput tracks memory
bandwidth (R² = 0.939–0.970). The dashed lines show linear fits.

![Four SQ4 scaling plots for 27B and 35B-A3B, with prefill against dense INT8 TOPS and structured MTP3 decode against memory bandwidth](docs/images/sq4-cross-gpu.png)

We describe our benchmark methods and report the full results in
[Shifter Quantization: Compact Representations for Native Integer Computation](https://arxiv.org/abs/2611.33080).

## Learn more

- [Install and troubleshoot](docs/install.md)
- [Choose a model and configure serving](docs/serving.md)
- [Contribute](CONTRIBUTING.md)
- [Release notes](CHANGELOG.md) and [security reporting](SECURITY.md)

We release Shifter under the [Apache License 2.0](LICENSE).
