Enable scribe environment for compile-time benchmarks if requested. (#133891)

Signed-off-by: Edward Z. Yang <ezyang@meta.com>

Pull Request resolved: https://github.com/pytorch/pytorch/pull/133891
Approved by: https://github.com/malfet
This commit is contained in:
Edward Z. Yang
2024-08-21 07:07:01 -07:00
committed by PyTorch MergeBot
parent 750d68ff70
commit 32e057636c
7 changed files with 104 additions and 2 deletions

View File

@ -397,6 +397,8 @@ DYNAMO_BENCHMARK_FLAGS=()
pr_time_benchmarks() {
pip_install --user "fbscribelogger"
TEST_REPORTS_DIR=$(pwd)/test/test-reports
mkdir -p "$TEST_REPORTS_DIR"
PYTHONPATH=$(pwd)/benchmarks/dynamo/pr_time_benchmarks source benchmarks/dynamo/pr_time_benchmarks/benchmark_runner.sh "$TEST_REPORTS_DIR/pr_time_benchmarks_after.txt" "benchmarks/dynamo/pr_time_benchmarks/benchmarks"

View File

@ -82,6 +82,10 @@ on:
required: false
description: |
HF Auth token to avoid rate limits when downloading models or datasets from hub
SCRIBE_GRAPHQL_ACCESS_TOKEN:
required: false
description: |
FB app token to write to scribe endpoint
outputs:
@ -94,6 +98,7 @@ on:
jobs:
build:
environment: ${{ github.ref == 'refs/heads/main' && 'scribe-protected' || startsWith(github.ref, 'refs/heads/release/') && 'scribe-protected' || contains(github.event.pull_request.labels.*.name, 'ci-scribe') && 'scribe-pr' || '' }}
# Don't run on forked repos
if: github.repository_owner == 'pytorch'
runs-on: ${{ inputs.runner_prefix}}${{ inputs.runner }}
@ -194,6 +199,7 @@ jobs:
DEBUG: ${{ inputs.build-with-debug && '1' || '0' }}
OUR_GITHUB_JOB_ID: ${{ steps.get-job-id.outputs.job-id }}
HUGGING_FACE_HUB_TOKEN: ${{ secrets.HUGGING_FACE_HUB_TOKEN }}
SCRIBE_GRAPHQL_ACCESS_TOKEN: ${{ secrets.SCRIBE_GRAPHQL_ACCESS_TOKEN }}
USE_SPLIT_BUILD: ${{ inputs.use_split_build }}
run: |
# detached container should get cleaned up by teardown_ec2_linux

View File

@ -67,6 +67,7 @@ jobs:
strategy:
matrix: ${{ fromJSON(inputs.test-matrix) }}
fail-fast: false
environment: ${{ github.ref == 'refs/heads/main' && 'scribe-protected' || startsWith(github.ref, 'refs/heads/release/') && 'scribe-protected' || contains(github.event.pull_request.labels.*.name, 'ci-scribe') && 'scribe-pr' || '' }}
runs-on: ${{ matrix.runner }}
timeout-minutes: ${{ matrix.mem_leak_check == 'mem_leak_check' && 600 || inputs.timeout-minutes }}
steps:

View File

@ -63,6 +63,7 @@ jobs:
{ config: "distributed", shard: 1, num_shards: 2, runner: "${{ needs.get-label-type.outputs.label-type }}amz2023.linux.2xlarge" },
{ config: "distributed", shard: 2, num_shards: 2, runner: "${{ needs.get-label-type.outputs.label-type }}amz2023.linux.2xlarge" },
]}
secrets: inherit
linux-jammy-py3_8-gcc11-test:
name: linux-jammy-py3.8-gcc11
@ -74,6 +75,7 @@ jobs:
build-environment: linux-jammy-py3.8-gcc11
docker-image: ${{ needs.linux-jammy-py3_8-gcc11-build.outputs.docker-image }}
test-matrix: ${{ needs.linux-jammy-py3_8-gcc11-build.outputs.test-matrix }}
secrets: inherit
linux-docs:
name: linux-docs
@ -83,6 +85,7 @@ jobs:
runner_prefix: amz2023.
build-environment: linux-jammy-py3.8-gcc11
docker-image: ${{ needs.linux-jammy-py3_8-gcc11-build.outputs.docker-image }}
secrets: inherit
linux-jammy-py3_8-gcc11-no-ops:
name: linux-jammy-py3.8-gcc11-no-ops
@ -96,6 +99,7 @@ jobs:
{ include: [
{ config: "default", shard: 1, num_shards: 1 },
]}
secrets: inherit
linux-jammy-py3_8-gcc11-pch:
name: linux-jammy-py3.8-gcc11-pch
@ -109,6 +113,7 @@ jobs:
{ include: [
{ config: "default", shard: 1, num_shards: 1 },
]}
secrets: inherit
linux-jammy-py3_10-clang15-asan-build:
name: linux-jammy-py3.10-clang15-asan
@ -128,6 +133,7 @@ jobs:
{ config: "default", shard: 6, num_shards: 6, runner: "${{ needs.get-label-type.outputs.label-type }}amz2023.linux.4xlarge" },
]}
sync-tag: asan-build
secrets: inherit
linux-jammy-py3_10-clang15-asan-test:
@ -141,6 +147,7 @@ jobs:
docker-image: ${{ needs.linux-jammy-py3_10-clang15-asan-build.outputs.docker-image }}
test-matrix: ${{ needs.linux-jammy-py3_10-clang15-asan-build.outputs.test-matrix }}
sync-tag: asan-test
secrets: inherit
linux-focal-py3_8-clang10-onnx-build:
name: linux-focal-py3.8-clang10-onnx
@ -155,6 +162,7 @@ jobs:
{ config: "default", shard: 1, num_shards: 2, runner: "${{ needs.get-label-type.outputs.label-type }}amz2023.linux.2xlarge" },
{ config: "default", shard: 2, num_shards: 2, runner: "${{ needs.get-label-type.outputs.label-type }}amz2023.linux.2xlarge" },
]}
secrets: inherit
linux-focal-py3_8-clang10-onnx-test:
name: linux-focal-py3.8-clang10-onnx
@ -166,6 +174,7 @@ jobs:
build-environment: linux-focal-py3.8-clang10-onnx
docker-image: ${{ needs.linux-focal-py3_8-clang10-onnx-build.outputs.docker-image }}
test-matrix: ${{ needs.linux-focal-py3_8-clang10-onnx-build.outputs.test-matrix }}
secrets: inherit
linux-focal-py3_8-clang10-build:
name: linux-focal-py3.8-clang10
@ -197,6 +206,7 @@ jobs:
build-environment: linux-focal-py3.8-clang10
docker-image: ${{ needs.linux-focal-py3_8-clang10-build.outputs.docker-image }}
test-matrix: ${{ needs.linux-focal-py3_8-clang10-build.outputs.test-matrix }}
secrets: inherit
linux-focal-py3_11-clang10-build:
name: linux-focal-py3.11-clang10
@ -218,6 +228,7 @@ jobs:
{ config: "dynamo", shard: 2, num_shards: 3, runner: "${{ needs.get-label-type.outputs.label-type }}amz2023.linux.2xlarge" },
{ config: "dynamo", shard: 3, num_shards: 3, runner: "${{ needs.get-label-type.outputs.label-type }}amz2023.linux.2xlarge" },
]}
secrets: inherit
linux-focal-py3_11-clang10-test:
name: linux-focal-py3.11-clang10
@ -229,6 +240,7 @@ jobs:
build-environment: linux-focal-py3.11-clang10
docker-image: ${{ needs.linux-focal-py3_11-clang10-build.outputs.docker-image }}
test-matrix: ${{ needs.linux-focal-py3_11-clang10-build.outputs.test-matrix }}
secrets: inherit
linux-focal-py3_12-clang10-build:
name: linux-focal-py3.12-clang10
@ -248,6 +260,7 @@ jobs:
{ config: "dynamo", shard: 2, num_shards: 3, runner: "${{ needs.get-label-type.outputs.label-type }}amz2023.linux.2xlarge" },
{ config: "dynamo", shard: 3, num_shards: 3, runner: "${{ needs.get-label-type.outputs.label-type }}amz2023.linux.2xlarge" },
]}
secrets: inherit
linux-focal-py3_12-clang10-test:
name: linux-focal-py3.12-clang10
@ -258,6 +271,7 @@ jobs:
docker-image: ${{ needs.linux-focal-py3_12-clang10-build.outputs.docker-image }}
test-matrix: ${{ needs.linux-focal-py3_12-clang10-build.outputs.test-matrix }}
timeout-minutes: 600
secrets: inherit
linux-focal-cuda11_8-py3_10-gcc9-build:
name: linux-focal-cuda11.8-py3.10-gcc9
@ -273,6 +287,7 @@ jobs:
{ config: "distributed", shard: 2, num_shards: 3, runner: "${{ needs.get-label-type.outputs.label-type }}amz2023.linux.8xlarge.nvidia.gpu" },
{ config: "distributed", shard: 3, num_shards: 3, runner: "${{ needs.get-label-type.outputs.label-type }}amz2023.linux.8xlarge.nvidia.gpu" },
]}
secrets: inherit
linux-focal-cuda11_8-py3_10-gcc9-test:
name: linux-focal-cuda11.8-py3.10-gcc9
@ -285,6 +300,7 @@ jobs:
build-environment: linux-focal-cuda11.8-py3.10-gcc9
docker-image: ${{ needs.linux-focal-cuda11_8-py3_10-gcc9-build.outputs.docker-image }}
test-matrix: ${{ needs.linux-focal-cuda11_8-py3_10-gcc9-build.outputs.test-matrix }}
secrets: inherit
linux-focal-cuda12_1-py3_10-gcc9-build:
name: linux-focal-cuda12.1-py3.10-gcc9
@ -302,6 +318,7 @@ jobs:
{ config: "default", shard: 4, num_shards: 5, runner: "${{ needs.get-label-type.outputs.label-type }}amz2023.linux.4xlarge.nvidia.gpu" },
{ config: "default", shard: 5, num_shards: 5, runner: "${{ needs.get-label-type.outputs.label-type }}amz2023.linux.4xlarge.nvidia.gpu" },
]}
secrets: inherit
linux-focal-cuda12_1-py3_10-gcc9-test:
name: linux-focal-cuda12.1-py3.10-gcc9
@ -314,6 +331,7 @@ jobs:
build-environment: linux-focal-cuda12.1-py3.10-gcc9
docker-image: ${{ needs.linux-focal-cuda12_1-py3_10-gcc9-build.outputs.docker-image }}
test-matrix: ${{ needs.linux-focal-cuda12_1-py3_10-gcc9-build.outputs.test-matrix }}
secrets: inherit
linux-jammy-py3-clang12-mobile-build:
name: linux-jammy-py3-clang12-mobile-build
@ -328,6 +346,7 @@ jobs:
{ include: [
{ config: "default", shard: 1, num_shards: 1 },
]}
secrets: inherit
linux-jammy-cuda-11_8-cudnn9-py3_8-clang12-build:
name: linux-jammy-cuda11.8-cudnn9-py3.8-clang12
@ -341,6 +360,7 @@ jobs:
{ include: [
{ config: "default", shard: 1, num_shards: 1 },
]}
secrets: inherit
linux-focal-py3-clang9-mobile-custom-build-static:
name: linux-focal-py3-clang9-mobile-custom-build-static
@ -355,6 +375,7 @@ jobs:
{ include: [
{ config: "default", shard: 1, num_shards: 1 },
]}
secrets: inherit
linux-focal-py3_8-clang9-xla-build:
name: linux-focal-py3_8-clang9-xla
@ -368,6 +389,7 @@ jobs:
{ include: [
{ config: "xla", shard: 1, num_shards: 1, runner: "${{ needs.get-label-type.outputs.label-type }}amz2023.linux.12xlarge" },
]}
secrets: inherit
linux-focal-py3_8-clang9-xla-test:
name: linux-focal-py3_8-clang9-xla
@ -377,6 +399,7 @@ jobs:
build-environment: linux-focal-py3.8-clang9-xla
docker-image: ${{ needs.linux-focal-py3_8-clang9-xla-build.outputs.docker-image }}
test-matrix: ${{ needs.linux-focal-py3_8-clang9-xla-build.outputs.test-matrix }}
secrets: inherit
win-vs2019-cpu-py3-build:
# don't run build twice on main
@ -395,6 +418,7 @@ jobs:
{ config: "default", shard: 2, num_shards: 3, runner: "${{ needs.get-label-type.outputs.label-type }}windows.4xlarge.nonephemeral" },
{ config: "default", shard: 3, num_shards: 3, runner: "${{ needs.get-label-type.outputs.label-type }}windows.4xlarge.nonephemeral" },
]}
secrets: inherit
linux-focal-cpu-py3_10-gcc9-bazel-test:
name: linux-focal-cpu-py3.10-gcc9-bazel-test
@ -409,6 +433,7 @@ jobs:
{ include: [
{ config: "default", shard: 1, num_shards: 1, runner: "${{ needs.get-label-type.outputs.label-type }}amz2023.linux.4xlarge" },
]}
secrets: inherit
linux-focal-cuda12_1-py3_10-gcc9-bazel-test:
name: linux-focal-cuda12.1-py3.10-gcc9-bazel-test
@ -423,6 +448,7 @@ jobs:
{ include: [
{ config: "default", shard: 1, num_shards: 1, runner: "${{ needs.get-label-type.outputs.label-type }}amz2023.linux.4xlarge.nvidia.gpu" },
]}
secrets: inherit
linux-focal-cuda12_4-py3_10-gcc9-bazel-test:
name: linux-focal-cuda12.4-py3.10-gcc9-bazel-test
@ -437,6 +463,7 @@ jobs:
{ include: [
{ config: "default", shard: 1, num_shards: 1, runner: "${{ needs.get-label-type.outputs.label-type }}amz2023.linux.4xlarge.nvidia.gpu" },
]}
secrets: inherit
linux-focal-py3-clang9-android-ndk-r21e-gradle-custom-build-single:
name: linux-focal-py3-clang9-android-ndk-r21e-gradle-custom-build-single
@ -448,6 +475,7 @@ jobs:
{ include: [
{ config: "default", shard: 1, num_shards: 1, runner: "linux.2xlarge" },
]}
secrets: inherit
linux-focal-py3-clang9-android-ndk-r21e-gradle-custom-build-single-full-jit:
name: linux-focal-py3-clang9-android-ndk-r21e-gradle-custom-build-single-full-jit
@ -459,6 +487,7 @@ jobs:
{ include: [
{ config: "default", shard: 1, num_shards: 1, runner: "linux.2xlarge" },
]}
secrets: inherit
linux-jammy-py3_8-gcc11-mobile-lightweight-dispatch-build:
name: linux-jammy-py3.8-gcc11-mobile-lightweight-dispatch-build
@ -473,6 +502,7 @@ jobs:
{ include: [
{ config: "default", shard: 1, num_shards: 1 },
]}
secrets: inherit
linux-focal-rocm6_1-py3_8-build:
# don't run build twice on main
@ -491,6 +521,7 @@ jobs:
{ config: "default", shard: 2, num_shards: 3, runner: "linux.rocm.gpu" },
{ config: "default", shard: 3, num_shards: 3, runner: "linux.rocm.gpu" },
]}
secrets: inherit
linux-focal-cuda12_1-py3_10-gcc9-sm86-build:
name: linux-focal-cuda12.1-py3.10-gcc9-sm86
@ -509,6 +540,7 @@ jobs:
{ config: "default", shard: 4, num_shards: 5, runner: "${{ needs.get-label-type.outputs.label-type }}amz2023.linux.g5.4xlarge.nvidia.gpu" },
{ config: "default", shard: 5, num_shards: 5, runner: "${{ needs.get-label-type.outputs.label-type }}amz2023.linux.g5.4xlarge.nvidia.gpu" },
]}
secrets: inherit
linux-focal-cuda12_1-py3_10-gcc9-sm86-test:
name: linux-focal-cuda12.1-py3.10-gcc9-sm86
@ -520,6 +552,7 @@ jobs:
build-environment: linux-focal-cuda12.1-py3.10-gcc9-sm86
docker-image: ${{ needs.linux-focal-cuda12_1-py3_10-gcc9-sm86-build.outputs.docker-image }}
test-matrix: ${{ needs.linux-focal-cuda12_1-py3_10-gcc9-sm86-build.outputs.test-matrix }}
secrets: inherit
linux-jammy-py3-clang12-executorch-build:
name: linux-jammy-py3-clang12-executorch
@ -533,6 +566,7 @@ jobs:
{ include: [
{ config: "executorch", shard: 1, num_shards: 1, runner: "${{ needs.get-label-type.outputs.label-type }}amz2023.linux.2xlarge" },
]}
secrets: inherit
linux-jammy-py3-clang12-executorch-test:
name: linux-jammy-py3-clang12-executorch
@ -542,6 +576,7 @@ jobs:
build-environment: linux-jammy-py3-clang12-executorch
docker-image: ${{ needs.linux-jammy-py3-clang12-executorch-build.outputs.docker-image }}
test-matrix: ${{ needs.linux-jammy-py3-clang12-executorch-build.outputs.test-matrix }}
secrets: inherit
linux-focal-py3_12-clang10-experimental-split-build:
name: linux-focal-py3.12-clang10-experimental-split-build
@ -561,6 +596,8 @@ jobs:
{ config: "dynamo", shard: 2, num_shards: 3, runner: "amz2023.linux.2xlarge" },
{ config: "dynamo", shard: 3, num_shards: 3, runner: "amz2023.linux.2xlarge" },
]}
secrets: inherit
linux-focal-py3_12-clang10-experimental-split-build-test:
name: linux-focal-py3.12-clang10-experimental-split-build
uses: ./.github/workflows/_linux-test.yml
@ -570,6 +607,7 @@ jobs:
docker-image: ${{ needs.linux-focal-py3_12-clang10-experimental-split-build.outputs.docker-image }}
test-matrix: ${{ needs.linux-focal-py3_12-clang10-experimental-split-build.outputs.test-matrix }}
timeout-minutes: 600
secrets: inherit
linux-focal-cuda12_1-py3_10-gcc9-inductor-build:
name: cuda12.1-py3.10-gcc9-sm75
@ -584,6 +622,7 @@ jobs:
{ include: [
{ config: "pr_time_benchmarks", shard: 1, num_shards: 1, runner: "linux.g4dn.metal.nvidia.gpu" },
]}
secrets: inherit
linux-focal-cuda12_1-py3_10-gcc9-inductor-test:
name: cuda12.1-py3.10-gcc9-sm75
@ -593,3 +632,4 @@ jobs:
build-environment: linux-focal-cuda12.1-py3.10-gcc9-sm75
docker-image: ${{ needs.linux-focal-cuda12_1-py3_10-gcc9-inductor-build.outputs.docker-image }}
test-matrix: ${{ needs.linux-focal-cuda12_1-py3_10-gcc9-inductor-build.outputs.test-matrix }}
secrets: inherit

View File

@ -170,6 +170,7 @@ jobs:
{ config: "slow", shard: 3, num_shards: 3, runner: "${{ needs.get-label-type.outputs.label-type }}amz2023.linux.4xlarge" },
]}
sync-tag: asan-build
secrets: inherit
linux-jammy-py3_10-clang15-asan-test:
name: linux-jammy-py3.10-clang15-asan
@ -182,3 +183,4 @@ jobs:
docker-image: ${{ needs.linux-jammy-py3_10-clang15-asan-build.outputs.docker-image }}
test-matrix: ${{ needs.linux-jammy-py3_10-clang15-asan-build.outputs.test-matrix }}
sync-tag: asan-test
secrets: inherit

View File

@ -201,6 +201,7 @@ jobs:
{ config: "default", shard: 2, num_shards: 3, runner: "${{ needs.get-label-type.outputs.label-type }}windows.4xlarge.nonephemeral" },
{ config: "default", shard: 3, num_shards: 3, runner: "${{ needs.get-label-type.outputs.label-type }}windows.4xlarge.nonephemeral" },
]}
secrets: inherit
win-vs2019-cpu-py3-test:
name: win-vs2019-cpu-py3
@ -237,6 +238,7 @@ jobs:
{ config: "default", shard: 2, num_shards: 2, runner: "linux.rocm.gpu" },
{ config: "distributed", shard: 1, num_shards: 1, runner: "linux.rocm.gpu" },
]}
secrets: inherit
linux-focal-rocm6_1-py3_8-test:
permissions:

View File

@ -1,9 +1,55 @@
import csv
from abc import ABC, abstractmethod
from fbscribelogger import make_scribe_logger
import torch._C._instruction_counter as i_counter
scribe_log_torch_benchmark_compile_time = make_scribe_logger(
"TorchBenchmarkCompileTime",
"""
struct TorchBenchmarkCompileTimeLogEntry {
# The commit SHA that triggered the workflow, e.g., 02a6b1d30f338206a71d0b75bfa09d85fac0028a. Derived from GITHUB_SHA.
4: optional string commit_sha;
# The unit timestamp in second for the Scuba Time Column override
6: optional i64 time;
7: optional i64 instruction_count; # Instruction count of compilation step
8: optional string name; # Benchmark name
# Commit date (not author date) of the commit in commit_sha as timestamp, e.g., 1724208105. Increasing if merge bot is used, though not monotonic; duplicates occur when stack is landed.
16: optional i64 commit_date;
# A unique number for each workflow run within a repository, e.g., 19471190684. Derived from GITHUB_RUN_ID.
17: optional string github_run_id;
# A unique number for each attempt of a particular workflow run in a repository, e.g., 1. Derived from GITHUB_RUN_ATTEMPT.
18: optional string github_run_attempt;
# Indicates if branch protections or rulesets are configured for the ref that triggered the workflow run. Derived from GITHUB_REF_PROTECTED.
20: optional bool github_ref_protected;
# The fully-formed ref of the branch or tag that triggered the workflow run, e.g., refs/pull/133891/merge or refs/heads/main. Derived from GITHUB_REF.
21: optional string github_ref;
# The weight of the record according to current sampling rate
25: optional i64 weight;
# The name of the current job. Derived from JOB_NAME, e.g., linux-jammy-py3.8-gcc11 / test (default, 3, 4, amz2023.linux.2xlarge).
26: optional string github_job;
# The GitHub user who triggered the job. Derived from GITHUB_TRIGGERING_ACTOR.
27: optional string github_triggering_actor;
# A unique number for each run of a particular workflow in a repository, e.g., 238742. Derived from GITHUB_RUN_NUMBER.
28: optional string github_run_number_str;
}
""", # noqa: B950
)
class BenchmarkBase(ABC):
_instruction_count = False
@ -58,7 +104,10 @@ class BenchmarkBase(ABC):
def collect_all(self):
self.results = []
if self._instruction_count:
self.results.append(
(self.name(), "instruction_count", self.count_instructions())
r = self.count_instructions()
self.results.append((self.name(), "instruction_count", r))
scribe_log_torch_benchmark_compile_time(
name=self.name(),
instruction_count=r,
)
return self