Skip to content

[.ai] document single-file model layout and "don't reimplement Diffus…#14048

Merged
yiyixuxu merged 9 commits into
mainfrom
ai-docs-single-file-and-base-pipeline
Jun 24, 2026
Merged

[.ai] document single-file model layout and "don't reimplement Diffus…#14048
yiyixuxu merged 9 commits into
mainfrom
ai-docs-single-file-and-base-pipeline

Conversation

@yiyixuxu

Copy link
Copy Markdown
Collaborator

adding two gotcha from review in #14040

yiyixuxu and others added 2 commits June 23, 2026 01:51
…ionPipeline"

Two conventions that weren't written down, surfaced while reviewing a new
model/pipeline port:

- models.md: add a "Single-file model layout" section. A model lives in one
  self-contained `transformer_<name>.py`; reuse shared blocks from
  normalization.py/attention.py/embeddings.py and inline model-specific
  variants with `# Copied from` rather than creating per-model
  `attention_processor_<name>.py` / `block_<name>.py` / `rope_<name>.py`
  companion files (no precedent for these in the repo).

- pipelines.md: add gotcha #7, "Don't reimplement DiffusionPipeline." A
  subclass adds only pipeline-specific steps; device placement, offloading,
  execution-device resolution, and module registration already exist on the
  base class. No custom device/offload manager, no `device=` arg on
  `__call__`, no `set_<component>` setters.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Drop the implementation-specific examples (Lumina class names, per-model
transformer_*.py citations) and state the single-file policy generally:
everything (attention, blocks, RoPE, model-specific layers) in one model
file, with shared blocks either imported from the common modules or brought
in via `# Copied from ... with Old->New`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions github-actions Bot added the size/S PR with diff < 50 LOC label Jun 23, 2026
yiyixuxu and others added 6 commits June 23, 2026 01:59
The positive statement (everything in one model file) already conveys it;
drop the companion-module filename list and the editorializing.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
State the principle and the canonical base APIs; drop the implementation-
specific anti-pattern callouts (enable_*_flag booleans, set_<component>
setters, the device= arg, a shadow self.execution_device).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Drop the per-category API bullets; one sentence — don't add device
placement, offloading, or component loading/registration logic on a
subclass, it's on the base class. Can expand later if needed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…#8

main's newly merged "don't modify registered component on the fly" keeps #7;
our "don't reimplement DiffusionPipeline" becomes #8 (appended after it).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@yiyixuxu yiyixuxu requested a review from dg845 June 23, 2026 02:23
Comment thread .ai/models.md Outdated

@dg845 dg845 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

Co-authored-by: dg845 <58458699+dg845@users.noreply.github.com>
@yiyixuxu yiyixuxu merged commit 03040e5 into main Jun 24, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S PR with diff < 50 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants