Skip to content

Commit fb12446

Browse files
authored
Merge branch 'main' into skyreels-v2-single-file
2 parents c629b53 + 2d0110f commit fb12446

86 files changed

Lines changed: 5991 additions & 3282 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.ai/AGENTS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Diffusers — Agent Guide
22

3+
## Setup
4+
5+
- Local Claude Code agents: run `make claude` after cloning to wire the [skills](#skills) under `.claude/`.
6+
- Local OpenAI Codex agents: run `make codex` after cloning to wire the [skills](#skills) under `.agents/`.
7+
38
## Coding style
49

510
Strive to write code as simple and explicit as possible.

.ai/review-rules.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ Common mistakes are covered in the common-mistakes / gotcha sections in [AGENTS.
1515

1616
- **Ephemeral context.** Comments, docstrings, and files that only made sense to the current PR's author or reviewer don't help a future reader/user/developer. Examples: `# per reviewer comment on PR #NNNN`, `# as discussed in review`, `# TODO from offline chat`, debug printouts. Same for files: parity harnesses, comparison scripts, anything in `scripts/` with hardcoded developer paths or imports from the reference repo. State the *reason* so the comment stands alone, or drop it.
1717

18+
## Documentation impact
19+
20+
A PR can leave existing docs stale or surface a pattern worth recording. Scan the docs related to what the PR touches and flag updates as a **suggestions / additional info** section (not blocking):
21+
22+
- **Usage docs.** New or changed public behavior — a new pipeline/model, a new argument, changed defaults, a renamed API — should have matching updates in `docs/`, docstrings, and examples. Flag any that now describe outdated behavior or that are missing for the new surface.
23+
- **Agent docs.** If the review turns up a rule, pattern, or common gotcha that isn't written down yet — especially one the author got wrong or that you had to reason out — propose adding it to the relevant agent guide ([AGENTS.md](AGENTS.md), [models.md](models.md), [pipelines.md](pipelines.md), [modular.md](modular.md), a skill, or this file) so the next contributor/agent gets it for free instead of repeating the mistake.
24+
1825
## Dead code analysis (new models)
1926

2027
When reviewing a PR that adds a new model, trace how the model is actually called from the pipeline to identify likely dead code. Include the results as a **suggestions / additional info** section in your review (not as blocking comments — the findings are advisory).

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@ Fixes # (issue)
1717

1818
## Before submitting
1919
- [ ] Did you use an AI agent (Claude Code, Codex, Cursor, etc.) to help with this PR? If so:
20-
- [ ] Did you point it at the project conventions in [`.ai/`](https://github.com/huggingface/diffusers/tree/main/.ai) (e.g. via `make claude` / `make codex`)? See [Coding with AI agents](https://github.com/huggingface/diffusers/blob/main/CONTRIBUTING.md#coding-with-ai-agents).
20+
- [ ] Did you read the [Coding with AI agents](https://huggingface.co/docs/diffusers/main/en/conceptual/contribution#coding-with-ai-agents) guide?
2121
- [ ] Did you self-review the diff against [`.ai/review-rules.md`](https://github.com/huggingface/diffusers/blob/main/.ai/review-rules.md)?
22-
- [ ] Did you read the [contributor guideline](https://github.com/huggingface/diffusers/blob/main/CONTRIBUTING.md)?
23-
- [ ] Did you read our [philosophy doc](https://github.com/huggingface/diffusers/blob/main/PHILOSOPHY.md)? (important for complex PRs)
22+
- [ ] Did you read the [contributor guideline](https://huggingface.co/docs/diffusers/main/en/conceptual/contribution)?
23+
- [ ] Did you read our [philosophy doc](https://huggingface.co/docs/diffusers/main/en/conceptual/philosophy)? (important for complex PRs)
2424
- [ ] Was this discussed/approved via a GitHub issue or the [forum](https://discuss.huggingface.co/c/discussion-related-to-httpsgithubcomhuggingfacediffusers/63)? Please add a link to it if that's the case.
2525
- [ ] Did you make sure to update the documentation with your changes? Here are the
2626
[documentation guidelines](https://github.com/huggingface/diffusers/tree/main/docs), and
2727
[here are tips on formatting docstrings](https://github.com/huggingface/diffusers/tree/main/docs#writing-source-documentation).
2828
- [ ] Did you write any new necessary tests?
29+
- [ ] Are you the author (or part of the team) of the model/pipeline (only applicable for model/pipeline related PRs)?
2930

3031

3132
## Who can review?
Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
name: GPU Tests from PR Comment
2+
3+
# Lets maintainers (admin / write access) run GPU tests on a PR by commenting:
4+
# /diffusers-bot pytest <args>
5+
# e.g. `/diffusers-bot pytest tests/models/test_modeling_common.py -k "some_test"`.
6+
7+
8+
on:
9+
issue_comment:
10+
types: [created]
11+
12+
# Default to read-only; jobs that comment opt into `pull-requests: write` explicitly.
13+
permissions:
14+
contents: read
15+
16+
concurrency:
17+
# A newer command on the same PR supersedes an in-flight one.
18+
group: diffusers-bot-${{ github.event.issue.number }}
19+
cancel-in-progress: true
20+
21+
env:
22+
DIFFUSERS_IS_CI: yes
23+
OMP_NUM_THREADS: 8
24+
MKL_NUM_THREADS: 8
25+
HF_XET_HIGH_PERFORMANCE: 1
26+
PYTEST_TIMEOUT: 600
27+
# Force version overrides across every `uv pip install`: pin tokenizers and the
28+
# torch/torchvision/torchaudio set baked into the image so `-U` installs can't bump
29+
# torch and break torchvision's C++ ABI. Re-written into the file in the install step.
30+
UV_OVERRIDE: /tmp/uv-overrides.txt
31+
32+
jobs:
33+
gate:
34+
name: Authorize & launch
35+
# Only react to `/diffusers-bot pytest …` comments on open PRs.
36+
if: |
37+
github.event.issue.pull_request &&
38+
github.event.issue.state == 'open' &&
39+
startsWith(github.event.comment.body, '/diffusers-bot pytest')
40+
runs-on: ubuntu-22.04
41+
permissions:
42+
pull-requests: write
43+
outputs:
44+
pytest_args: ${{ steps.parse.outputs.pytest_args }}
45+
comment_id: ${{ steps.comment.outputs.comment_id }}
46+
steps:
47+
- name: Check commenter permission
48+
id: auth
49+
env:
50+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
REPO: ${{ github.repository }}
52+
COMMENTER: ${{ github.event.comment.user.login }}
53+
run: |
54+
PERM=$(gh api "repos/${REPO}/collaborators/${COMMENTER}/permission" --jq '.permission' 2>/dev/null || echo "none")
55+
echo "Commenter @${COMMENTER} has permission: ${PERM}"
56+
if [[ "$PERM" == "admin" || "$PERM" == "write" ]]; then
57+
echo "authorized=true" >> "$GITHUB_OUTPUT"
58+
else
59+
echo "authorized=false" >> "$GITHUB_OUTPUT"
60+
fi
61+
62+
- name: Reject unauthorized commenter
63+
if: steps.auth.outputs.authorized != 'true'
64+
env:
65+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
REPO: ${{ github.repository }}
67+
PR: ${{ github.event.issue.number }}
68+
COMMENTER: ${{ github.event.comment.user.login }}
69+
run: |
70+
gh api -X POST "repos/${REPO}/issues/${PR}/comments" \
71+
-f body="🚫 Sorry @${COMMENTER}, you're not authorized to run \`/diffusers-bot\`. Only maintainers with write or admin access can trigger GPU tests." >/dev/null
72+
echo "::error::Only maintainers with write/admin access can run /diffusers-bot."
73+
exit 1
74+
75+
- name: Acknowledge with 👀
76+
env:
77+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78+
REPO: ${{ github.repository }}
79+
COMMENT_ID: ${{ github.event.comment.id }}
80+
run: |
81+
gh api -X POST "repos/${REPO}/issues/comments/${COMMENT_ID}/reactions" -f content="eyes" >/dev/null
82+
83+
- name: Parse pytest args
84+
id: parse
85+
env:
86+
COMMENT_BODY: ${{ github.event.comment.body }}
87+
run: |
88+
# Use only the first line of the comment, strip the command prefix.
89+
FIRST_LINE=$(printf '%s' "$COMMENT_BODY" | head -n1)
90+
ARGS="${FIRST_LINE#/diffusers-bot pytest}"
91+
# Trim surrounding whitespace/CR.
92+
ARGS="$(printf '%s' "$ARGS" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')"
93+
echo "pytest_args=${ARGS}" >> "$GITHUB_OUTPUT"
94+
95+
- name: Post "running" comment
96+
id: comment
97+
env:
98+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
99+
REPO: ${{ github.repository }}
100+
PR: ${{ github.event.issue.number }}
101+
COMMENTER: ${{ github.event.comment.user.login }}
102+
PYTEST_ARGS: ${{ steps.parse.outputs.pytest_args }}
103+
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
104+
run: |
105+
BODY="⏳ Running \`pytest ${PYTEST_ARGS}\` on a GPU runner — [view logs](${RUN_URL}).
106+
107+
Triggered by @${COMMENTER}."
108+
CID=$(gh api -X POST "repos/${REPO}/issues/${PR}/comments" -f body="$BODY" --jq '.id')
109+
echo "comment_id=${CID}" >> "$GITHUB_OUTPUT"
110+
111+
gpu_tests:
112+
name: Run pytest on GPU
113+
needs: gate
114+
runs-on:
115+
group: aws-g4dn-2xlarge
116+
container:
117+
image: diffusers/diffusers-pytorch-cuda
118+
options: --gpus all --shm-size "16gb" --ipc host
119+
# Least privilege: this job checks out and runs untrusted fork code, so it gets no
120+
# write token. Comment writes happen only in `gate`/`report`.
121+
permissions:
122+
contents: read
123+
defaults:
124+
run:
125+
shell: bash
126+
steps:
127+
- name: Checkout PR head
128+
uses: actions/checkout@v6
129+
with:
130+
# Works for forks too — no fork credentials needed.
131+
ref: refs/pull/${{ github.event.issue.number }}/head
132+
fetch-depth: 2
133+
134+
- name: NVIDIA-SMI
135+
run: nvidia-smi
136+
137+
- name: Install dependencies
138+
run: |
139+
printf 'tokenizers<0.23.0\ntorch==2.10.0\ntorchvision==0.25.0\ntorchaudio==2.10.0\n' > "$UV_OVERRIDE"
140+
uv pip install -e ".[quality,training,test]"
141+
uv pip install peft@git+https://github.com/huggingface/peft.git
142+
uv pip uninstall accelerate && uv pip install -U accelerate@git+https://github.com/huggingface/accelerate.git
143+
uv pip uninstall transformers huggingface_hub && UV_PRERELEASE=allow uv pip install -U transformers@git+https://github.com/huggingface/transformers.git
144+
145+
- name: Environment
146+
run: diffusers-cli env
147+
148+
- name: Run pytest
149+
env:
150+
# No secrets here: this step runs untrusted fork code (pytest imports the PR's
151+
# conftest.py/plugins), so exposing a token would let a malicious PR exfiltrate
152+
# it. Public Hub models download without auth; gated-repo tests are unsupported.
153+
# https://pytorch.org/docs/stable/notes/randomness.html#avoiding-nondeterministic-algorithms
154+
CUBLAS_WORKSPACE_CONFIG: :16:8
155+
# Forwarded via env (not interpolated into the script) to avoid breakage on
156+
# quotes/special characters in a legitimate command.
157+
PYTEST_ARGS: ${{ needs.gate.outputs.pytest_args }}
158+
run: |
159+
eval "pytest --make-reports=tests_bot_gpu $PYTEST_ARGS"
160+
161+
- name: Failure short reports
162+
if: ${{ failure() }}
163+
run: |
164+
cat reports/tests_bot_gpu_stats.txt || true
165+
cat reports/tests_bot_gpu_failures_short.txt || true
166+
167+
- name: Test suite reports artifacts
168+
if: ${{ always() }}
169+
uses: actions/upload-artifact@v6
170+
with:
171+
name: bot_gpu_test_reports
172+
path: reports
173+
174+
report:
175+
name: Report status
176+
needs: [gate, gpu_tests]
177+
# Always run so the comment is updated on success, failure, or cancellation —
178+
# but only if `gate` actually posted a comment to update.
179+
if: ${{ always() && needs.gate.outputs.comment_id != '' }}
180+
runs-on: ubuntu-22.04
181+
permissions:
182+
pull-requests: write
183+
steps:
184+
- name: Update comment with final status
185+
env:
186+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
187+
REPO: ${{ github.repository }}
188+
CID: ${{ needs.gate.outputs.comment_id }}
189+
RESULT: ${{ needs.gpu_tests.result }}
190+
PYTEST_ARGS: ${{ needs.gate.outputs.pytest_args }}
191+
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
192+
run: |
193+
case "$RESULT" in
194+
success) EMOJI="✅"; MSG="passed";;
195+
failure) EMOJI="❌"; MSG="failed";;
196+
cancelled) EMOJI="⚠️"; MSG="was cancelled";;
197+
*) EMOJI="⚠️"; MSG="did not run (${RESULT})";;
198+
esac
199+
BODY="${EMOJI} \`pytest ${PYTEST_ARGS}\` ${MSG} on GPU — [view logs](${RUN_URL})."
200+
gh api -X PATCH "repos/${REPO}/issues/comments/${CID}" -f body="$BODY"

.github/workflows/pr_link_issue_reminder.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ on:
66
workflow_dispatch:
77

88
jobs:
9-
remind_or_close:
10-
name: Remind or close PRs without a linked issue
9+
remind:
10+
# Reminds external contributors to link an issue. PRs from maintainers, users
11+
# with write/admin access, and collaborators are skipped by the script.
12+
name: Remind external contributors to link an issue
1113
if: github.repository == 'huggingface/diffusers'
1214
runs-on: ubuntu-22.04
1315
permissions:

.github/workflows/run_tests_from_a_pr.yml

Lines changed: 0 additions & 76 deletions
This file was deleted.

.github/workflows/serge_review.yml

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,9 @@ jobs:
4646
concurrency:
4747
group: claude-ai-review-${{ github.event.issue.number || github.event.pull_request.number }}
4848
cancel-in-progress: false
49-
# A clean GitHub-hosted runner (not the self-hosted VPN group, whose
50-
# pre-existing tailscaled collided with the action's own daemon). The
51-
# Tailscale step below joins this runner to the tailnet so
52-
# https://serge.huggingface.tech/ is reachable.
53-
runs-on: ubuntu-latest
49+
runs-on:
50+
group: aws-general-8-plus
5451
steps:
55-
- name: Connect to Tailscale
56-
uses: tailscale/github-action@v4
57-
with:
58-
oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID_AI_REVIEW }}
59-
oauth-secret: ${{ secrets.TS_AUDIENCE_AI_REVIEW }}
60-
tags: tag:ci
61-
args: --accept-dns=false
62-
6352
- name: Relay event to the Serge GitHub App
6453
env:
6554
WEBHOOK_URL: https://serge.huggingface.tech/webhook

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,5 @@ tags
184184
wandb
185185

186186
# AI agent generated symlinks
187-
/AGENTS.md
188-
/CLAUDE.md
189187
/.agents/skills
190188
/.claude/skills

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.ai/AGENTS.md

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.ai/AGENTS.md

0 commit comments

Comments
 (0)