Skip to content

Conversation

jainapurva
Copy link
Contributor

@jainapurva jainapurva commented Feb 21, 2025

This is the first PR, in the benchmarking effort. It provides the outline to setup inference microbenchmarking for quant api's in torchao.

The different inputs like quantization techniques, matrix sizes, compile, sparsity etc, will be given as input to the python script. The options are re-defined in the scipt for quantization techniques, and a developer can add new quant technique. The script will generate a csv with performance numbers, and that'll be used to plot charts and as an input to dashboard . The script performs the following tasks:

  • Take input as .yml
  • Performs benchmarking for quantize_ APIs eval time for configurations
  • Record all the config params and their respective time in csv file.
  • Test cases

Future PRs will include more config options and process the generated results.

benchmark_config.yml

# Sample configuration for inference kernel benchmarks
quantization_config_recipe_names:
  - "baseline"  # String format is same as llama/generate.py
  - "int8wo"
  - "int4wo-128"
output_dir: "benchmarks/microbenchmarks/test/results"  # Directory for results and plots
model_params:
  matrix_shapes:
    - name: "custom"
      shapes: [
        [1024, 1024, 1024],  # [m, k, n]
        [2048, 4096, 1024],
        [4096, 4096, 1024]
      ]
  high_precision_dtype: "torch.bfloat16"
  use_torch_compile: true
  torch_compile_mode: "max-autotune"
  device: "cuda"  # Change this to "cuda", "mps", "xpu", or "cpu" as needed
  model_type: "linear"

Run command:

python benchmarks/microbenchmarks/benchmark_runner.py --config benchmarks/microbenchmarks/benchmark_config.yml

Output will be stored in

benchmarks/microbenchmarks/results/results.csv

Copy link

pytorch-bot bot commented Feb 21, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/1759

Note: Links to docs will display an error until the docs builds have been completed.

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 21, 2025
@jainapurva jainapurva added topic: new feature Use this tag if this PR adds a new feature topic: performance Use this tag if this PR improves the performance of a feature labels Feb 25, 2025
@jainapurva jainapurva requested a review from HDCharles February 25, 2025 20:32
@jainapurva jainapurva marked this pull request as ready for review February 25, 2025 22:02
Copy link
Contributor

@HDCharles HDCharles left a comment

Choose a reason for hiding this comment

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

lgtm

@jainapurva jainapurva merged commit 6b76adb into main Mar 17, 2025
16 of 17 checks passed
liangel-02 pushed a commit that referenced this pull request Aug 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. topic: new feature Use this tag if this PR adds a new feature topic: performance Use this tag if this PR improves the performance of a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants