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

Proposal: Set batch size as a first-class argument in the CLI #31

Open
jeremyfowers opened this issue Dec 1, 2023 · 0 comments
Open
Labels
enhancement New feature or request p2 Low priority

Comments

@jeremyfowers
Copy link
Collaborator

Batching is the most common parameter in AI benchmarking, and it applies to virtually every model.

We currently support batching via the --script-args argument, which allows a batching parameter to be sent to the input script and therefore the model. We also support --script-args="--batch_size N" as the "official" semantics for passing batch size to a turnkey model.

However, we have a major flaw: batch size is never reflected in our results. We report throughput as "invocations per second", not "inferences per second". The latter would be far more useful.

To truly report "inferences per second" we need to somehow parse the batch size and then pass it into the benchmarking software, so that we can report inferences_per_second = invocations_per_second * batch_size

There may not be any perfect way to solve this, but we should still do something. Some issues with potential solutions:

  1. Models/applications that were not created by the TurnkeyML maintainers may use other arg names for batching (e.g., --batch, --batching, etc.)
  2. Batch size is usually the outer dimension of the input tensor, but not always (e.g., in LSTM it is the second dimension)
  3. Batch size may be hardcoded in the application (not configurable as a script arg at all)

A bulletproof (if verbose) solution could be like this:

  1. batch_size is a reserved --script-arg name that indicates the batch size, and will be used in IPS computations
  2. A new CLI arg --batch-arg-name can override the reserved term batch_size to some other name such as batching in corner cases where the model/app developer has named their arg something else.
  3. a new CLI arg --batch-size=N can set the batch size in both the inputs (by setting --script-args="<batch_arg_name>=N) as well as in the IPS calculation. This is needed in the case where batch size is hardcoded in the application.

cc @danielholanda @viradhak-amd @ramkrishna2910

@jeremyfowers jeremyfowers added enhancement New feature or request p2 Low priority labels Dec 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request p2 Low priority
Projects
None yet
Development

No branches or pull requests

1 participant