-
Notifications
You must be signed in to change notification settings - Fork 474
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
Make backend names in JSON reports match burnbench CLI #1375
Make backend names in JSON reports match burnbench CLI #1375
Conversation
I found this quite handy and wanted to open it up for comments from maintainers. I've used this to plot the data, which I can also contribute somewhere. import json
import os
import seaborn as sns
import matplotlib.pyplot as plt
from pandas import DataFrame
data = {
"benchmark": [],
"backendConfigName": [],
"mean": [],
"median": [],
"min": [],
"max": []
}
for file in os.listdir("./"):
if file.endswith(".json"):
with open(file, "r") as f:
result = json.load(f)
data["benchmark"].append(result["name"])
data["backendConfigName"].append(result["backendConfigName"])
data["mean"].append(result["mean"] / 1000.0) # convert to miliseconds keeping decimal point
data["median"].append(result["median"])
data["min"].append(result["min"])
data["max"].append(result["max"])
plt.figure(figsize=(28, 20))
benchmarks = DataFrame(data)
p = sns.swarmplot(
data=benchmarks,
x="backendConfigName", y="mean", hue="benchmark",
log_scale=False,
legend=True,
palette="Set2",
s=10, marker="D", linewidth=1,
)
for i in p.get_ygridlines():
i.set_linestyle(':')
i.set_linewidth(0.5)
i.set_visible(True)
plt.ylabel("Mean Duration (miliseconds)")
plt.xlabel("Backends")
plt.legend(title="Benchmark")
plt.xticks(rotation=45)
plt.show() |
86b297b
to
4757e32
Compare
/// "min": "duration in microseconds", | ||
/// "max": "duration in microseconds", | ||
/// "median": "duration in microseconds", | ||
/// "mean": "duration in microseconds", | ||
/// "variance": "duration in microseconds" |
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 suppose this should be split into a separate commit. Ideally, it'd be great if this was in the benchmarking doc. It took me an attempt to change the formatting of results on stdout before I found out about the JSON files.
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 don't think we should pass the backend name in all function calls, I would put it into the benchmark trait. In the future we might change that backend_name to any runtime information that we need to collect.
@nathanielsimard sure, I've not spent any time thinking about the design, was just getting something to work and figured I'd open a PR and see if this is deemed useful at all. |
5da0e08
to
55b5941
Compare
@nathanielsimard PTAL, I've moved the logic into |
d4943e3
to
899ad6e
Compare
6c44c34
to
cf2962a
Compare
crates/burn-jit/src/backend.rs
Outdated
@@ -27,6 +27,14 @@ impl<R: Runtime> Backend for JitBackend<R> { | |||
format!("jit<{}>", R::name()) | |||
} | |||
|
|||
fn config_name(_device: &Self::Device) -> Option<String> { | |||
// match R::config_name(device) { |
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.
no so sure what to do here...
crates/burn-ndarray/src/backend.rs
Outdated
@@ -21,6 +21,18 @@ impl Default for NdArrayDevice { | |||
} | |||
} | |||
|
|||
fn config_name() -> String { |
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've moved this one to the top of the file since it seem right to have features config macros up-front, not inside the trait defintion, so this way it seemed more readable to me - no surprises lower-down surprises ;)
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.
There is something that bothers me with the naming/implementation. There is a lot of overlapping information.
I think it might be better to have somthing as such:
fn device_features(device: &B::Device) -> Vec<String> {
let mut features = Vec::new();
#[cfg(feature = "std")]
features.push("std".into());
#[cfg(feature = "blas-openblas")]
features.push("openblas".into());
match device {
Cuda => features.push("cuda".into());
Metal => features.push("metal".into());
};
features
}
@syl20bnr do you have an opinion on this?
crates/burn-candle/src/backend.rs
Outdated
fn config_name(device: &Self::Device) -> Option<String> { | ||
match device { | ||
CandleDevice::Cpu => Some(String::from("candle-cpu")), | ||
CandleDevice::Cuda(_) | CandleDevice::Metal(_) => Some(String::from("candle-gpu")), |
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 add candle-cuda
and candle-metal
in this case.
9349b24
to
36f4364
Compare
I feel that we can do much simpler by sticking closer to what this PR is all about. We could just store the arguments passed on the command line. The serialized arguments would be an object |
@syl20bnr I agree in principle, although I'm not sure if I have more time for this. I did say in the PR title that it's about matching the names of backends, which is one surface area, but there are other ways of looking at it. Namely, I just want to plot the results and need keys that I could relate to. If burnbench just produced a plot for me, I'd also be quite happy and wouldn't need to worry about all this. So I'm not necessarily sure preservation of CLI arguments is the right UX facet to lean on, perhaps producing plots could be more useful, the rest is implementation detail. Of course, it depends on how far you want to take burnbench. |
I understand and the current interaction between burnbench and the actual benchmarks is a bit contrieved and it would need a bit of refactoring. Currently the benchmark itself is responsible of persistence and upload of results which should now be the responsibility of our burnbench runner. Once we moved these responsibilities to our runner it will be easier to serialize more contextual informations and more. For the plots we are indeed working on it and it will soon be announced on our discord, so stay tune! |
So actually right now preserving CLI args would require some additional tricks, because results are stored per benchmark (and, e.g. data benchmark produces multiple files). Any burnbench invocations with multiple backends and multiple benchmarks would require some special treatment, as backends and benchmarks pass in the CLI would need to be mapped to results actual results and translated to a single invocation. Maybe it's not too hard as there is |
fded72d
to
0b96ec6
Compare
We have been thinking about this and adding a new function to the backend trait just for this is too invasive. In the current situation the probably best option is to modify the macro in |
@syl20bnr what do we do with this PR? Keep it open? |
Yes we can keep it open. @errordeveloper do you have time to change the implementation ? If not I can do it, |
The suggestion makes sense, however I don’t think I will find the time to implement it any time soon.
|
OK. I have assigned to @syl20bnr then. Thank you, @errordeveloper , for the update and PR. |
- add `config_name` to `Backend` trait - add `backend_config_name` to `Benchmark` trait - fix documentation for JSON reports to use correct unit of time
This reverts commit a09edb6.
0b96ec6
to
a6d8c2d
Compare
I made the changes. Here is an example of a report:
|
a6d8c2d
to
6a40f6d
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1375 +/- ##
==========================================
- Coverage 86.31% 86.30% -0.02%
==========================================
Files 683 683
Lines 78091 78107 +16
==========================================
+ Hits 67408 67412 +4
- Misses 10683 10695 +12 ☔ View full report in Codecov by Sentry. |
Great we came to a consensus, it is quite similar to my original change, albeit argument is passed to ‘save’ instead of ‘run_benchmark’.
|
Indeed we went a bit full-circle on this one 😁 |
Pull Request Template
Checklist
run-checks all
script has been executed.Related Issues/PRs
Provide links to relevant issues and dependent PRs.
Changes
Summarize the problem being addressed and your solution.
Testing
Describe how these changes have been tested.