-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Restructure skill files and reference guides for CLI based installation. #14454
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "name": "diffusers", | ||
| "description": "Conventions and task skills for contributing to diffusers", | ||
| "author": { | ||
| "name": "The Hugging Face team" | ||
| }, | ||
| "homepage": "https://huggingface.co/docs/diffusers/main/en/conceptual/contribution#coding-with-ai-agents", | ||
| "repository": "https://github.com/huggingface/diffusers", | ||
| "license": "Apache-2.0", | ||
| "keywords": [ | ||
| "diffusers", | ||
| "diffusion-models", | ||
| "contributing" | ||
| ] | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "name": "diffusers", | ||
| "version": "0.1.0", | ||
| "description": "Conventions and task skills for contributing to diffusers", | ||
| "skills": "./skills/" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,8 +2,44 @@ | |
|
|
||
| ## Setup | ||
|
|
||
| - Local Claude Code agents: run `make claude` after cloning to wire the [skills](#skills) under `.claude/`. | ||
| - Local OpenAI Codex agents: run `make codex` after cloning to wire the [skills](#skills) under `.agents/`. | ||
| We recommend developing in a virtual environment managed by [uv](https://docs.astral.sh/uv/): | ||
|
|
||
| ```bash | ||
| uv venv && source .venv/bin/activate | ||
| uv pip install -e . # provides diffusers-cli | ||
| ``` | ||
|
|
||
| List the available skills, and what each one is for, with: | ||
|
|
||
| ```bash | ||
| diffusers-cli skills list | ||
| ``` | ||
|
|
||
| Install them with: | ||
|
|
||
| ```bash | ||
| diffusers-cli skills add <skill name> # install one, or --all for every skill | ||
| # --claude / --codex / --cursor to pick one target | ||
| ``` | ||
|
|
||
| `diffusers-cli skills update` refreshes what you installed. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where is this handled? |
||
|
|
||
| `make claude` and `make codex` used to symlink `.claude/skills` and `.agents/skills` at `.ai/skills`. If those symlinks | ||
| are still around, remove them before installing — otherwise the install writes through them into `.ai/` itself: | ||
|
|
||
|
Comment on lines
+27
to
+29
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But we're removing those |
||
| ```bash | ||
| rm .claude/skills .agents/skills | ||
| ``` | ||
|
|
||
| Claude Code and Codex can also install via plugins | ||
|
|
||
| ```bash | ||
| claude plugin marketplace add huggingface/diffusers | ||
| claude plugin install diffusers@diffusers-skills --scope project | ||
|
|
||
| codex plugin marketplace add huggingface/diffusers # then install from the Plugins Directory | ||
| ``` | ||
|
|
||
|
|
||
| ## Coding style | ||
|
|
||
|
|
@@ -27,10 +63,10 @@ Strive to write code as simple and explicit as possible. | |
|
|
||
| ## Reference guides | ||
|
|
||
| - **Models** — see [models.md](models.md) for model conventions, attention pattern, implementation rules, dependencies, and gotchas. For adding or converting a model, use the [model-integration](./skills/model-integration/SKILL.md) skill. | ||
| - **Pipelines** — see [pipelines.md](pipelines.md) for pipeline conventions, patterns, and gotchas. | ||
| - **Modular pipelines** — see [modular.md](modular.md) for modular pipeline conventions, patterns, and gotchas. | ||
| - **Tests** — see [testing.md](testing.md) for test conventions: required test layers, tester mixins, and dummy-component rules. | ||
| - **Models** — see [models.md](references/models.md) for model conventions, attention pattern, implementation rules, dependencies, and gotchas. For adding or converting a model, use the [model-integration](./skills/model-integration/SKILL.md) skill. | ||
| - **Pipelines** — see [pipelines.md](references/pipelines.md) for pipeline conventions, patterns, and gotchas. | ||
| - **Modular pipelines** — see [modular.md](references/modular.md) for modular pipeline conventions, patterns, and gotchas. | ||
| - **Tests** — see [testing.md](references/testing.md) for test conventions: required test layers, tester mixins, and dummy-component rules. | ||
|
Comment on lines
+66
to
+69
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it solve the discovery problem? |
||
|
|
||
| ## Skills | ||
|
|
||
|
|
@@ -43,4 +79,4 @@ Task-specific guides live in `.ai/skills/` and are loaded on demand by AI agents | |
|
|
||
| ## Self-review before a PR | ||
|
|
||
| Before opening a PR, run self-review against [review-rules.md](review-rules.md). The [self-review skill](skills/self-review/SKILL.md) runs this as the same pass the `@claude` CI reviewer uses. Share the final report on the PR (description or comment) — see the skill for details. | ||
| Before opening a PR, run self-review against [review-rules.md](references/review-rules.md). The [self-review skill](./skills/self-review/SKILL.md) runs this as the same pass the `@claude` CI reviewer uses. Share the final report on the PR (description or comment) — see the skill for details. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would the agents be able to discover it after the necessary skills are installed? |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json", | ||
| "name": "diffusers", | ||
| "description": "Conventions and task skills for contributing to diffusers", | ||
| "author": { | ||
| "name": "The Hugging Face team" | ||
| }, | ||
| "homepage": "https://huggingface.co/docs/diffusers/main/en/conceptual/contribution#coding-with-ai-agents", | ||
| "repository": "https://github.com/huggingface/diffusers", | ||
| "license": "Apache-2.0", | ||
| "keywords": [ | ||
| "diffusers", | ||
| "diffusion-models", | ||
| "contributing" | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,16 +3,16 @@ | |
| Review-specific rules for Claude. Focus on correctness — style is handled by ruff. | ||
|
|
||
| Before reviewing, read and apply the guidelines in: | ||
| - [AGENTS.md](AGENTS.md) — coding style, copied code | ||
| - the repo's `AGENTS.md` — coding style, copied code | ||
| - [models.md](models.md) — model conventions, attention pattern, implementation rules, dependencies, gotchas | ||
| - [pipelines.md](pipelines.md) — pipeline conventions, coding style, gotchas | ||
| - [modular.md](modular.md) — modular pipeline conventions, patterns, common mistakes | ||
| - [testing.md](testing.md) — test conventions: required test layers, tester mixins, dummy-component rules. When a PR adds or changes tests, check them against this guide. | ||
| - [skills/model-integration/pitfalls.md](skills/model-integration/pitfalls.md) — known pitfalls causing numerical discrepancies between the reference implementation and the diffusers port (dtype mismatches, config assumptions, etc.) | ||
| - [skills/model-integration/pitfalls.md](https://github.com/huggingface/diffusers/blob/main/.ai/skills/model-integration/pitfalls.md) — known pitfalls causing numerical discrepancies between the reference implementation and the diffusers port (dtype mismatches, config assumptions, etc.) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we just removing it from AGENT.md? Additionally, wouldn't we have a similar problem like https://huggingface.slack.com/archives/C065E480NN9/p1786544533688239? |
||
|
|
||
| ## Common mistakes | ||
|
|
||
| Common mistakes are covered in the common-mistakes / gotcha sections in [AGENTS.md](AGENTS.md), [models.md](models.md), [pipelines.md](pipelines.md), and [modular.md](modular.md). Additionally, watch for below patterns that aren't covered there: | ||
| Common mistakes are covered in the common-mistakes / gotcha sections in `AGENTS.md`, [models.md](models.md), [pipelines.md](pipelines.md), and [modular.md](modular.md). Additionally, watch for below patterns that aren't covered there: | ||
|
|
||
| - **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. | ||
|
|
||
|
|
@@ -21,7 +21,7 @@ Common mistakes are covered in the common-mistakes / gotcha sections in [AGENTS. | |
| 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): | ||
|
|
||
| - **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. | ||
| - **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. Human review comments on the PR are a good source for these: if a human reviewer pointed something out and your review missed it, that usually indicates a doc gap — figure out what's missing and propose the addition. | ||
| - **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`, [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. Human review comments on the PR are a good source for these: if a human reviewer pointed something out and your review missed it, that usually indicates a doc gap — figure out what's missing and propose the addition. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we just removing it from |
||
|
|
||
| ## Dead code analysis (new models) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,7 +36,7 @@ Follow the style introduced in [#14113](https://github.com/huggingface/diffusers | |
|
|
||
| - Location: `tests/modular_pipelines/<model>/test_modular_pipeline_<model>.py` (one test class per blockset / pipeline variant). | ||
| - Subclass `ModularPipelineTesterMixin` (from `..test_modular_pipelines_common`) — it runs the pipeline end-to-end (call signature, batch consistency, float16, device placement) against a tiny checkpoint. | ||
| - Set `pipeline_class`, `pipeline_blocks_class`, `pretrained_model_name_or_path`, `params` / `batch_params`, and implement `get_dummy_inputs(seed=0)`. Set `expected_workflow_blocks` to pin the block name → class ordering per workflow. | ||
| - Set `pipeline_class`, `pipeline_blocks_class`, `pretrained_model_name_or_path`, `params` / `batch_params`, and implement `get_dummy_inputs(seed=0)`. Set `expected_workflow_blocks` to pin the block name → class ordering per workflow (only for blocksets with a `_workflow_map` — with a single workflow the list would just restate the class definition), and `expected_workflow_defaults` to pin each workflow's components, pipeline configs, and inputs — required ones by name, optional ones with their defaults. A pipeline without workflows pins its full blockset under the `None` key. An optional `component_configs` entry pins config values of `from_config` components against their creating spec (e.g. the guider scale that tells a base and a distilled preset apart); pretrained components take their config from the repo, so there is nothing block-level to pin. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems unrelated change? |
||
| - `pretrained_model_name_or_path` is a tiny repo with real components (tiny transformer, real scheduler / VAE / tokenizer configs). Develop against a personal repo; tiny repos ultimately live under `hf-internal-testing/` — not merge-blocking, a maintainer moves it before or after merge. | ||
| - **The tiny repo must mirror the real checkpoint's shape** — same index file type, same pipeline-level config keys, a scheduler configured like the real one. A fixture that doesn't look like the published repos tests a loading/config path no user will ever hit, while the path users *do* hit stays uncovered. If the model ships variants with different configs (base/distilled, different schedules), make one tiny repo and test class per variant — see the flux2 klein base/distilled split. | ||
| - **Bespoke tests go on the tester class as methods**, not as module-level functions — the mixin is pytest-style, so fixtures (`tmp_path`, `pytest.raises`, parametrize) all work in methods. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -146,12 +146,11 @@ diffusers-cli run --model my-user/my-denoise-block --trust-remote-code \ | |
|
|
||
| ## Verifying the install | ||
|
|
||
| If `diffusers-cli` isn't on PATH, see the install verification section of | ||
| [`../diffusers-cli/SKILL.md`](../diffusers-cli/SKILL.md#verifying-the-cli-is-installed). | ||
| If `diffusers-cli` isn't on PATH, see the install verification section of the `diffusers-cli` skill. | ||
|
|
||
| ## Related | ||
|
|
||
| - [`diffusers-cli` skill](../diffusers-cli/SKILL.md) — once your block is uploaded, `schema`/`run` | ||
| - the `diffusers-cli` skill — once your block is uploaded, `schema`/`run` | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Without the link or reference, would it not leave the agent to guess? |
||
| let you call it from the terminal without writing Python. | ||
| - diffusers' [modular pipelines docs](../../../docs/source/en/modular_diffusers) — for writing the block | ||
| - diffusers' [modular pipelines docs](https://huggingface.co/docs/diffusers/main/en/modular_diffusers/overview) — for writing the block | ||
| class itself. | ||
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.
(curiosity): why is this needed?