Repository navigation
[RFC] Common Benchmark Suite - #77
Conversation
ab288ec to
9dea7b1
Compare
|
Will someone be able to help add suitable reviewers? 🙂 (maybe include @jpienaar @GMNGeoffrey @julianwa @mariewhite @reichlfl). |
|
Kindly ping for visibility : ) Also tag @powderluv who might be interested |
|
Nice work, looking forward to this! :) I just left a few nit comments mostly, thanks. |
| classes only describe the compiler-agnostic parts of a benchmark, which include: | ||
|
|
||
| * Model class to define model metadata and the artifacts (e.g., exported | ||
| StableHLO of the model, input data, and expected output data). |
There was a problem hiding this comment.
I assume it is implicit here but "expected output data" may come with a defined "numerical tolerance"? It'll be interesting to see how to express this: maybe it can be a python function that takes the result and the reference and perform any kind of comparison deemed suitable for this model, returning a pass/fail signal?
There was a problem hiding this comment.
Agree, I think when we provide the expected output, it should also include the information about how to compare and the tolerance. The benchmark suite will provide the python function to take expected output, tolerance, and model output and return the comparison results.
I updated the text here and in the code example to demonstrate how it works.
| * Model class to define model metadata and the artifacts (e.g., exported | ||
| StableHLO of the model, input data, and expected output data). | ||
| * Device class to define device specifications to run benchmarks (e.g., GCP VM | ||
| models). |
There was a problem hiding this comment.
Are we restricting this iteration to single device models? Single node? Otherwise what kind of topology are we thinking of?
(caveat: I'm not sure how to do multi-node without a framework, so a model defined with a "stable HLO export" may not be able to express this?)
There was a problem hiding this comment.
I believe we focus on the single device models in the initial iteration in our benchmark strategy RFC (We mentioned that for GPU benchmarks but not for CPU. I posted a question for clarification there). I can see the DeviceSpec in the example below can be extended to describe a multi-node topology, but it's a little bit hard to design before knowing what kinds of multi-node benchmarks we want.
The model artifact will also include its framework's implementation (which is described in the example). Updated the text here to clarify.
| # E.g., c2-standard-16 | ||
| device_model: str | ||
| # E.g., linux-x86_64 | ||
| device_architecture: str |
There was a problem hiding this comment.
With accelerators, the concept of "architecture" is a bit blurry to me: is this only about the host? Is it important to be able to select the right precompiled image of the framework to deploy? (otherwise I'd think that pip or cmake or the local system would "do the right thing" anyway)
There was a problem hiding this comment.
Ah yes, there is confusion here. There should be host_environment and accelerator_architecture to describe the architecture of the accelerator and the host machine connects to the accelerator.
In some cases we want to pre-compile the runtime, tools, and models on separate build machines in workflow and deploy them to the benchmark machines (described by DeviceSpec). For example, cross-compiling and running benchmarks on mobile phones. So build machines need to know the benchmark environments from the benchmark definitions. It also makes sense to run ML compilers on cheaper build machines instead of compiling models on the expensive benchmark machines when possible.
From IREE's experience, to compile the runtime and model, the build machines need to know two things about the benchmark machine: the host environment to run the runtime and the accelerator architecture to optimize for.
I made some changes to include fields to describe both host and accelerator on a benchmark machine.
| # E.g., linux-x86_64 | ||
| device_architecture: str | ||
|
|
||
| class InferenceBenchmark: |
There was a problem hiding this comment.
Curious why an "inference" benchmarks is specific here: what in the metadata would be different for a training benchmark?
There was a problem hiding this comment.
I actually haven't designed training benchmarks yet but my guess is that there will be training parameters and stopping criteria (by reading the MLPerf traning)
In general I think it's a good idea to keep different types of benchmarks separated.
There was a problem hiding this comment.
Yeah I'd kind of like us to avoid baking too much ML stuff into the benchmarking that isn't really the key differentiator. I know we are building things for ML, but I find that sometimes the ML-isms obscure things. So in this case I think the salient point is that it's a single call into a model with a single expected response. It doesn't seem to, for instance, support benchmarking a series of calls into the model. Should it? I think a more descriptive name might fall out of this like SingleCallBenchmark
There was a problem hiding this comment.
I think we should leave the specifics of how the benchmark is called to the implementation. Workloads are so diverse that I don't think the metadata should be imposing how it should execute.
The simplest inference workload is single-shot. However, many inference workloads need multiple calls to eventually get the answer e.g. any model that incorporates time like audio and video processing. Some workloads use multiple models and multiple calls e.g. Stable Diffusion uses 3 models and calls one of the models multiple times. Training workloads would be more complex with many config options.
I'm in favor of making this class more generic like BenchmarkDefinition or BenchmarkInstance. The infra is just concerned about feeding the input data in, checking the outputs are correct, and running it on the specified hardware. Everything else is a black box. We may even want a higher abstraction to a Model like a Workload that could have one or more Models or Microbenchmarks, or be completely up to the implementer (for shiny new things).
There was a problem hiding this comment.
In my naive thought, as we accept the Python module in Model, the multiple-model workload can be represented as a single model composed of multiple models with Python code to describe the data flow between those underlying models. I guess we can rename Model to Workload to give it a more general semantic.
IMO it's something we haven't done before and we should add some those models to the benchmark suite as early as possible to clear out any design issue.
03b1b3f to
0a1618a
Compare
GMNGeoffrey
left a comment
There was a problem hiding this comment.
A number of comments, but overall this LG. Nice work on this :-)
| [OpenXLA Benchmarking Strategy](https://github.com/openxla/community/pull/75) | ||
| outlines a benchmark suite for comparative and regression benchmarking for the | ||
| OpenXLA and third-party compilers that the OpenXLA community is interested in. | ||
| It is part of the **OOBI** (OpenXLA OSS Benchmarking Infrastructure). |
There was a problem hiding this comment.
I think someone mentioned this elsewhere, but our naming here makes less sense in an OSS context. Like of course it's OSS, it's an OSS project :-) Added to that, OSS is an initialism already, so having it within the OOBI initialism is a bit weird. So as much as I like these little guys:
I think we should probably go with just "OBI"
There was a problem hiding this comment.
We also have internal OpenXLA benchmarking infrastructure, so I believe we needed to make that distinction. OOBI and OIBI :)
There was a problem hiding this comment.
Internally we need to make that distinction, but from the perspective of the OSS OpenXLA project it doesn't make much sense
| # For the exported model, it's the URL to fetch the model. | ||
| # For the model implementation with framework, it's the file path to import | ||
| # the Python model module with `importlib.import_module`. This prevents | ||
| # pulling in unnecessary dependencies from those modules. |
There was a problem hiding this comment.
Nice! Thanks for thinking about dependency bloat from the beginning. I was worried that we'd end up importing the world for everything.
| class Model: | ||
| """Model to benchmark.""" | ||
| name: str | ||
| # For the exported model, it's the URL to fetch the model. |
There was a problem hiding this comment.
I think we should specify that this needs to be a stable URL, and should almost certainly be a mirror we control. I'm also slightly tempted to include an artifact digest as well to enforce that a bit, though I suspect some people will get annoyed about that. We could just use content-adressable storage for the models, but I know people also get grumpy about opaque names for things :-)
There was a problem hiding this comment.
Briefly mentioned in the comments. Totally agree to include digest in the definitions for verification.
| hlo_remote_path = common_benchmark.model.source_artifacts[ | ||
| ModelFormat.HLO_DUMP | ||
| ] | ||
| hlo_path = download_file(hlo_remote_path) |
There was a problem hiding this comment.
So say I wanted to make it so my benchmarks use local files and make fetching over the network an out-of-band process (as we discussed recently). Where would that tie in? Is that just a different implementation of this bit? I think I see how this would work because I know something about our current benchmarking, but just from reading this, I'd think we were deeply coupling benchmarks to network access and be somewhat alarmed. Assuming my alarm is unwarranted and you're imagining some kind of config export thingy, can you maybe just add a note of how this sort of thing would be possible without network access deep in the stack?
IMO storing hashes would actually help with this. You could tell the model or input definition "hey I know you want to get this at this URL, but here's a file with the same hash. Use this instead" (except I wouldn't want implicit network access that you then override, so I don't think it should work quite like that).
There was a problem hiding this comment.
Done. Add a few words to explain how it can be done before the benchmark loop.
I'm trying to give a concise example here so that's why I put all the steps in this function to demo the full workflow.
| input_data: List[ModelTestData] | ||
| expected_output: List[ModelTestData] |
There was a problem hiding this comment.
Would framework-level benchmarks have input and output data here or in the Python source? I actually wonder whether framework benchmarks should be a separate category here? I'm unsure though
There was a problem hiding this comment.
I checked with @mariecwhite. In the current use cases, framework-level benchmarks also use numpy tensors as the input/otput (they might convert numpy into framework's tensors in the model scripts). But they might use different data layouts (e.g. NCHW vs. NHWC). Their derived models usually use the same data layout as the source model. Currently TENSFORFLOW_NUMPY, PYTORCH_NUMPY, JAX_NUMPY should be enough, non-numpy formats can be added in the future, if we have other kinds of framework implementations.
I think each model derivation (TF/PyTorch framework implementation, exported StableHLO models...) should describe what kinds of data format they accept/output. In ModelTestData we provide the preprocessed data for each format. More kinds of the data format can also be included in the future, but we likely want to stick to only supporting the data formats of the "source framework model implementations", to avoid exploding the supported formats.
For special cases (e.g. exported models with special data layout transform), they can transform the test data from the source model layout during benchmarking (and they should know how to transform as we provide the data format in the benchmark definition). We can also add the preprocessed data to the ModelTestData, but only when necessary (e.g. We decide to widely support that model format).
| class IreeInferenceBenchmark: | ||
| """Describes an IREE inference benchmark.""" | ||
| # Reference to the base benchmark. | ||
| base_benchmark: benchmark_framework.InferenceBenchmark | ||
| module_generation_config: IreeModuleGenerationConfig | ||
| # IREE runtime driver. | ||
| runtime_driver: str | ||
| extra_runtime_flags: List[str] = [] |
There was a problem hiding this comment.
Interesting, so we're using composition rather than inheritance here? Do we expect the IreeInferenceBenchmark (IREEInferenceBenchmark?) to satisfy some interface?
There was a problem hiding this comment.
Since it's a one-to-many relation (IREE might have multiple benchamrks with different IREE settings on a single common InferenceBenchmark), composition should do a better job than inheritance here (we will need to populate all fields in InferenceBenchmark again if we use inheritance).
For the benchmark interface to satisfy, we might have something like that. But I try not to overwhelm the RFC with too many details.
| ML frameworks, the extra `requirements.txt` will be stored with the benchmark | ||
| definitions and pin the package versions. It is not necessary to install it if |
There was a problem hiding this comment.
Should this be part of the benchmark definition if it's for a source file?
There was a problem hiding this comment.
I think we can track the changes on requirements.txt together with the model implementation code.
Assume we have a way to track the version of framework model implementation (the hash source codes or the git commit hash of the code directory), as requirements.txt stays with the code, any changes on it will also be reflected in that version.
| This will give a simple start and it won't be hard to spin out the comparative | ||
| benchmark workflow into a separate repository if needed. |
stellaraccident
left a comment
There was a problem hiding this comment.
Looks like it has support. I propose landing and noting any ongoing comments or future followups in a section at the bottom, if applicable.
d4b5ae2 to
ed0192d
Compare
f7bf87b to
174abdc
Compare
|
Thanks for all the reviews and I think we don't have a major objection to this idea 🙂 I added a section in the bottom to list the remaining open questions and will track them in the new benchmark repository. |
|
Hi @theadactyl Would you be able to help merge this RFC and create the repository |
|
I can merge. Will look into the new repo |

This is the subsequent RFC of the high-level benchmarking strategy for OpenXLA #75 (in review).
It proposes to create a benchmark suite to fulfill the benchmarking requirements in the strategy.
The temporary links to the high-level strategy RFC will be updated once #75 is merged.