VAR-Q is a lightweight KV-cache quantization method for efficient visual autoregressive generation. It reduces inference-time KV-cache memory while preserving generation quality, and is designed to attach to existing visual autoregressive model implementations without modifying their source code.
This smoke path does not require third-party backends, checkpoints, or datasets.
git clone https://github.com/lujiaji/VAR-Q.git
cd VAR-Q
git checkout varq_official
# Install PyTorch first from https://pytorch.org/get-started/locally/
pip install -e .
python examples/smoke_quant_roundtrip.py
python examples/smoke_pack_unpack.py
python examples/smoke_hook_mock_attention.py
For development checks:
pip install -e ".[dev]"
pytest tests/
VAR-Q is a runtime KV-cache quantization method for visual autoregressive generation. It quantizes K/V cache tensors created during inference; it is not a weight-only quantization method.
Weight quantization methods such as GPTQ, AWQ, and related approaches are orthogonal to VAR-Q. In principle, a backend can combine weight-only quantization for model parameters with VAR-Q for runtime KV-cache memory.
VARQ, all G_* grouping variants, ratio-controlled grouping, pre-RoPE control, and low-bit KV cache packing/unpacking.ablation/ and are installed as an optional comparison package alongside VAR_Q.Reported A100-80GB evaluations show approximately 75% KV-cache reduction at INT4 and up to 87% at INT2. The reduced cache enables substantially larger full-generation batches across image and video backends.
| Model | INT4 KV-cache reduction | BF16 max batch | Largest verified VAR-Q batch |
|---|---|---|---|
| Infinity-8B | 74.8% | 3 | 16 (INT4), 22 (INT2) |
| Self-Forcing | 74.9% | 8 | 16 (INT4) |
| LongLive | 74.9% | 4 | 8 (INT3) |
| InfinityStar-480p | 73.5% | 1 | 3 (INT2) |
| VAR-d30 | 72.9% | 134 | 543 (INT2) |
For Infinity-8B, the effective compression ratios below include scale metadata:
| KV precision | Effective KV compression |
|---|---|
| INT4 | 3.97x |
| INT3 | 4.95x |
| INT2 | 7.88x |
KV-cache reduction refers to persistent K/V storage rather than whole-process peak GPU allocation. Maximum batch is the largest completed full-generation run under each reported precision.
On Infinity-8B at batch size 1, fusing packed-KV loading, unpacking, and dequantization into attention reduces both attention-path and end-to-end latency relative to the same quantized runtime without fusion:
| KV precision | Attention, unfused -> fused | Attention improvement | E2E, unfused -> fused | E2E improvement |
|---|---|---|---|---|
| INT8 | 1951 -> 1603 ms | 17.8% | 3973 -> 3627 ms | 8.7% |
| INT4 | 1999 -> 1583 ms | 20.8% | 4012 -> 3596 ms | 10.4% |
The speedups above compare fused and unfused quantized execution. They do not claim that quantized execution is faster than the BF16 reference (3164 ms E2E).
| Backend | Upstream repository | Default checkout | Integration path |
|---|---|---|---|
| VAR | https://github.com/FoundationVision/VAR | third_party/VAR | Automatic runtime hook |
| Infinity | https://github.com/FoundationVision/Infinity | third_party/Infinity | Automatic runtime hook |
| InfinityStar | https://github.com/FoundationVision/InfinityStar | third_party/InfinityStar | Automatic runtime hook |
| LiveTalk | https://github.com/ChenhongyiYang/LiveTalk | third_party/LiveTalk | Automatic runtime hook |
| Self-Forcing | https://github.com/guandeh17/Self-Forcing | third_party/Self-Forcing | Automatic packed-KV hook |
| LongLive | https://github.com/NVlabs/LongLive | third_party/LongLive | Automatic segmented packed-KV hook |
All listed entrypoints install hooks at runtime and do not require a committed patch to their upstream repositories. Standard Wan2.1/Wan2.2 diffusion is not listed because it does not maintain a persistent autoregressive KV cache.
For backends using the general hook router, VAR-Q and ablation methods are selected through the same attachment point while their quantization implementations remain isolated: VAR-Q is implemented in VAR_Q/, and comparisons remain in ablation/.
VAR-Q/
├── VAR_Q/ # VAR-Q core and runtime hooks
│ ├── quant.py # VARQ, G_* grouping, ratio logic, pre-RoPE control
│ ├── pack_unpack.py # Low-bit pack/unpack utilities
│ ├── config_loader.py # Public JSON normalization
│ ├── paths.py # Relative third-party path helpers
│ ├── fused/ # Packed-KV attention Python API
│ ├── csrc/ # CUDA quant/pack/unpack/attention extension
│ └── hooks/ # Model hook installers
├── ablation/ # KIVI / FLexGen / KVQuant implementations
├── Benchmark/ # Public evaluation entrypoints
├── configs/ # Curated JSON configs
├── docs/ # Public documentation
├── examples/ # No-checkpoint smoke demos
├── scripts/ # Public inference and evaluation launchers
├── tests/ # Lightweight public smoke tests
├── third_party/README.md # Upstream checkout instructions
├── requirements-varq.txt # Lightweight VAR-Q convenience environment
├── pyproject.toml # Editable install metadata
└── LICENSE
Ignored local-only paths include third_party/, temp/, benchmark outputs, model weights, generated media, and test output/tmp directories. The lightweight tests/ suite is part of the public repository.
Clone VAR-Q and check out the public branch:
git clone https://github.com/lujiaji/VAR-Q.git
cd VAR-Q
git checkout varq_official
Install PyTorch first, matching your CUDA driver and runtime. Follow the official PyTorch selector rather than relying on VAR-Q to pin a wheel:
# Example only. Choose the command for your CUDA version from:
# https://pytorch.org/get-started/locally/
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121
Install VAR-Q in editable mode:
conda activate <your-backend-env>
pip install -e .
Build the bundled CUDA extension before CUDA inference:
bash scripts/bench/build_fused_flash.sh
import VAR_Q and the CPU reference path remain available on CPU-only hosts;
CUDA tensors never fall back to Triton or a Python pack/unpack implementation.
For a non-editable minimal convenience install after PyTorch is already installed, requirements-varq.txt is retained:
pip install -r requirements-varq.txt
VAR-Q itself only needs PyTorch for CPU import/reference use and a compatible CUDA toolchain for CUDA inference. VAR, Infinity, InfinityStar, Self-Forcing, and LongLive may pin different CUDA, PyTorch, flash-attn, xformers, tokenizer, or evaluation package versions; install those dependencies inside each official upstream repository instead of putting them into the VAR-Q root environment metadata.
| Component | Environment | Notes |
|---|---|---|
| VAR-Q core smoke tests | Python 3.10, PyTorch | CPU works for public tests; CUDA extension tests run when CUDA is available. |
| VAR / Infinity / InfinityStar | Follow official backend environments | Install VAR-Q with pip install -e . inside the backend env. |
| Self-Forcing / LongLive | Follow official backend environments | Video stacks may require separate CUDA/PyTorch package sets. |
| CI | Ubuntu latest, Python 3.10 | Runs only py_compile and public smoke tests. |
Clone upstream repositories into third_party/:
git clone https://github.com/FoundationVision/VAR third_party/VAR
git clone https://github.com/FoundationVision/Infinity third_party/Infinity
git clone https://github.com/FoundationVision/InfinityStar third_party/InfinityStar
git clone https://github.com/ChenhongyiYang/LiveTalk third_party/LiveTalk
git clone https://github.com/guandeh17/Self-Forcing third_party/Self-Forcing
git clone https://github.com/NVlabs/LongLive third_party/LongLive
VAR-Q does not vendor third-party source or distribute patch files. Public launchers load the backend model and install hooks in memory.
Checkpoints are intentionally not stored in JSON configs. Provide them through command-line arguments, environment variables, or the upstream backend's native loader.
Third-party backends, checkpoints, datasets, and generated assets are not distributed with this repository. They are governed by their own licenses and usage terms.
VAR-Q follows a SmoothQuant-style runtime replacement design. The installer scans supported attention modules, stores the original methods in a handle, and replaces the instance-level KV-cache path in memory.
from VAR_Q.hooks import install_varq_hooks, remove_varq_hooks
handle = install_varq_hooks(
model,
model_type="var", # "var", "infinity", or "infinitystar"
quant_config={
"enable": True,
"q_bits": 4,
"quant_method": "VARQ",
"qkv_format": "BLHc",
"pack_to_int32": True,
},
)
# Run backend inference.
remove_varq_hooks(handle)
Use quant_method="VARQ" or any G_* method for the main method. Use KIVI, FLexGen, or KVQuant in public configs for ablations; the loader normalizes them to isolated ablation implementations.
LiveTalk uses a dedicated hook installer for its chunk-overwrite cache semantics:
from VAR_Q.hooks import install_livetalk_hooks, remove_livetalk_hooks
handle = install_livetalk_hooks(pipeline, quant_config)
# Run LiveTalk generation.
remove_livetalk_hooks(handle)
Self-Forcing and LongLive expose direct installers. Their launchers call these automatically after the upstream pipeline has been constructed:
from VAR_Q.hooks import install_longlive_hooks, install_self_forcing_hooks
sf_handle = install_self_forcing_hooks(sf_pipeline, "configs/self_forcing/varq/base/SF-VARQ-4.json")
ll_handle = install_longlive_hooks(ll_pipeline, "configs/longlive/varq/base/LL-VARQ-4.json")
The underlying VideoKVCacheAdapter remains available as an integration API
for additional causal video models.
VAR-Q reduces active cache allocations in addition to reporting packed byte counts:
expected_total_seq_len and preallocate_kv_cache when the generation length is known.quant_compute_dtype="native" and dequant_dtype="native" avoid unnecessary full-size FP32 or cast temporaries.dequant_workspace_policy="release" avoids retaining dense dequant workspaces between attention calls.For memory measurements, enable the entrypoint's profiling option where available. Reports include packed K/V bytes, scale bytes, dequant workspace bytes, and PyTorch allocated/reserved peaks. Compare backends using identical prompts, generation schedules, batch size, dtype, and a clean CUDA device.
All public scripts resolve paths relative to the VAR-Q repository root.
VAR:
export VARQ_VAE_CKPT=/path/to/vae_ch160v4096z32.pth
export VARQ_VAR_CKPT_TEMPLATE='/path/to/var_d{}.pth'
bash scripts/inference_VAR.sh configs/var/varq/base/VAR-VARQ-8.json scripts/output/var
Infinity:
export INFINITY_MODEL_PATH=/path/to/infinity_model
export INFINITY_TEXT_ENCODER_CKPT=/path/to/text_encoder
export INFINITY_PN=1M
bash scripts/inference_Infinity.sh \
configs/infinity/varq/base/Infinity-VARQ-8.json \
"a cinematic photograph of a red fox in snow" \
scripts/output/infinity.png
InfinityStar:
export INFINITYSTAR_CHECKPOINTS_DIR=/path/to/infinitystar/checkpoints
bash scripts/inference_InfinityStar.sh \
configs/infinitystar/varq/base/InfinityStar-VARQ-8.json \
--output scripts/output/infinitystar_varq_demo.mp4
Self-Forcing runs its upstream inference.py by default. Arguments after --
are forwarded directly to that script:
bash scripts/inference_SelfForcing.sh \
configs/self_forcing/varq/base/SF-VARQ-4.json \
-- <upstream inference arguments>
LongLive follows the same pattern:
bash scripts/inference_LongLive.sh \
configs/longlive/varq/base/LL-VARQ-4.json \
-- <upstream inference arguments>
LiveTalk:
bash scripts/inference_LiveTalk.sh 4 -- \
--checkpoint_root /path/to/livetalk/checkpoints \
--output scripts/output/livetalk_varq_demo.mp4
If a required third-party checkout is missing, launchers fail early and print the expected third_party/<repo> path.
VAR evaluation:
bash scripts/eval_VAR.sh \
configs/var/varq/base/VAR-VARQ-8.json \
/path/to/VIRTUAL_imagenet256_labeled.npz
Infinity evaluation:
bash scripts/eval_Infinity.sh geneval \
configs/infinity/varq/base/Infinity-VARQ-8.json
Supported Infinity evaluation tasks are geneval, dpg, and imagereward.
Curated JSON configs live under:
configs/<backend>/<family>/<topic>/*.json
The quantization block is intentionally backend-agnostic and can be reused when calling install_varq_hooks(...) directly. Full JSON files are still kept per backend because model loaders use different qkv_format, sequence layout, image/video schedule, and grouping defaults.
See docs/configs.md for a concise field reference.
Retained public configs include:
| Backend | VAR-Q configs | Ablation configs | Extra configs |
|---|---|---|---|
| VAR | 8/6/4/3-bit | KIVI 4-bit, FLexGen 4-bit | G_HEAD_DIM |
| Infinity | 8/6/4/3/2-bit | KIVI 4-bit, FLexGen 4-bit | G_HEAD_DIM |
| InfinityStar | 8/6/4-bit | KIVI 4-bit, FLexGen 4-bit | G_HEAD_DIM, ratio 1/2 and 1/3 |
| Self-Forcing | 8/6/4/3/2-bit | KIVI 4-bit, FLexGen 4-bit | G_HEAD_DIM, 4/3-bit ratio 1/2, 1/4, 1/8 |
| LongLive | 8/6/4/3/2-bit | KIVI 4-bit, FLexGen 4-bit | G_HEAD_DIM, 4/3-bit ratio 1/2, 1/4, 1/8 |
For next-frame video backends such as Self-Forcing and LongLive, max_scale_seq_len=1560 is the default grouping unit. If compression_ratio is omitted, it defaults to 1, so the group length is 1560. compression_ratio=3 represents grouping the full 4680-token chunk.
Lightweight tests are public and do not require third-party model repositories, checkpoints, or datasets:
python -m py_compile VAR_Q/*.py VAR_Q/hooks/*.py ablation/*.py scripts/*.py
pytest tests/
The smoke tests cover pack/unpack, quant/dequant shape checks, config loading, and mock runtime hook installation/removal.
If this repository is useful for your research, please cite the VAR-Q paper. The BibTeX entry will be added after the final publication metadata is available.
This repository is released under the MIT License. Third-party model repositories, checkpoints, datasets, and generated assets are governed by their own licenses.
Python
81.2%
Cuda
8.6%
C++
5.6%
Jupyter Notebook
3.1%
Shell
1.5%
VAR-Q is a lightweight KV-cache quantization method for efficient visual autoregressive generation. It reduces inference-time KV-cache memory while preserving generation quality, and is designed to attach to existing visual autoregressive model implementations without modifying their source code.
This smoke path does not require third-party backends, checkpoints, or datasets.
git clone https://github.com/lujiaji/VAR-Q.git
cd VAR-Q
git checkout varq_official
# Install PyTorch first from https://pytorch.org/get-started/locally/
pip install -e .
python examples/smoke_quant_roundtrip.py
python examples/smoke_pack_unpack.py
python examples/smoke_hook_mock_attention.py
For development checks:
pip install -e ".[dev]"
pytest tests/
VAR-Q is a runtime KV-cache quantization method for visual autoregressive generation. It quantizes K/V cache tensors created during inference; it is not a weight-only quantization method.
Weight quantization methods such as GPTQ, AWQ, and related approaches are orthogonal to VAR-Q. In principle, a backend can combine weight-only quantization for model parameters with VAR-Q for runtime KV-cache memory.
VARQ, all G_* grouping variants, ratio-controlled grouping, pre-RoPE control, and low-bit KV cache packing/unpacking.ablation/ and are installed as an optional comparison package alongside VAR_Q.Reported A100-80GB evaluations show approximately 75% KV-cache reduction at INT4 and up to 87% at INT2. The reduced cache enables substantially larger full-generation batches across image and video backends.
| Model | INT4 KV-cache reduction | BF16 max batch | Largest verified VAR-Q batch |
|---|---|---|---|
| Infinity-8B | 74.8% | 3 | 16 (INT4), 22 (INT2) |
| Self-Forcing | 74.9% | 8 | 16 (INT4) |
| LongLive | 74.9% | 4 | 8 (INT3) |
| InfinityStar-480p | 73.5% | 1 | 3 (INT2) |
| VAR-d30 | 72.9% | 134 | 543 (INT2) |
For Infinity-8B, the effective compression ratios below include scale metadata:
| KV precision | Effective KV compression |
|---|---|
| INT4 | 3.97x |
| INT3 | 4.95x |
| INT2 | 7.88x |
KV-cache reduction refers to persistent K/V storage rather than whole-process peak GPU allocation. Maximum batch is the largest completed full-generation run under each reported precision.
On Infinity-8B at batch size 1, fusing packed-KV loading, unpacking, and dequantization into attention reduces both attention-path and end-to-end latency relative to the same quantized runtime without fusion:
| KV precision | Attention, unfused -> fused | Attention improvement | E2E, unfused -> fused | E2E improvement |
|---|---|---|---|---|
| INT8 | 1951 -> 1603 ms | 17.8% | 3973 -> 3627 ms | 8.7% |
| INT4 | 1999 -> 1583 ms | 20.8% | 4012 -> 3596 ms | 10.4% |
The speedups above compare fused and unfused quantized execution. They do not claim that quantized execution is faster than the BF16 reference (3164 ms E2E).
| Backend | Upstream repository | Default checkout | Integration path |
|---|---|---|---|
| VAR | https://github.com/FoundationVision/VAR | third_party/VAR | Automatic runtime hook |
| Infinity | https://github.com/FoundationVision/Infinity | third_party/Infinity | Automatic runtime hook |
| InfinityStar | https://github.com/FoundationVision/InfinityStar | third_party/InfinityStar | Automatic runtime hook |
| LiveTalk | https://github.com/ChenhongyiYang/LiveTalk | third_party/LiveTalk | Automatic runtime hook |
| Self-Forcing | https://github.com/guandeh17/Self-Forcing | third_party/Self-Forcing | Automatic packed-KV hook |
| LongLive | https://github.com/NVlabs/LongLive | third_party/LongLive | Automatic segmented packed-KV hook |
All listed entrypoints install hooks at runtime and do not require a committed patch to their upstream repositories. Standard Wan2.1/Wan2.2 diffusion is not listed because it does not maintain a persistent autoregressive KV cache.
For backends using the general hook router, VAR-Q and ablation methods are selected through the same attachment point while their quantization implementations remain isolated: VAR-Q is implemented in VAR_Q/, and comparisons remain in ablation/.
VAR-Q/
├── VAR_Q/ # VAR-Q core and runtime hooks
│ ├── quant.py # VARQ, G_* grouping, ratio logic, pre-RoPE control
│ ├── pack_unpack.py # Low-bit pack/unpack utilities
│ ├── config_loader.py # Public JSON normalization
│ ├── paths.py # Relative third-party path helpers
│ ├── fused/ # Packed-KV attention Python API
│ ├── csrc/ # CUDA quant/pack/unpack/attention extension
│ └── hooks/ # Model hook installers
├── ablation/ # KIVI / FLexGen / KVQuant implementations
├── Benchmark/ # Public evaluation entrypoints
├── configs/ # Curated JSON configs
├── docs/ # Public documentation
├── examples/ # No-checkpoint smoke demos
├── scripts/ # Public inference and evaluation launchers
├── tests/ # Lightweight public smoke tests
├── third_party/README.md # Upstream checkout instructions
├── requirements-varq.txt # Lightweight VAR-Q convenience environment
├── pyproject.toml # Editable install metadata
└── LICENSE
Ignored local-only paths include third_party/, temp/, benchmark outputs, model weights, generated media, and test output/tmp directories. The lightweight tests/ suite is part of the public repository.
Clone VAR-Q and check out the public branch:
git clone https://github.com/lujiaji/VAR-Q.git
cd VAR-Q
git checkout varq_official
Install PyTorch first, matching your CUDA driver and runtime. Follow the official PyTorch selector rather than relying on VAR-Q to pin a wheel:
# Example only. Choose the command for your CUDA version from:
# https://pytorch.org/get-started/locally/
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121
Install VAR-Q in editable mode:
conda activate <your-backend-env>
pip install -e .
Build the bundled CUDA extension before CUDA inference:
bash scripts/bench/build_fused_flash.sh
import VAR_Q and the CPU reference path remain available on CPU-only hosts;
CUDA tensors never fall back to Triton or a Python pack/unpack implementation.
For a non-editable minimal convenience install after PyTorch is already installed, requirements-varq.txt is retained:
pip install -r requirements-varq.txt
VAR-Q itself only needs PyTorch for CPU import/reference use and a compatible CUDA toolchain for CUDA inference. VAR, Infinity, InfinityStar, Self-Forcing, and LongLive may pin different CUDA, PyTorch, flash-attn, xformers, tokenizer, or evaluation package versions; install those dependencies inside each official upstream repository instead of putting them into the VAR-Q root environment metadata.
| Component | Environment | Notes |
|---|---|---|
| VAR-Q core smoke tests | Python 3.10, PyTorch | CPU works for public tests; CUDA extension tests run when CUDA is available. |
| VAR / Infinity / InfinityStar | Follow official backend environments | Install VAR-Q with pip install -e . inside the backend env. |
| Self-Forcing / LongLive | Follow official backend environments | Video stacks may require separate CUDA/PyTorch package sets. |
| CI | Ubuntu latest, Python 3.10 | Runs only py_compile and public smoke tests. |
Clone upstream repositories into third_party/:
git clone https://github.com/FoundationVision/VAR third_party/VAR
git clone https://github.com/FoundationVision/Infinity third_party/Infinity
git clone https://github.com/FoundationVision/InfinityStar third_party/InfinityStar
git clone https://github.com/ChenhongyiYang/LiveTalk third_party/LiveTalk
git clone https://github.com/guandeh17/Self-Forcing third_party/Self-Forcing
git clone https://github.com/NVlabs/LongLive third_party/LongLive
VAR-Q does not vendor third-party source or distribute patch files. Public launchers load the backend model and install hooks in memory.
Checkpoints are intentionally not stored in JSON configs. Provide them through command-line arguments, environment variables, or the upstream backend's native loader.
Third-party backends, checkpoints, datasets, and generated assets are not distributed with this repository. They are governed by their own licenses and usage terms.
VAR-Q follows a SmoothQuant-style runtime replacement design. The installer scans supported attention modules, stores the original methods in a handle, and replaces the instance-level KV-cache path in memory.
from VAR_Q.hooks import install_varq_hooks, remove_varq_hooks
handle = install_varq_hooks(
model,
model_type="var", # "var", "infinity", or "infinitystar"
quant_config={
"enable": True,
"q_bits": 4,
"quant_method": "VARQ",
"qkv_format": "BLHc",
"pack_to_int32": True,
},
)
# Run backend inference.
remove_varq_hooks(handle)
Use quant_method="VARQ" or any G_* method for the main method. Use KIVI, FLexGen, or KVQuant in public configs for ablations; the loader normalizes them to isolated ablation implementations.
LiveTalk uses a dedicated hook installer for its chunk-overwrite cache semantics:
from VAR_Q.hooks import install_livetalk_hooks, remove_livetalk_hooks
handle = install_livetalk_hooks(pipeline, quant_config)
# Run LiveTalk generation.
remove_livetalk_hooks(handle)
Self-Forcing and LongLive expose direct installers. Their launchers call these automatically after the upstream pipeline has been constructed:
from VAR_Q.hooks import install_longlive_hooks, install_self_forcing_hooks
sf_handle = install_self_forcing_hooks(sf_pipeline, "configs/self_forcing/varq/base/SF-VARQ-4.json")
ll_handle = install_longlive_hooks(ll_pipeline, "configs/longlive/varq/base/LL-VARQ-4.json")
The underlying VideoKVCacheAdapter remains available as an integration API
for additional causal video models.
VAR-Q reduces active cache allocations in addition to reporting packed byte counts:
expected_total_seq_len and preallocate_kv_cache when the generation length is known.quant_compute_dtype="native" and dequant_dtype="native" avoid unnecessary full-size FP32 or cast temporaries.dequant_workspace_policy="release" avoids retaining dense dequant workspaces between attention calls.For memory measurements, enable the entrypoint's profiling option where available. Reports include packed K/V bytes, scale bytes, dequant workspace bytes, and PyTorch allocated/reserved peaks. Compare backends using identical prompts, generation schedules, batch size, dtype, and a clean CUDA device.
All public scripts resolve paths relative to the VAR-Q repository root.
VAR:
export VARQ_VAE_CKPT=/path/to/vae_ch160v4096z32.pth
export VARQ_VAR_CKPT_TEMPLATE='/path/to/var_d{}.pth'
bash scripts/inference_VAR.sh configs/var/varq/base/VAR-VARQ-8.json scripts/output/var
Infinity:
export INFINITY_MODEL_PATH=/path/to/infinity_model
export INFINITY_TEXT_ENCODER_CKPT=/path/to/text_encoder
export INFINITY_PN=1M
bash scripts/inference_Infinity.sh \
configs/infinity/varq/base/Infinity-VARQ-8.json \
"a cinematic photograph of a red fox in snow" \
scripts/output/infinity.png
InfinityStar:
export INFINITYSTAR_CHECKPOINTS_DIR=/path/to/infinitystar/checkpoints
bash scripts/inference_InfinityStar.sh \
configs/infinitystar/varq/base/InfinityStar-VARQ-8.json \
--output scripts/output/infinitystar_varq_demo.mp4
Self-Forcing runs its upstream inference.py by default. Arguments after --
are forwarded directly to that script:
bash scripts/inference_SelfForcing.sh \
configs/self_forcing/varq/base/SF-VARQ-4.json \
-- <upstream inference arguments>
LongLive follows the same pattern:
bash scripts/inference_LongLive.sh \
configs/longlive/varq/base/LL-VARQ-4.json \
-- <upstream inference arguments>
LiveTalk:
bash scripts/inference_LiveTalk.sh 4 -- \
--checkpoint_root /path/to/livetalk/checkpoints \
--output scripts/output/livetalk_varq_demo.mp4
If a required third-party checkout is missing, launchers fail early and print the expected third_party/<repo> path.
VAR evaluation:
bash scripts/eval_VAR.sh \
configs/var/varq/base/VAR-VARQ-8.json \
/path/to/VIRTUAL_imagenet256_labeled.npz
Infinity evaluation:
bash scripts/eval_Infinity.sh geneval \
configs/infinity/varq/base/Infinity-VARQ-8.json
Supported Infinity evaluation tasks are geneval, dpg, and imagereward.
Curated JSON configs live under:
configs/<backend>/<family>/<topic>/*.json
The quantization block is intentionally backend-agnostic and can be reused when calling install_varq_hooks(...) directly. Full JSON files are still kept per backend because model loaders use different qkv_format, sequence layout, image/video schedule, and grouping defaults.
See docs/configs.md for a concise field reference.
Retained public configs include:
| Backend | VAR-Q configs | Ablation configs | Extra configs |
|---|---|---|---|
| VAR | 8/6/4/3-bit | KIVI 4-bit, FLexGen 4-bit | G_HEAD_DIM |
| Infinity | 8/6/4/3/2-bit | KIVI 4-bit, FLexGen 4-bit | G_HEAD_DIM |
| InfinityStar | 8/6/4-bit | KIVI 4-bit, FLexGen 4-bit | G_HEAD_DIM, ratio 1/2 and 1/3 |
| Self-Forcing | 8/6/4/3/2-bit | KIVI 4-bit, FLexGen 4-bit | G_HEAD_DIM, 4/3-bit ratio 1/2, 1/4, 1/8 |
| LongLive | 8/6/4/3/2-bit | KIVI 4-bit, FLexGen 4-bit | G_HEAD_DIM, 4/3-bit ratio 1/2, 1/4, 1/8 |
For next-frame video backends such as Self-Forcing and LongLive, max_scale_seq_len=1560 is the default grouping unit. If compression_ratio is omitted, it defaults to 1, so the group length is 1560. compression_ratio=3 represents grouping the full 4680-token chunk.
Lightweight tests are public and do not require third-party model repositories, checkpoints, or datasets:
python -m py_compile VAR_Q/*.py VAR_Q/hooks/*.py ablation/*.py scripts/*.py
pytest tests/
The smoke tests cover pack/unpack, quant/dequant shape checks, config loading, and mock runtime hook installation/removal.
If this repository is useful for your research, please cite the VAR-Q paper. The BibTeX entry will be added after the final publication metadata is available.
This repository is released under the MIT License. Third-party model repositories, checkpoints, datasets, and generated assets are governed by their own licenses.
Python
81.2%
Cuda
8.6%
C++
5.6%
Jupyter Notebook
3.1%
Shell
1.5%