Repository navigation
[TorchFX] Fix TinyLlama weight compression example for transformers 5.5 - #4289
Open
AlexanderDokuchaev wants to merge 5 commits into
Open
AlexanderDokuchaev wants to merge 5 commits into
AlexanderDokuchaev wants to merge 5 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The pinned generation helper duplicates the final prompt token and changes generated output, while an unconditional xfail masks a failing Linux accuracy check.
3 open issues
What changed in this PR
Updates NNCF’s TorchFX TinyLlama weight-compression example for Transformers 5.5, replacing custom export and generation wrappers with upstream helpers.
Changes:
- Uses named calibration inputs truncated to the static-cache length.
- Adds no-gradient generation, a warm-up forward, and baseline/compressed model reporting.
- Removes the custom wrappers and
optimumdependency, and refreshes example test durations.
| File | Description |
|---|---|
tests/cross_fw/examples/test_durations.json |
Refreshes example timing data and removes one entry. |
examples/llm_compression/torch_fx/tiny_llama/requirements.txt |
Drops the optimum dependency. |
examples/llm_compression/torch_fx/tiny_llama/modelling.py |
Deletes custom export and generation wrappers. |
examples/llm_compression/torch_fx/tiny_llama/main.py |
Adopts upstream helpers and updates calibration, generation, and reporting. |
Review effort: Balanced
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Changes
transformers.integrations.executorch.convert_and_export_with_cacheandTorchExportableModuleForDecoderOnlyLM.generateinstead of the custom wrappers;modelling.pyremoved.{"input_ids", "cache_position"}dicts truncated to the cache length.torch.no_grad(); one warm-up forward before timing;optimumdependency droppedtests/cross_fw/examples/test_durations.jsonReason for changes
The example fails with transformers 5.x:
IndexError: index_copy_(): index 512 is out of bounds— the customforwardskipped thecumulative_lengthreset of
StaticCache, so calibration samples were appended until the 512-token cache overflowed.KeyError: 'cache_position'—generate()no longer passescache_position.Related tickets
N/A
Tests
Test examples - success