Commit 1dcb225
fix: baichuan dynamic cache (#1865)
fix: Handle DynamicCache in Baichuan model for generation compatibility
Baichuan's forward() and prepare_inputs_for_generation() assumed
past_key_values is always a legacy tuple-of-tuples, but transformers
5.x passes DynamicCache objects during model.generate(). This caused
TypeError/AttributeError in the baichuan_2_7b_squad_vllm_deploy and
baichuan_2_7b_squad_peft_vllm_deploy CI tests.
- Convert DynamicCache to legacy tuples in BaichuanModel.forward()
- Treat empty DynamicCache as None in prepare_inputs_for_generation()
- Fix position_ids truncation for transformers 5.x which passes
position_ids via kwargs instead of letting the model compute them
Signed-off-by: Zeyu Zhou <zezhou@nvidia.com>
Co-authored-by: Alexandros Koumparoulis <153118171+akoumpa@users.noreply.github.com>1 parent a53b52c commit 1dcb225
2 files changed
Lines changed: 40 additions & 2 deletions
File tree
- nemo_automodel/components/models/baichuan
- tests/unit_tests/models/baichuan
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
364 | 365 | | |
365 | 366 | | |
366 | 367 | | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
367 | 374 | | |
368 | 375 | | |
369 | 376 | | |
| |||
558 | 565 | | |
559 | 566 | | |
560 | 567 | | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
561 | 571 | | |
562 | 572 | | |
563 | 573 | | |
564 | 574 | | |
565 | 575 | | |
566 | 576 | | |
567 | 577 | | |
568 | | - | |
569 | | - | |
| 578 | + | |
| 579 | + | |
570 | 580 | | |
571 | 581 | | |
572 | 582 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
483 | 484 | | |
484 | 485 | | |
485 | 486 | | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
486 | 514 | | |
487 | 515 | | |
488 | 516 | | |
| |||
0 commit comments