Commit 4c4db31
committed
fix(quant): make embedding input_quantizer absorb wildcard configs
The previous design raised in _QuantEmbedding.forward whenever
input_quantizer.is_enabled, on the theory that any non-disable config was
an explicit user mistake. That assumption was wrong for wildcard configs:
the default QuantizeConfig is just [{"quantizer_name": "*", "cfg":
{"num_bits": 8, ...}}] (no embedding opt-out), so the wildcard enables
embed_tokens.input_quantizer for tiny Llama-style tests and the forward
guard fires — breaking test_peft_save_load and test_transformers_save_load.
Switch _UnsettableInputQuantizer.set_from_attribute_config to absorb the
incoming config like a normal quantizer, then force _disabled = True at
the end. The "throw on explicit set" semantics are preserved via the
.enable / .enable_quant / .enable_calib overrides, which catch the direct
mistakes users would actually make. The forward-time guard (and the
corresponding test) are removed since the invariant is now maintained at
the configure step.
Signed-off-by: ajrasane <131806219+ajrasane@users.noreply.github.com>1 parent 7ed34d5 commit 4c4db31
2 files changed
Lines changed: 39 additions & 24 deletions
File tree
- modelopt/torch/quantization/nn/modules
- tests/unit/torch/quantization
Lines changed: 30 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
62 | 74 | | |
63 | 75 | | |
64 | 76 | | |
65 | 77 | | |
66 | 78 | | |
67 | 79 | | |
68 | 80 | | |
69 | | - | |
70 | | - | |
| 81 | + | |
| 82 | + | |
71 | 83 | | |
72 | 84 | | |
73 | 85 | | |
74 | 86 | | |
75 | 87 | | |
76 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
77 | 91 | | |
78 | 92 | | |
79 | 93 | | |
| |||
119 | 133 | | |
120 | 134 | | |
121 | 135 | | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
126 | 143 | | |
127 | 144 | | |
128 | 145 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
| 95 | + | |
| 96 | + | |
101 | 97 | | |
102 | | - | |
103 | | - | |
104 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
105 | 102 | | |
106 | 103 | | |
107 | 104 | | |
108 | 105 | | |
109 | 106 | | |
110 | 107 | | |
111 | | - | |
112 | | - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
113 | 111 | | |
114 | 112 | | |
115 | 113 | | |
| |||
0 commit comments