Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BT] add decoder benchmark script #857

Merged
merged 6 commits into from
Mar 6, 2023

Conversation

younesbelkada
Copy link
Contributor

What does this PR do?

This PR adds the benchmark script adapted for decoder-based models as well, to benchmark the speedup we obtain with torch.sdpa and transformers models

cc @fxmarty

Comment on lines 122 to 123
max_new_tokens=max_token,
use_cache=False,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why use_cache = False? I'd rather benchmark with the cache enabled.

Also, can we rather set min_length=length, max_length=length? So that we can generate a specific length.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's because max_length is deprecated, yes we can add min_length I think let me try

max_new_tokens=max_token,
use_cache=False,
)
_ = hf_model.generate(input_ids, generation_config=gen_config)
Copy link
Contributor

Choose a reason for hiding this comment

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

the input_ids are not defined no?

Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense to pass attention_mask as well? Not sure

start_event = torch.cuda.Event(enable_timing=True)
end_event = torch.cuda.Event(enable_timing=True)
start_event.record()
for _ in range(num_batches):
_ = model(input_ids, masks)
if is_decoder:
_ = model.generate(input_ids, generation_config=generation_config)
Copy link
Contributor

Choose a reason for hiding this comment

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

the input_ids is not defined no?

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Mar 6, 2023

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

Copy link
Contributor

@fxmarty fxmarty left a comment

Choose a reason for hiding this comment

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

Feel free to merge once you think it's good. I think we should use use_cache=True to benchmark.

@younesbelkada younesbelkada merged commit c7b384a into huggingface:main Mar 6, 2023
@younesbelkada younesbelkada deleted the benchmark-bt branch March 6, 2023 16:27
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint.

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.

4 participants