lucidrains/vector-quantize-pytorch

Vector (and Scalar) Quantization, in Pytorch

View on GitHub ↗Jump to charts ↓Open shareable report

Summary Information

Updated 22 minutes ago
Added to GitGenius on September 17th, 2026
Created on June 9th, 2020
Open Issues & Pull Requests: 53 (+0)
GitHub issues: Enabled
Number of forks: 339
Total Stargazers: 4,006 (+0)
Total Subscribers: 30 (+0)

Repository Insights (GitGenius)

Median issue/PR response: 3.1 hours
Mean response time: 18.1 days
90th percentile: 15.7 days
Tracked items: 63

Most active contributors

Sign in to see contributor activity.

Charts & Analytics

Fetching additional details & charts...

Issue Activity (beta)

Open issues: 17
New in 7 days: 0
Closed in 7 days: 0
Avg open age: 704 days
Stale 30+ days: 17
Stale 90+ days: 17

Recent activity

Opened in 7 days: 0
Closed in 7 days: 0
Comments in 7 days: 0
Events in 7 days: 0

Top labels

  • enhancement (4)
  • bug (1)

Most active issues this week

No issue events were indexed in the last 7 days.

Detailed Description

Vector-quantize-pytorch is a vector quantization library for PyTorch that implements quantization techniques for deep learning models.

The library addresses the need to compress continuous representations into discrete codes using learned codebooks. It originated as a PyTorch transcription of DeepMind's TensorFlow implementation and uses exponential moving averages to update the codebook. Vector quantization has proven effective in generative models for images and audio, as demonstrated by DeepMind's VQ-VAE-2 and OpenAI's Jukebox.

The tool is suited for researchers and practitioners building generative models or compression systems that benefit from discrete latent representations. It works well in projects involving image or audio generation where quantization can reduce model size while maintaining quality. The library provides multiple variants beyond basic vector quantization: Residual VQ recursively quantizes residuals across multiple quantizers, GroupedResidualVQ applies quantization to feature dimension groups for efficiency, and it supports alternative codebook update methods like DiVeQ that use gradients instead of auxiliary losses. For gradient computation during training, the library offers the straight-through estimator alongside newer approaches like the rotation trick and directional reparameterization, each suited to different training scenarios. Codebook initialization can use k-means centroids from the first batch, addressing initialization challenges in practice.

The maintainers respond to issues and pull requests within hours. Development activity centers on enhancements and bug fixes, indicating active refinement of existing functionality and responsiveness to user needs.