Commit 33e21ba
committed
Fix: Unify nn.Module device placement across all quantizers and base class
This commit addresses multiple instances where torch.nn.Module objects
(including nn.Linear and PreTrainedModel) were incorrectly passed to
the `move_to_device` function, which is designed for tensors. This
could lead to AttributeError exceptions.
The following changes were made:
- In AWQQuantizer, GPTQQuantizer, and GGUFQuantizer, `nn.Linear`
layer instances are now moved to the target device using `layer.to(device)`.
- In BaseQuantizer, `PreTrainedModel` instances are now moved to the
primary device using `model.to(device)`.
These changes ensure that all nn.Module device placements utilize the
standard `.to()` method, preventing errors and ensuring correct and
consistent behavior across the library. This supersedes previous
individual fixes for QuantizedLinear by addressing the issue at all
identified points for various module types.1 parent 5b434ed commit 33e21ba
4 files changed
+4
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
198 | | - | |
| 198 | + | |
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
206 | | - | |
| 206 | + | |
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
190 | | - | |
| 190 | + | |
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
521 | 521 | | |
522 | 522 | | |
523 | 523 | | |
524 | | - | |
| 524 | + | |
525 | 525 | | |
526 | 526 | | |
527 | 527 | | |
| |||
0 commit comments