Commit 726607d
Add __str__ to FqnToConfig to make printing more readable (#3323)
* Adds __str__ to FqnToConfig to make printing more readable
Summary:
att, adds `__str__` method to `FqnToConfig` so that printing is more
legible.
For some config:
```python
config = FqnToConfig({
"model.layers.fig.1.1": Float8DynamicActivationFloat8WeightConfig(
granularity=PerRow(),
),
"model.layers.fig.1.3": Float8DynamicActivationFloat8WeightConfig(
granularity=PerRow(),
),
"model.layers.fig.8.3": Float8DynamicActivationFloat8WeightConfig(
granularity=PerRow(),
),
})
```
the output will be:
```
FqnToConfig({
'model.layers.fig.1.1':
Float8DynamicActivationFloat8WeightConfig(activation_dtype=torch.float8_e4m3fn, weight_dtype=torch.float8_e4m3fn, granularity=[PerRow(dim=-1), PerRow(dim=-1)], mm_config=Float8MMConfig(emulate=False, use_fast_accum=True, pad_inner_dim=False), activation_value_lb=None, activation_value_ub=None, kernel_preference=<KernelPreference.AUTO: 'auto'>, set_inductor_config=True, version=2),
'model.layers.fig.1.3':
Float8DynamicActivationFloat8WeightConfig(activation_dtype=torch.float8_e4m3fn, weight_dtype=torch.float8_e4m3fn, granularity=[PerRow(dim=-1), PerRow(dim=-1)], mm_config=Float8MMConfig(emulate=False, use_fast_accum=True, pad_inner_dim=False), activation_value_lb=None, activation_value_ub=None, kernel_preference=<KernelPreference.AUTO: 'auto'>, set_inductor_config=True, version=2),
'model.layers.fig.8.3':
Float8DynamicActivationFloat8WeightConfig(activation_dtype=torch.float8_e4m3fn, weight_dtype=torch.float8_e4m3fn, granularity=[PerRow(dim=-1), PerRow(dim=-1)], mm_config=Float8MMConfig(emulate=False, use_fast_accum=True, pad_inner_dim=False), activation_value_lb=None, activation_value_ub=None, kernel_preference=<KernelPreference.AUTO: 'auto'>, set_inductor_config=True, version=2),
})
```
also adds in a test so that you cannot specify both fqn_to_config and
module_fqn_to_config unless they are both equal.
Test Plan:
```
pytest test/quantization/test_quant_api.py -k test_fqn_config_module_config_and_fqn_config_both_specified
```
Reviewers:
Subscribers:
Tasks:
Tags:
* fix ruff check1 parent 7213f81 commit 726607d
File tree
2 files changed
+28
-0
lines changed- test/quantization
- torchao/quantization
2 files changed
+28
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1178 | 1178 | | |
1179 | 1179 | | |
1180 | 1180 | | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
1181 | 1188 | | |
1182 | 1189 | | |
1183 | 1190 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2466 | 2466 | | |
2467 | 2467 | | |
2468 | 2468 | | |
| 2469 | + | |
| 2470 | + | |
| 2471 | + | |
| 2472 | + | |
| 2473 | + | |
| 2474 | + | |
| 2475 | + | |
| 2476 | + | |
| 2477 | + | |
2469 | 2478 | | |
2470 | 2479 | | |
2471 | 2480 | | |
| |||
2479 | 2488 | | |
2480 | 2489 | | |
2481 | 2490 | | |
| 2491 | + | |
| 2492 | + | |
| 2493 | + | |
| 2494 | + | |
| 2495 | + | |
| 2496 | + | |
| 2497 | + | |
| 2498 | + | |
| 2499 | + | |
| 2500 | + | |
| 2501 | + | |
| 2502 | + | |
2482 | 2503 | | |
2483 | 2504 | | |
2484 | 2505 | | |
| |||
0 commit comments