lucidrains / lucidrains/vector-quantize-pytorch
Bug in FSQ, with return_indices to False and image-type feature input
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4k
- Forks
- 338
- PR merge metrics
- No merged PRs in 30d
Description
The new version of FSQ, with the possibility to not compute indices and return only None, has a small bug:
```python
from vector_quantize_pytorch.finite_scalar_quantization import FSQ
import torch
quantizer = FSQ(levels=[8,5,5,5], return_indices=False)
images = torch.rand(1, 4, 32, 32)
quantizer(images)
```
the code above will raise a RuntimeError, as Einops try [here](https://github.com/lucidrains/vector-quantize-pytorch/blob/fc55a8cd578ede12da08762ebba3b0f08897fb78/vector_quantize_pytorch/finite_scalar_quantization.py#L203) to unpack None.
I will shortly propose a PR, which solves the issue and clean a bit the code, for better readability and ease of use.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at FSQ in vector_quantize_pytorch/finite_scalar_quantization.py, especially the Einops unpacking near line 203, and run the image-shaped reproduction from the issue with return_indices=False. Done means this call no longer raises a RuntimeError and returns the expected output with indices represented as None.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100