Skip to content

Enable traced model for text-generation task#22265

Merged
gante merged 1 commit intohuggingface:mainfrom
jiqing-feng:main
Mar 22, 2023
Merged

Enable traced model for text-generation task#22265
gante merged 1 commit intohuggingface:mainfrom
jiqing-feng:main

Conversation

@jiqing-feng
Copy link
Contributor

@gante Hi, Gante.
Refer to: #22072
Thanks for your advice. This PR only changed the example, would you please help me to review it? Thanks!

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Mar 20, 2023

The documentation is not available anymore as the PR was closed or merged.

@yao-matrix
Copy link
Contributor

@sgugger @gante

Copy link
Contributor

@gante gante left a comment

Choose a reason for hiding this comment

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

Thank you for reworking the example @jiqing-feng 🤗

As mentioned in the other PR, I'm going to keep an eye on demand!

@gante gante requested a review from amyeroberts March 21, 2023 14:41
Copy link
Contributor

@amyeroberts amyeroberts left a comment

Choose a reason for hiding this comment

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

Thanks for this contribution! 🔥

Have you run the script with and without the --jit flag to confirm it runs as expected?

traced_model = torch.jit.trace(model, jit_inputs, strict=False)
traced_model = torch.jit.freeze(traced_model.eval())
traced_model(*jit_inputs)
traced_model(*jit_inputs)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this line run twice? I'm not super familiar with torch.jit so apologies if I'm missing something.

Copy link
Contributor Author

@jiqing-feng jiqing-feng Mar 22, 2023

Choose a reason for hiding this comment

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

Thanks for this contribution! 🔥

Have you run the script with and without the --jit flag to confirm it runs as expected?

Yes, the example runs as usual without --jit and it also runs as expected with --jit.

Why is this line run twice? I'm not super familiar with torch.jit so apologies if I'm missing something.

I have tested it on A100 and found that the first two forwards are very slow, mainly because the first forward contains the operation of inserting profiling nodes and the second forward contains the operation of fusion. Refer to jit.

@jiqing-feng
Copy link
Contributor Author

jiqing-feng commented Mar 22, 2023

@gante Thanks for your attention. Would you please help me to merge it? Thanks! I think the demand for jit trace will grow, and I hope we can keep on working on it so it will be adapted to all models and all tasks in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants