Commit 217d968
authored
Make FakeQuantizer expose useful config details (#1717)
**Summary:** Expose useful config details when printing
FakeQuantizer, which appears when printing QAT prepared models
containing linear layers.
Before:
```
>>> print(prepared_model.layers[0].attn.qproj)
FakeQuantizedLinear(
in_features=4096, out_features=4096, bias=False
(activation_fake_quantizer): FakeQuantizer()
(weight_fake_quantizer): FakeQuantizer()
)
```
After:
```
>>> print(prepared_model.layers[0].attn.qproj)
FakeQuantizedLinear(
in_features=4096, out_features=4096, bias=False
(activation_fake_quantizer): FakeQuantizer(FakeQuantizeConfig(dtype=torch.int8, granularity=PerToken(), mapping_type=<MappingType.ASYMMETRIC: 3>, scale_precision=torch.float32, zero_point_precision=torch.int32, zero_point_domain=<ZeroPointDomain.INT: 1>, is_dynamic=True, range_learning=False))
(weight_fake_quantizer): FakeQuantizer(FakeQuantizeConfig(dtype=torch.int4, granularity=PerGroup(group_size=32), mapping_type=<MappingType.SYMMETRIC: 1>, scale_precision=torch.float32, zero_point_precision=torch.int32, zero_point_domain=<ZeroPointDomain.INT: 1>, is_dynamic=True, range_learning=False))
)
```
**Test Plan:**
python test/quantization/test_qat.py -k test_fake_quantizer_repr1 parent ceceea5 commit 217d968
File tree
2 files changed
+24
-0
lines changed- test/quantization
- torchao/quantization/qat
2 files changed
+24
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
34 | 37 | | |
35 | 38 | | |
36 | 39 | | |
| |||
1348 | 1351 | | |
1349 | 1352 | | |
1350 | 1353 | | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
1351 | 1369 | | |
1352 | 1370 | | |
1353 | 1371 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
0 commit comments