Implementation checklist¶
Use this checklist when implementing or reviewing a model package. For maintenance or documentation, select the affected sections and explain non-applicable evidence in the PR. Complete the applicable items before requesting review, and quote deviations in the pull request description. A workspace member is a package included in the repository's root uv workspace.
Before starting¶
- Start new implementation in a task worktree from current
origin/main, or continue the existing worktree for that task; vendor submodules remain read-only. - Use the roadmap for scope, data sources for dataset choices, conventions for interfaces/code, and architecture for shared ownership. Read the parts affected by the task.
- Read the model issue's plan comment and every later amendment comment; later amendments override earlier plan text when they conflict.
- Add the
in-progresslabel to the model issue before implementation begins.
Interface compliance¶
- Use the canonical layout output classes with their eight aligned fields and framework bases. Keep package-local copies and an
extrasfield out; schema tests check that the two explicit dataclasses agree. - Return normalized center
xywhboxes in[0, 1], and represent padding only withmaskrather than a reserved public label id. - Return
id2labelwith outputs and persist it in the config and model card; batched open-vocabulary output uses one batch-local union, with per-example maps inintermediates["id2label_per_example"]. - Make
generatortake precedence overseed, and verify that generation is reproducible from the seed or generator. - Use canonical
condition_typenames (unconditional,label,label_size,completion,refinement,text,content_image,relation,hierarchical, andretrieval); normalize original-implementation aliases before dispatch and raise explicitly for unsupported conditions instead of falling back silently. - Expose the full agreed v1 (initial interface) pipeline
__call__signature and the relevant v2 (later interface) additions even when the model rejects some inputs. - Follow the model and serialization rules for discrete-vocabulary layout tokenizers and their serialized auxiliary data.
- Follow the model and serialization rules for
PreTrainedModel.forwardand pipeline composition. - Follow the model and serialization rules for standard model entry points and pipeline orchestration.
- Follow the model and serialization rules for
save_pretrained,from_pretrained, and documented overrides. - Follow the model and serialization rules for framework class suffixes and base-class requirements.
- Before applying
plan-agreed, document and justify any novel public method or override on a Hugging Face base class, and have the coordinator, meaning the maintainer who owns the model issue and is distinct from the evidence producer, check that justification under the model and serialization rules. - Make Transformers-side layout pipelines subclass
laygen.pipelines.LayoutGenerationPipelinerather thantransformers.Pipeline; the shared base owns config and subfolder loading, serialization, device and dtype handling,generator-over-seedbehavior, and the canonical layout-output schema.
Package layout¶
- Apply the model framework and module-name conventions to packages added or maintained here.
- Create
models/<slug>/as auvworkspace member with its ownpyproject.toml,src/<pkg>/,scripts/,tests/, andtests/vendor_parity/directories. - Isolate original-implementation dependencies in the package's
vendoroptional extra so the package itself stays light. - Put shared logic in
lib/laygen(laygen.common) or poster-sidelib/posgen(posgen.common) and import it rather than copying it between model packages. - Run workspace-member commands with
uv run --package <member-name> ..., such asuv run --package layout-dm pytestoruv run --package laygen pytest, so the member's dependencies and extras resolve instead of running plain rootuv runagainst a member path.
Data¶
- Use organization datasets under
creative-graphic-design/*as the primary source, and put all loading behind the processor. - Respect the pinned dataset configurations: Rico uses
name="ui-screenshots-and-hierarchies-with-semantic-annotations"because the default configuration is metadata-only; RICO13 needs a vendor-derived mapping, PKU filters or reservesINVALIDand uses pixelltrbboxes, Magazine converts polygons to boxes and is train-only, and CGL-v2 usesralf-stylefor validation and saliency. - Keep tests from triggering large dataset downloads; PubLayNet is about 107 GB, so use builders, streaming, synthetic rows, or tiny local fixtures.
- When an organization dataset is missing, use the original implementation's dataset source and record the migration TODO in the model issue.
Parity and tests¶
- Regenerate golden fixtures with the reference-generation script on one explicitly selected GPU and fixed seeds with
CUDA_VISIBLE_DEVICESset to one free GPU; never commit the fixtures, and commit only seeds, environment notes, config hashes, and script arguments needed to regenerate them. - Apply the model-conversion parity requirement: exact deterministic tokens/ids and bitwise floating comparison by default, with a measured numerical justification for any tolerance. Regular tests may skip absent assets; acceptance uses
PARITY_REQUIRE=1and reports pass/skip counts. - Reach at least 90% coverage per package under the CI selection
-m "not vendor_parity and not integration"with real unit tests such as tiny random-weight CPU configurations; never lower the gate or add broad pragma exclusions. - Run root pytest with
--import-mode=importlibfrom the rootpyproject.tomladdoptssetting, and preserve that setting when resolving pyproject merge conflicts because packages share test basenames; addingtests/__init__.pydoes not fix import mode. - Keep unit tests independent of weights and network access.
- Pass a local
save_pretrainedtofrom_pretrainedround-trip test.
Training for train-ourselves models¶
Models whose weights this repository trains itself are called train-ourselves models.
- Use PyTorch Lightning through the
trainingextra withLightningCLI, YAML configurations, and CLI overrides, and keep theLightningModule,LightningDataModule, andconfigs/*.yamlfiles in the model package. - Follow the training protocol and training document template for stage order, launch prerequisites, source/config provenance, per-dataset results, seed scope, and evidence invalidation. Inference parity or a passing document checker is not training reproduction.
Hub and licensing¶
- Name Hugging Face Hub repositories
creative-graphic-design/<model-slug>-<dataset>, adding a task suffix only for incompatible task-specific checkpoints. - Use the method name known in the literature for
<model-slug>, such aslayoutganppfor vendorconst-layout, rather than the vendor repository slug when they differ, and keep the vendor slug in the model card for traceability. - Verify the license before uploading weights, and obtain explicit approval for AGPL, GPL, or CC-NC models.
- Ship a
README.mdfor every library package underlib/laygen,lib/posgen, and futurelib/*packages that explains its purpose, module map, key API examples, design rules, single-field-spec and no-extrasconstraints, extraction criteria, and links to the project roadmap, shared data sources, and shared library architecture. - Write READMEs for package users rather than reviewers; omit compliance narration and internal tooling walkthroughs, and state only what users need to know about what exists and how to use it.
- Open model documentation with an overview, paper link, key idea, and copy-pasteable usage. Consult the relevant official framework documentation when an API or documentation convention is uncertain; there is no required tour of unrelated model pages for every edit.
- Give every model README a top-level
## Reproducibilitysection that opens by stating how to reproduce agreement checks against the original implementation and links tomodels/<pkg>/REPRODUCING.md; that required file contains copy-pasteable commands for download, reference or golden generation withCUDA_VISIBLE_DEVICES,pytest -m vendor_parity, checkpoint conversion, andfrom_pretrainedsmoke tests, with prerequisites, cache locations, and expected artifacts. Prose mentions do not satisfy this requirement. - Take dataset identifiers and canonical condition types from shared enums. Follow runtime ownership for canonical aliases versus package-specific alias interpretation and validation, and use canonical condition names in Hub task suffixes such as
-labelrather than-gen-t. - Apply the typing rules in the code and review safeguards below to closed sets such as
box_format,condition_type,output_type, sampling modes, and dataset or vocabulary keys, as well as exhaustive branches, module constants, public signatures, and structured specification data. - Apply
ruffdocstring rules (D) to allsrc/code without adding per-file ignores forlib/*/srcormodels/*/src; write the docstrings instead, while keeping test and script exemptions where they already apply. - Give public pipelines, tokenizers, processors, configs,
laygen.commonmodules, and agents google-style docstrings withArgs,Returns,Raises, and runnable doctest-styleExamples; these docstrings feed the generated API reference. - Do not commit machine-specific absolute paths that contain a developer's local checkout directory; resolve script defaults relative to the repository root and provide an explicit CLI override, and use repository-relative paths such as
./vendor/<repo>in documentation. - Give every script under
models/<pkg>/scripts/a module docstring and an argparse--helpdescription for every argument and default, with defaults that work from a clean checkout. - Ship every model package README in model-card style with an overview, install and usage snippet using
from_pretrainedor a pipeline call, supported Hub ids, datasets, a numeric original-implementation agreement summary, and the original implementation's license and citation; prompt-only packages may instead document configuration/exemplar serialization and the absence of learned checkpoints. - Give every model README a
### Parity Resultssection under## Evaluationwith a numeric table stating what was compared, the number of cases, the match criterion, and the result. Prose mentions do not satisfy this requirement; usemodels/layout-dm/README.mdas the reference format. - Give every Hub model repository a model card based on the official Hugging Face model-card template through
huggingface_hub.ModelCard.from_template, with YAML metadata forlicense,library_name(transformersordiffusers),pipeline_tag,tagsincludinglayout-generation, and organization dataset ids, plus model details, intended uses and limitations, afrom_pretrainedexample, training data, numeric agreement results, citation BibTeX, and a link to the original implementation. - Follow the issue-closure rule in Status Labels And Milestones: merge, independent agreement checks, and a local save/load smoke test for every planned checkpoint, dataset, or task repository. Hub publication is separate.
Process¶
- Treat completion as a pull request with green CI or a documented CI blocker; do not self-merge because the user makes the merge decision.
- Apply the same lane or topic labels as the implementation issue to the pull request, and keep status labels such as
plan-agreed,in-progress, andparity-verifiedon the issue rather than the pull request. - Build the pull request description from
.github/PULL_REQUEST_TEMPLATE.md, keep it as the single current summary of the pull request, and keep progress reports out of pull request comments. - Include the pull request URL, checklist verification with deviations, agreement results, and follow-ups in progress reports.
- Mark checklist items with
[x]only when they were actually verified.
Code and review safeguards¶
- Use
StrEnumwithauto()for closed string sets rather than barestr,tuple[str, ...], or string-literal unions; type alias tables asdict[SomeAliasEnum, SomeEnum], and use shared dataset and condition enums instead of local redefinitions. - Use
typing.assert_neverfor exhaustive enum dispatch. - Annotate module constants with
Final[...], including tokens, thresholds, and paths. - Annotate every public signature and structured specification; use
NamedTupleorTypedDictfor structured tuples and dictionaries, and useLiteralor enums for closed parameter sets. - Do not import private underscore-prefixed modules across modules; make a needed module public instead.
- Use Hugging Face base classes where they exist, including
PreTrainedTokenizerfor tokenizers andtransformers.ProcessorMixinfor processors, rather than hand-written save and load logic. - Do not use
*argsor**kwargsgrab-bag signatures on public APIs; expose explicit keyword-only parameters and reject unsupported call shapes at the signature level. - Do not use
sys.pathhacks in tests or conftest files; workspace and package execution must resolve imports. - Accept
strat public boundaries only when the boundary normalizes it immediately to a shared enum; use the enum type internally. - Check shared helpers before writing local copies of bbox, label, or serialization utilities, and list extraction candidates for LayoutDM-like logic instead of duplicating it.
Verification commands¶
Run the checks for the changed scope once, then rerun affected checks if a fix changes their inputs. Record commands, results, and unavailable checks in the PR. Use the repository's dependency environments for package, root-tooling, full-workspace, and documentation command selection.
- Run affected member tests with
uv run --package <member> pytest. - Run the full hook set with
uv run pre-commit run --all-files. - Build the documentation site strictly with
uv run --group docs zensical build --strict -f mkdocs.yml.
Use the package's REPRODUCING.md or TRAINING.md for asset-dependent acceptance commands. A coordinator reports actual comparisons with PARITY_REQUIRE=1, not an all-skip result.