mirror of
https://github.com/deepseek-ai/Janus.git
synced 2026-11-05 00:57:18 +00:00
[PR #232] [CLOSED] fix: use actual codebook size for usage tracking buffer in VectorQuantizer #229
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
deepseek-ai/Janus#229
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/deepseek-ai/Janus/pull/232
Author: @Mr-Neutr0n
Created: 2/11/2026
Status: ❌ Closed
Base:
main← Head:fix/vq-codebook-buffer-size📝 Commits (1)
e24472afix: use actual codebook size for usage buffer and remove nn.Parameter wrapper📊 Changes
1 file changed (+3 additions, -2 deletions)
View changed files
📝
janus/models/vq_model.py(+3 -2)📄 Description
Summary
Fixes two bugs in
VectorQuantizer.__init__injanus/models/vq_model.py:1. Hardcoded buffer size (65536) instead of actual codebook size (
self.n_e)The
codebook_usedbuffer was hardcoded to size65536, but the actual codebook size (n_e) is configurable (default16384). This causes:n_e < 65536— the buffer allocates 4x more entries than needed at the default size.n_e > 65536— usage tracking would fail for codebook entries beyond index 65535.2.
nn.Parameterwrapped insideregister_bufferregister_bufferis designed to store tensors as non-parameter state (not updated by optimizers, but included instate_dict). Wrapping the tensor innn.Parameterinsideregister_buffercreates conflicting semantics —nn.Parametersignals "this should be optimized," whileregister_buffersignals the opposite. A plaintorch.zeros(...)tensor is the correct argument.Fix
This ensures the buffer size matches the actual codebook size and uses the correct tensor type for a registered buffer.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.