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

[Docs] Benchmark docs #5360

Merged

Conversation

patrickvonplaten
Copy link
Contributor

@patrickvonplaten patrickvonplaten commented Jun 29, 2020

This PR updates the docs for benchmarks and adds a README.md where the community can post their benchmark results.

Would be happy about Feedback from @sgugger and @LysandreJik .

@LysandreJik - I deleted the part about "This work was done by Timothy Liu." because the links were broken.


If you would like to list benchmark results on your favorite models of the [model hub](https://huggingface.co/models) here, please open a Pull Request and add it below.

| Benchmark description | Results | Environment info | Author |
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there one number we could put in the actual table. Like tokens/second or MB/1000 tokens so that this table is more than just a ton of links?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd also have a Framework column instead of including in description. And maybe also Date

Copy link
Contributor

Choose a reason for hiding this comment

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

I love this idea though!

Copy link
Member

Choose a reason for hiding this comment

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

How good is GitHub at diff'ing large CSV files? I was thinking of copying all results into a single, monster (multi-dimensional?) spreadsheet like @LysandreJik's spreadsheet

>>> python examples/benchmarking/run_benchmark_tf.py --help


An instantiated benchmark object can then simply be run by calling ``benchmark.run()``.
Copy link
Contributor

Choose a reason for hiding this comment

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

this seems to not linearly follow from the command line example above.

Copy link
Contributor

Choose a reason for hiding this comment

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

should be closer to L34


Here, three arguments are given to the benchmark argument data classes, namely ``models``, ``batch_sizes``, and ``sequence_lengths``. The argument ``models`` is required and expects a :obj:`list` of model identifiers from the `model hub <https://huggingface.co/models>`__
The :obj:`list` arguments ``batch_sizes`` and ``sequence_lengths`` define the size of the ``input_ids`` on which the model is benchmarked.
There are many more parameters that can be configured via the benchmark argument data classes. For more detail on these one can either directly consult the files
Copy link
Contributor

Choose a reason for hiding this comment

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

I would have one example with all reasonable clargs. It's easier to delete than add.

Copy link
Contributor

@sshleifer sshleifer left a comment

Choose a reason for hiding this comment

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

Great idea. I also tried to promote sharing seq2seq results through wandb (cc: @clmnt), have not gotten much usage yet but maybe I will eventually!

How to benchmark 🤗 Transformer models
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The classes :obj:`PyTorchBenchmark` and :obj:`TensorflowBenchmark` allow to flexibly benchmark 🤗 Transformer models.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use :class:~transformers.PyTorchBenchmark and :class:~transformers.TensorflowBenchmark so that we get a link to the doc (once it's added ;-) ) here and in the rest of the document.

@patrickvonplaten
Copy link
Contributor Author

Actually will make a separate PR for the examples README.md - to have the docs in v3.0.0.

Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

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

Very cool!

How to benchmark 🤗 Transformer models
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The classes :obj:`PyTorchBenchmark` and :obj:`TensorflowBenchmark` allow to flexibly benchmark 🤗 Transformer models.
Copy link
Member

Choose a reason for hiding this comment

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

🤠what does this mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure where this comes from actually :D -> was supposed to be a HF smiley

Copy link
Member

Choose a reason for hiding this comment

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

haha very random

docs/source/benchmarks.rst Outdated Show resolved Hide resolved
Co-authored-by: Lysandre Debut <lysandre@huggingface.co>
Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

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

@LysandreJik Are the doctest included in the tests now? I think this file should be ignored if that's the case because:

  • is it fast enough?
  • the output seems very dependent of the system


Hereby, `inference` is defined by a single forward pass, and `training` is defined by a single forward pass and backward pass.

The benchmark classes :obj:`PyTorchBenchmark` and :obj:`TensorflowBenchmark` expect an object of type :obj:`PyTorchBenchmarkArguments` and :obj:`TensorflowBenchmarkArguments`, respectively, for instantiation. :obj:`PyTorchBenchmarkArguments` and :obj:`TensorflowBenchmarkArguments` are data classes and contain all relevant configurations for their corresponding benchmark class.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same for :obj:PyTorchBenchmarkArguments and :obj:TensorflowBenchmarkArguments

(PS: if this is still experimental and can be renamed, Tensorflow is spelled TensorFlow normally, PyTorchBenchmark has the right spelling)

@LysandreJik
Copy link
Member

@sgugger right now it's not ignored, so the slow test will fail because the output isn't the same. I don't think it's too big of a deal though, we can fix that after the release with only partial testing of the file.

@patrickvonplaten
Copy link
Contributor Author

Thanks for the review. Addressed them and also renamed the classes for consistency.

Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

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

Very cool!

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.

None yet

5 participants