Commit d70c48c
authored
Fix HF PTQ empty-init dtype kwargs (#1857)
## Summary
Fixes NVBug 6359821: `hf_ptq.py` can fail for remote/custom
architectures like `DeciLMForCausalLM` when dtype-related kwargs are
forwarded into model construction paths that do not accept them.
This change keeps the fix scoped to the observed DeciLM/Llama Nemotron
path. It resolves the init config used for empty-weight construction,
derives dtype consistently from the resolved config, forwards the
supported dtype kwarg for the DeciLM empty-weight probe, and drops
unsupported dtype forwarding from the DeciLM real `from_pretrained()`
load.
NVBug: https://nvbugspro.nvidia.com/bug/6359821
## Validation
- `pre-commit run --files examples/hf_ptq/example_utils.py
tests/examples/hf_ptq/test_example_utils.py`
- `pytest_pwd tests/examples/hf_ptq/test_example_utils.py -q -x` (15
passed)
- Actual `Llama-3_3-Nemotron-Super-49B-v1` end-to-end `hf_ptq.py` export
on one node with 6 GPUs, Transformers 4.48.3:
#1857 (comment)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Bug Fixes**
* Improved model loading for Hugging Face remote-code scenarios by
safely re-deriving the initialization configuration when needed, with a
warning-based fallback.
* Ensured precision is derived consistently from the resolved config
(including dtype name handling) with a safe default when unspecified.
* Tightened forwarding of precision-related kwargs and
`trust_remote_code`, and avoided passing `max_memory` during config
loading.
* **Tests**
* Added unit coverage for initialization config resolution (including
failure fallback).
* Extended integration-style coverage to validate dtype/kwarg
forwarding, `trust_remote_code` behavior, and eval-mode initialization.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Signed-off-by: realAsma <akuriparambi@nvidia.com>1 parent 43c2034 commit d70c48c
2 files changed
Lines changed: 104 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
750 | 750 | | |
751 | 751 | | |
752 | 752 | | |
| 753 | + | |
753 | 754 | | |
754 | 755 | | |
755 | 756 | | |
756 | 757 | | |
757 | 758 | | |
758 | 759 | | |
759 | 760 | | |
760 | | - | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
761 | 768 | | |
762 | 769 | | |
763 | 770 | | |
764 | | - | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
765 | 776 | | |
766 | 777 | | |
767 | 778 | | |
| |||
783 | 794 | | |
784 | 795 | | |
785 | 796 | | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
786 | 800 | | |
787 | 801 | | |
788 | 802 | | |
789 | | - | |
| 803 | + | |
790 | 804 | | |
791 | 805 | | |
792 | 806 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| |||
229 | 231 | | |
230 | 232 | | |
231 | 233 | | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
0 commit comments