You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix compatible issue with transformers 5.0+ (#2328)
## Describe your changes
This pull request introduces compatibility updates for Hugging Face
Transformers 5.0 and improves handling of dynamic cache and input
formats in Olive's ONNX conversion and training utilities. It also
updates tests and requirements to reflect these changes and ensure
robust model export and training workflows.
### Transformers 5.0 Compatibility
* Added patching and conversion utilities for
`DynamicLayer.lazy_initialization`, `past_key_values`, and dynamic
shapes to support the new DynamicCache format in Transformers >= 5.0.
This ensures models using dynamic cache export correctly with
`torch.export`.
* Updated `_export_pytorch_model` logic to apply the new patches and
conversions only for Transformers >= 5.0, while maintaining legacy
support for older versions.
### Training Argument Handling
* Improved filtering of training arguments in `create_training_args` to
remove fields not valid for Transformers 5.0 and exclude `None` values,
allowing Transformers to use its own defaults.
### Test Suite Updates
* Modified model loading and metadata tests to remove
`trust_remote_code` parameter and update expected file counts and
tokenizer types for Transformers 5.0.
[[1]](diffhunk://#diff-af681b2feed22286034d304b653185d2a4dc5d680e7d715a6ad41a1c731ff0fcL30-L45)
[[2]](diffhunk://#diff-af681b2feed22286034d304b653185d2a4dc5d680e7d715a6ad41a1c731ff0fcL76-R80)
[[3]](diffhunk://#diff-af681b2feed22286034d304b653185d2a4dc5d680e7d715a6ad41a1c731ff0fcL97-R90)
[[4]](diffhunk://#diff-af681b2feed22286034d304b653185d2a4dc5d680e7d715a6ad41a1c731ff0fcL129-R121)
* Updated model output comparison in rotation tests to cast logits to
`float` before comparison, ensuring consistency across dtypes.
### Requirements Adjustments
* Restricted `onnxscript` version to `<0.6.1` and removed the
Transformers version pin, reflecting confidence in test suite
compatibility with Transformers 5.0.
[[1]](diffhunk://#diff-1ce09e5a57d7791711f12f84ecb7e089e925a2929b719d587561e8e58c7e4b90L24-R24)
[[2]](diffhunk://#diff-1ce09e5a57d7791711f12f84ecb7e089e925a2929b719d587561e8e58c7e4b90L40-L41)
## Checklist before requesting a review
- [ ] Add unit tests for this change.
- [ ] Make sure all tests can pass.
- [ ] Update documents if necessary.
- [ ] Lint and apply fixes to your code by running `lintrunner -a`
- [ ] Is this a user-facing change? If yes, give a description of this
change to be included in the release notes.
## (Optional) Issue link
0 commit comments