Skip to content

[Examples][FX] WC Example for TorchFX Backend#3467

Merged
alexsu52 merged 40 commits intoopenvinotoolkit:developfrom
anzr299:an/fx/lm_wc/example
Jul 25, 2025
Merged

[Examples][FX] WC Example for TorchFX Backend#3467
alexsu52 merged 40 commits intoopenvinotoolkit:developfrom
anzr299:an/fx/lm_wc/example

Conversation

@anzr299
Copy link
Collaborator

@anzr299 anzr299 commented Apr 28, 2025

Changes

Add example script for TorchFX backend in examples/.

Reason for changes

This is to show a sample script for applying WC to LLMs which are exported using torch.export()

Tests

Category Job Status Job Number Notes
GH Examples Examples Running 352

@anzr299 anzr299 requested a review from a team as a code owner April 28, 2025 11:57
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Apr 28, 2025
@AlexanderDokuchaev
Copy link
Collaborator

Please add new tests to https://github.com/openvinotoolkit/nncf/blob/develop/tests/cross_fw/examples/.test_durations

@anzr299
Copy link
Collaborator Author

anzr299 commented Apr 28, 2025

@anzr299 anzr299 requested a review from alexsu52 May 20, 2025 09:39
AlexanderDokuchaev added a commit that referenced this pull request May 28, 2025
### Changes

This PR achieves the following:
1. Fix an issue faced when using openvino nightly Ref. 167462
2. Fix performance issue where compressed FX models in conformance were
running slow. Fixes discovered when working on #3467 allow the
compressed FX model to run faster.

### Reason for changes

To resolve errors with openvino nightly and make the WC conformance test
run faster.

### Related tickets

167462

Category | Job | Status | Job Number | Notes
-- | -- | -- | -- | --
WC Conformance | Nightly | Pass | 104 |

---------

Co-authored-by: Alexander Dokuchaev <alexander.dokuchaev@intel.com>
Copy link
Collaborator

@daniil-lyakhov daniil-lyakhov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor

Comment on lines +88 to +90
"""
Convert a `PreTrainedModel` into an exportable module and export it using `torch.export`
or `torch._export.capture_pre_autograd_graph`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add parameters and return statements to the docstring

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

anzr299 and others added 2 commits June 23, 2025 19:42
Co-authored-by: Daniil Lyakhov <daniil.lyakhov@intel.com>
Use chat template for the prompt as expected by the model
Comment on lines +72 to +74
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)

input_ids = tokenizer(prompt, return_tensors="pt")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
input_ids = tokenizer(prompt, return_tensors="pt")
input_ids = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@alexsu52 alexsu52 merged commit 9fb0551 into openvinotoolkit:develop Jul 25, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants