-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add TF MNIST classification cost benchmark #33391
Merged
+91
−7
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8b5ae3f
Add TF MNIST classification cost benchmark
jrmccluskey 80b01ad
linting
jrmccluskey e8b189d
Generalize to single workflow file for cost benchmarks
jrmccluskey d9fd867
fix incorrect UTC time in comment
jrmccluskey 6976360
move wordcount to same workflow
jrmccluskey a2a60fb
update workflow job name
jrmccluskey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
91 changes: 91 additions & 0 deletions
91
.github/workflows/beam_CostBenchmark_Python_TF_MNIST_Classification_Dataflow.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
name: Cost Benchmark Python TF MNIST Classification Dataflow | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
#Setting explicit permissions for the action to avoid the default permissions which are `write-all` in case of pull_request_target event | ||
permissions: | ||
actions: write | ||
pull-requests: read | ||
checks: read | ||
contents: read | ||
deployments: read | ||
id-token: none | ||
issues: read | ||
discussions: read | ||
packages: read | ||
pages: read | ||
repository-projects: read | ||
security-events: read | ||
statuses: read | ||
|
||
# This allows a subsequently queued workflow run to interrupt previous runs | ||
concurrency: | ||
group: '${{ github.workflow }} @ ${{ github.event.issue.number || github.sha || github.head_ref || github.ref }}-${{ github.event.schedule || github.event.comment.id || github.event.sender.login }}' | ||
cancel-in-progress: true | ||
|
||
env: | ||
DEVELOCITY_ACCESS_KEY: ${{ secrets.GE_ACCESS_TOKEN }} | ||
GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GE_CACHE_USERNAME }} | ||
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GE_CACHE_PASSWORD }} | ||
INFLUXDB_USER: ${{ secrets.INFLUXDB_USER }} | ||
INFLUXDB_USER_PASSWORD: ${{ secrets.INFLUXDB_USER_PASSWORD }} | ||
|
||
jobs: | ||
beam_Inference_Python_Benchmarks_Dataflow: | ||
if: | | ||
github.event_name == 'workflow_dispatch' | ||
runs-on: [self-hosted, ubuntu-20.04, main] | ||
timeout-minutes: 900 | ||
name: ${{ matrix.job_name }} (${{ matrix.job_phrase }}) | ||
strategy: | ||
matrix: | ||
job_name: ["beam_CostBenchmark_Python_TF_MNIST_Classification_Dataflow"] | ||
job_phrase: ["Run TF MNIST Classification Cost Benchmark"] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup repository | ||
uses: ./.github/actions/setup-action | ||
with: | ||
comment_phrase: ${{ matrix.job_phrase }} | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
github_job: ${{ matrix.job_name }} (${{ matrix.job_phrase }}) | ||
- name: Setup Python environment | ||
uses: ./.github/actions/setup-environment-action | ||
with: | ||
python-version: '3.10' | ||
- name: Prepare test arguments | ||
uses: ./.github/actions/test-arguments-action | ||
with: | ||
test-type: load | ||
test-language: python | ||
argument-file-paths: | | ||
${{ github.workspace }}/.github/workflows/cost-benchmarks-pipeline-options/python_tf_mnist_classification.txt | ||
# The env variables are created and populated in the test-arguments-action as "<github.job>_test_arguments_<argument_file_paths_index>" | ||
- name: get current time | ||
run: echo "NOW_UTC=$(date '+%m%d%H%M%S' --utc)" >> $GITHUB_ENV | ||
- name: run wordcount on Dataflow Python | ||
uses: ./.github/actions/gradle-command-self-hosted-action | ||
timeout-minutes: 30 | ||
with: | ||
gradle-command: :sdks:python:apache_beam:testing:load_tests:run | ||
arguments: | | ||
-PloadTest.mainClass=apache_beam.testing.benchmarks.inference.tensorflow_mnist_classification_cost_benchmark \ | ||
-Prunner=DataflowRunner \ | ||
-PpythonVersion=3.10 \ | ||
'-PloadTest.args=${{ env.beam_Inference_Python_Benchmarks_Dataflow_test_arguments_1 }} --job_name=benchmark-tests-tf-mnist-classification-python-${{env.NOW_UTC}} --input_file=gs://apache-beam-ml/testing/inputs/it_mnist_data.csv --output_file=gs://temp-storage-for-end-to-end-tests/wordcount/result_tf_mnist-${{env.NOW_UTC}}.txt --model=gs://apache-beam-ml/models/tensorflow/mnist/' \ | ||
29 changes: 29 additions & 0 deletions
29
.github/workflows/cost-benchmarks-pipeline-options/python_tf_mnist_classification.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
--region=us-central1 | ||
--machine_type=n1-standard-2 | ||
--num_workers=1 | ||
--disk_size_gb=50 | ||
--autoscaling_algorithm=NONE | ||
--input_options={} | ||
--staging_location=gs://temp-storage-for-perf-tests/loadtests | ||
--temp_location=gs://temp-storage-for-perf-tests/loadtests | ||
--requirements_file=apache_beam/ml/inference/tensorflow_tests_requirements.txt | ||
--publish_to_big_query=true | ||
--metrics_dataset=beam_run_inference | ||
--metrics_table=tf_mnist_classification | ||
--runner=DataflowRunner |
41 changes: 41 additions & 0 deletions
41
...pache_beam/testing/benchmarks/inference/tensorflow_mnist_classification_cost_benchmark.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# pytype: skip-file | ||
|
||
import logging | ||
|
||
from apache_beam.examples.inference import tensorflow_mnist_classification | ||
from apache_beam.testing.load_tests.dataflow_cost_benchmark import DataflowCostBenchmark | ||
|
||
|
||
class TensorflowMNISTClassificationCostBenchmark(DataflowCostBenchmark): | ||
def __init__(self): | ||
super().__init__() | ||
|
||
def test(self): | ||
extra_opts = {} | ||
extra_opts['input'] = self.pipeline.get_option('input_file') | ||
extra_opts['output'] = self.pipeline.get_option('output_file') | ||
extra_opts['model_path'] = self.pipeline.get_option('model') | ||
tensorflow_mnist_classification.run( | ||
self.pipeline.get_full_options_as_args(**extra_opts), | ||
save_main_session=False) | ||
|
||
|
||
if __name__ == '__main__': | ||
logging.basicConfig(level=logging.INFO) | ||
TensorflowMNISTClassificationCostBenchmark().run() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Should we consider running multiple benchmarks in the same workflow instead of a workflow per test? The advantage would be having fewer things to monitor/maintain
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.
Eventually we can bundle them either by framework or put them all together in one workflow, this is largely just me building on the wordcount example benchmark by having a RunInference-specific instance (the most important distinction is the need to include a requirements file for Dataflow workers, but the pattern will largely hold for custom containers with CUDA deps too.)
If we wanted to go ahead and choose one of those routes we could go ahead and do that now + set the workflow up for cron scheduling, I'm not opposed to that.
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'd be in favor of just doing that now - I think a single workflow will end up being easier to manage, and we can always parallelize via jobs within the workflow if needed
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.
Updated
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.
Can we move https://github.com/apache/beam/blob/master/.github/workflows/beam_Wordcount_Python_Cost_Benchmark_Dataflow.yml into this file as well?
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.
easy enough, done