Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,54 @@ jobs:

echo "Successfully pushed benchmark results to branch ${{ github.head_ref || github.ref_name }}"

# Weight diff for full bench runs. The standalone weight-diff workflow
# can't trigger off the bot's push (GITHUB_TOKEN does not retrigger
# workflows), so we compute and post the diff here instead. Both writers
# use the same `weight-diff` sticky header, so this overwrites the
# last comment from the standalone workflow.
- name: Materialize master weights for weight-diff
if: steps.prepare.outputs.benchmark_type == 'full'
run: |
git fetch --no-tags --depth=1 origin master:refs/remotes/origin/master
mkdir -p /tmp/weights-master/runtime/hydradx/src/weights
git archive origin/master runtime/hydradx/src/weights 2>/dev/null \
| tar -x -C /tmp/weights-master || true

- name: Generate weight diff report
if: steps.prepare.outputs.benchmark_type == 'full'
id: weight-diff
run: |
set -euo pipefail
python3 scripts/weight-diff/weight_diff.py \
--old /tmp/weights-master/runtime/hydradx/src/weights \
--new runtime/hydradx/src/weights \
> weight-diff-report.md

if grep -q 'No weight changes detected' weight-diff-report.md; then
echo "has_changes=false" >> "$GITHUB_OUTPUT"
else
echo "has_changes=true" >> "$GITHUB_OUTPUT"
fi

echo "----- report preview -----"
head -40 weight-diff-report.md

- name: Post weight-diff comment after full bench
if: steps.prepare.outputs.benchmark_type == 'full' && steps.weight-diff.outputs.has_changes == 'true'
uses: marocchino/sticky-pull-request-comment@v2.1.0
with:
header: weight-diff
path: weight-diff-report.md
number: ${{ steps.prepare.outputs.pr_number }}

- name: Remove stale weight-diff comment after full bench (no changes)
if: steps.prepare.outputs.benchmark_type == 'full' && steps.weight-diff.outputs.has_changes == 'false'
uses: marocchino/sticky-pull-request-comment@v2.1.0
with:
header: weight-diff
delete: true
number: ${{ steps.prepare.outputs.pr_number }}

- name: Comment benchmark results to the pull request
if: github.event_name == 'pull_request'
uses: marocchino/sticky-pull-request-comment@v2.1.0
Expand Down
59 changes: 59 additions & 0 deletions .github/workflows/weight-diff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: weight-diff

on:
pull_request:

permissions:
pull-requests: write
contents: read

jobs:
weight-diff:
name: Weight diff
runs-on: ubuntu-latest
steps:
- name: Checkout PR
uses: actions/checkout@v4

- name: Fetch master
run: git fetch --no-tags --depth=1 origin master:refs/remotes/origin/master

- name: Materialize master weights into a temp dir
run: |
mkdir -p /tmp/weights-master/runtime/hydradx/src/weights
# Extract weights from master. If the path doesn't exist on master
# (e.g. brand-new directory in this PR), proceed with an empty dir.
git archive origin/master runtime/hydradx/src/weights 2>/dev/null \
| tar -x -C /tmp/weights-master || true

- name: Generate weight diff report
id: diff
run: |
set -euo pipefail
python3 scripts/weight-diff/weight_diff.py \
--old /tmp/weights-master/runtime/hydradx/src/weights \
--new runtime/hydradx/src/weights \
> weight-diff-report.md

if grep -q 'No weight changes detected' weight-diff-report.md; then
echo "has_changes=false" >> "$GITHUB_OUTPUT"
else
echo "has_changes=true" >> "$GITHUB_OUTPUT"
fi

echo "----- report preview -----"
head -40 weight-diff-report.md

- name: Post weight diff comment
if: steps.diff.outputs.has_changes == 'true'
uses: marocchino/sticky-pull-request-comment@v2.1.0
with:
header: weight-diff
path: weight-diff-report.md

- name: Remove stale weight-diff comment when no changes
if: steps.diff.outputs.has_changes == 'false'
uses: marocchino/sticky-pull-request-comment@v2.1.0
with:
header: weight-diff
delete: true
Loading
Loading