Commit 9fbcffe
committed
Allow no quantization during QATConfig convert
**Summary:** This commit allows users to call the following,
which swaps `FakeQuantized*` modules back to the corresponding
`torch.nn.*` without performing post-training quantization.
```
QATConfig(base_config=None, step="convert")
```
This has the exact same functionality as this deprecated config:
```
FromIntXQuantizationAwareTrainingConfig()
```
This functionality is added back since it may be useful to users
who wish to save QAT trained checkpoints from models containing
only `torch.nn.*` modules (not `FakeQuanitzed*` modules), e.g.
when training and inference need to happen on different machines:
```
quantize_(model, QATConfig(base_ptq_config, step="prepare"))
train(model)
quantize_(model, QATConfig(step="convert"))
torch.save(model.state_dict(), "my_checkpoint.pt")
\# On a different machine
model.load_state_dict(torch.load("my_checkpoint.pt"))
quantize_(model, base_ptq_config)
```
**Test Plan:**
```
python test/quantization/test_qat.py -k qat_config_init
python test/quantization/test_qat.py -k qat_api_convert_no_quantization
```1 parent 418593c commit 9fbcffe
File tree
2 files changed
+60
-10
lines changed- test/quantization
- torchao/quantization/qat
2 files changed
+60
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1278 | 1278 | | |
1279 | 1279 | | |
1280 | 1280 | | |
| 1281 | + | |
1281 | 1282 | | |
1282 | 1283 | | |
1283 | 1284 | | |
| |||
1306 | 1307 | | |
1307 | 1308 | | |
1308 | 1309 | | |
1309 | | - | |
| 1310 | + | |
1310 | 1311 | | |
1311 | 1312 | | |
1312 | 1313 | | |
| |||
1884 | 1885 | | |
1885 | 1886 | | |
1886 | 1887 | | |
| 1888 | + | |
| 1889 | + | |
| 1890 | + | |
| 1891 | + | |
| 1892 | + | |
| 1893 | + | |
| 1894 | + | |
| 1895 | + | |
| 1896 | + | |
| 1897 | + | |
| 1898 | + | |
| 1899 | + | |
| 1900 | + | |
| 1901 | + | |
| 1902 | + | |
| 1903 | + | |
| 1904 | + | |
| 1905 | + | |
| 1906 | + | |
| 1907 | + | |
| 1908 | + | |
| 1909 | + | |
| 1910 | + | |
| 1911 | + | |
| 1912 | + | |
| 1913 | + | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
| 1917 | + | |
| 1918 | + | |
1887 | 1919 | | |
1888 | 1920 | | |
1889 | 1921 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
118 | 121 | | |
119 | | - | |
120 | 122 | | |
121 | 123 | | |
122 | 124 | | |
| |||
148 | 150 | | |
149 | 151 | | |
150 | 152 | | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | 153 | | |
156 | 154 | | |
157 | 155 | | |
158 | 156 | | |
159 | 157 | | |
160 | 158 | | |
161 | | - | |
162 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
163 | 173 | | |
164 | 174 | | |
165 | 175 | | |
| |||
196 | 206 | | |
197 | 207 | | |
198 | 208 | | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
199 | 212 | | |
200 | 213 | | |
201 | 214 | | |
| |||
213 | 226 | | |
214 | 227 | | |
215 | 228 | | |
| 229 | + | |
216 | 230 | | |
217 | | - | |
| 231 | + | |
| 232 | + | |
218 | 233 | | |
219 | 234 | | |
220 | 235 | | |
221 | 236 | | |
222 | 237 | | |
223 | 238 | | |
224 | 239 | | |
225 | | - | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
226 | 244 | | |
227 | 245 | | |
228 | 246 | | |
| |||
0 commit comments