facebookresearch / facebookresearch/SpinQuant

How to adapt source model project loading for W4A16KV16 model

Open
#29 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
428
Forks
93
PR merge metrics
No merged PRs in 30d

Description

I used the script (bash scripts/10_optimize_rotation.sh meta-llama/Llama-2-7b 4 16 16) to quantize W4A16KV16. Then I saved the model weights and structure.

The way I export the model is as follows:
In line 50 of ptq.py `model = ptq_model(ptq_args, model, model_args)` add the following code

```python
print("\n")
print("save weights of pytorch")
torch.save(model.statedict(),"mergedweights/torch/consolidated.00.pth")
```

Theoretically, W4A16KV16 only uses the R1 R2 rotation matrix and will not make any changes to the model structure. It should be possible to use the source model project to load, but it failed. My error message is as follows

![Image](https://github.com/user-attachments/assets/43fe2035-45cb-4b6e-ab06-e7e77442edcb)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.