-
Notifications
You must be signed in to change notification settings - Fork 353
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
Refactor serialization of benchmarks #1131
Conversation
* flatten benchmarks data to make it easier to save documents to a database and query them * split some information into their own fields like backend and device * add new seralized info: - computed values (mean, median, variance, min, max) - number of samples - operation name - tensor shapes if any * serialize to separate files, one file per benchmark run * simplify persistence module to only a save method
For the |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #1131 +/- ##
==========================================
+ Coverage 85.65% 85.67% +0.02%
==========================================
Files 513 513
Lines 56816 56987 +171
==========================================
+ Hits 48665 48823 +158
- Misses 8151 8164 +13 ☔ View full report in Codecov by Sentry. |
I updated the file name with a bench name and the first 8 chars of a random uuid, examples:
The name is passed as an argument to the |
From here: If you’re having trouble remembering how to phrase expect error messages remember to focus on the word “should” as in “env variable should be set by blah” or “the given binary should be available and executable by the current user”. So I just stick to the word should and it works out |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's very good in general. The only issue I see is how often we must tell the name of the benchmark (see my comments for example on unary). Could it not be unified in one place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of adding the new field "operation," we could add a field "ID" instead. "Name" is more generic, and we may have some benchmarks that aren't about single operations. Or maybe we need another structure:
- name (Could have a default implementation
core::any::type_name::<Self>().to_string()
) - shapes
- options (num_repeat, kind, etc.)
The ID could be generated from the concatenation of all of the above.
You are right, I thought about it but I cannot fetch the binary name at runtime, the only references are in Cargo, in the command line, and the source file name. I'll try to find something. |
4bd85a1
to
7a8bc99
Compare
Ready for another round of review. Files on disk naming examples:
I added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not save the num_repeat
in the database for now. I plan on eventually removing it since it is often confused with num_samples
. It was useful when we didn't have a reliable way to sync a backend without actually reading the data. Repeating an execution meant that the data reading was less impactful.
@nathanielsimard I already save the number of samples. See the gist. I believe the repeat can still be useful, check the docstring I added to it, I think it is a good concept to have:
Say we have a very quick operation to bench, repeating it to get a meaningful sample can be useful. |
Ideally the notion of repeat could be integrated into the main loop but I tried it and it was not as trivial to do. |
902441b
to
000af88
Compare
We decided to remove the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
Remove operations field Correctly create one file per ran benchmark
4727dce
to
278984c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's very nice, I think we reached the beautiful code stage.
I have only two minor requests and then it's good to go
See changes below for a list of changes.
I will add an "upload" function to the persistence module in a further PR.
The current naming of the saved files need a bit of work, currently I just do
benchmarks_<timestamp>.json
but we could have some race condition and get some files overridden. --> We updated it tobench_<name>_<timestamp>
.The computed values are saved in seconds, maybe we should save them in milliseconds ? --> We changed to microseconds.
You can see an example of produced file here: https://gist.github.com/syl20bnr/b0fdbbf0c3877b9e4ddf262a9cc388ac
Checklist
run-checks all
script has been executed.Related Issues/PRs
Changes
num_repeats
in benches execute functions.Testing
Tested serialization to disk with all the available benchmarks.