English | 简体中文
Discrete topology generation and constrained geometry assignment for layout patterns.
Paper · arXiv · Validation · Data format · Changes from the archive
Research implementation of the DAC 2023 conference version of DiffPattern, maintained from the surviving research code. The original pretrained checkpoints are no longer available. You can run the CPU geometry demo without weights, or train a new model using the preserved binary D3PM and Flax U-Net implementation.
Synthetic example: the topology is fixed while geometric dimensions change. These are executable demo outputs, not samples from a pretrained model.
| Component | Available in this edition |
|---|---|
| Binary topology normalization, folding and unfolding | Lossless 128×128 ↔ 32×32×16 conversion; 0/1 and 0/255 inputs |
| Discrete diffusion and U-Net | Original numerical core and architecture, including hybrid loss and ancestral sampling |
| Training and checkpoint recovery | Modern single-device JAX/Flax/Optax runner; new disjoint splits grouped by exact topology content |
| Evaluation | Saved-split hybrid loss and diffusion BPD; topology-complexity entropy |
| Topology prefilter | Both orientations of diagonal-only material contact |
| Geometry assignment | Seeded SLSQP, configurable width/space/area constraints, explicit failure records |
| Geometry variation | One or multiple geometry assignments for each topology |
| Visualization | PNG preview and physical-coordinate SVG export |
The maintained training runner currently uses one device. Original pretrained sampling, a complete GDS import/export pipeline, and the paper's KLayout rule-deck evaluation are not included. Constraint validation here covers the implemented scan-line and connected-area formulation, not a foundry DRC certification.
Use Python 3.11, the version used for validation. Commands below run from the repository root.
git clone https://github.com/ShiningSord/DiffPattern.git
cd DiffPattern
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m diffpattern demo --output outputs/demoOpen outputs/demo/topology.png and geometry_0.png through geometry_2.png. The matching SVGs preserve physical coordinates; report.json records the rules, success status and independently recomputed constraint residuals.
The lightweight demo needs only NumPy, SciPy and Pillow. TensorFlow and JAX are not imported by the geometry commands.
Both archived layer datasets are included in this Git repository as losslessly compressed ZIP files. git clone and git pull fetch them together with the code.
| Layer | Samples | Download | Included arrays |
|---|---|---|---|
| 10001 | 15,210 | layer10001.zip (11.4 MB) | 128×128 topology, 32×32×16 folded topology, physical dimensions |
| 10003 | 14,134 | layer10003.zip (6.6 MB) | 128×128 topology, 32×32×16 folded topology, physical dimensions |
Verify and extract both datasets to data/ using the Python standard library:
python -m scripts.prepare_dataTo prepare just one layer, use --layers 10001 or --layers 10003. The script checks archive and array SHA-256 hashes, verifies existing matching files and refuses to overwrite different files. The unpacked arrays require approximately 992 MB in total. See dataset contents and formats.
Install the separately pinned training environment:
python -m pip install -r requirements-train.txt
python -m diffpattern make-data --output outputs/smoke_data.npz --count 16 --size 32
python -m diffpattern train --data outputs/smoke_data.npz --config configs/smoke.json --output outputs/smoke --steps 2
python -m diffpattern train --data outputs/smoke_data.npz --config configs/smoke.json --output outputs/smoke --steps 4 --resume outputs/smoke/latest.msgpack
python -m diffpattern sample --checkpoint outputs/smoke/latest.msgpack --output outputs/smoke_samples.npy --count 3
python -m diffpattern evaluate --checkpoint outputs/smoke/latest.msgpack --data outputs/smoke_data.npzThis creates a tiny test model, not a replacement for the missing research weights. --steps is the total target step, including steps already completed. Resume verifies the configuration, data fingerprint and batch size. Checkpoints include parameters, optimizer state, EMA parameters, step, configuration and split indices. Missing checkpoints produce an error instead of sampling random initialization.
For the full 32×32×16 topology representation:
python -m diffpattern train --data data/layer10001_128_pattern_32_32_16.npy --config configs/research.json --output outputs/research --steps 500000 --batch-size 128
python -m diffpattern sample --checkpoint outputs/research/latest.msgpack --output outputs/generated.npy --count 100 --batch-size 8Prepare the included datasets with python -m scripts.prepare_data first; see data notes. This command uses the full architecture and a 500k-step target. It has not been run to convergence during validation. Reduce batch size to suit the device. NVIDIA use requires a matching JAX CUDA installation; follow the JAX installation guide. Only macOS ARM64 CPU execution was tested here, not CUDA, distributed training or Windows.
python -m diffpattern inspect --input outputs/demo/synthetic_data.npz
python -m diffpattern convert --input outputs/demo/synthetic_data.npz --to folded --output outputs/folded.npy
python -m diffpattern convert --input outputs/folded.npy --to topology --output outputs/topology.npy
python -m diffpattern legalize --input outputs/topology.npy --index 0 --output outputs/one_layout --seed 7
python -m diffpattern legalize --input outputs/topology.npy --index 0 --count 3 --variants 2 --output outputs/layout_batch --min-width 20 --min-space 10
python -m diffpattern reconstruct --input outputs/topology.npy --delta outputs/one_layout_delta.npy --index 0 --output outputs/reconstructionlegalize runs the topology prefilter, solves the constraints and checks the resulting geometry. A failed item gets a failure record and no new image. Batch mode preserves every failure and labels each topology/variant. Exit code 2 means an invalid request or at least one failed geometry; inspect the JSON report. reconstruct simply renders supplied dimensions and does not certify their design-rule compliance.
delta[0] represents row heights and delta[1] column widths. Material is encoded as zero. Defaults are expressed in the same coordinate units as the supplied extent, conventionally nanometres for the archived layout data.
- Original weights and the exact historical train/test split are unavailable. The new split prevents exact duplicate topologies from crossing train/eval boundaries, but does not separate merely similar patterns or their source layout regions.
- The software checks exercise a small model, not reproduction of paper metrics. The full model's initialization, forward pass and loss are checked separately.
- The archived beta schedule is retained: code beta ranges from 0.02 to 1.0, while the binary transition's off-diagonal probability is beta/2, matching 0.01 to 0.5.
- The modern runner replaces the old TensorFlow/
flax.optimorchestration. Its checkpoint format is new and does not load old optimizer checkpoints. - Generated topologies may be rejected by the prefilter or may have no feasible geometry under selected rules. A successful SLSQP return alone is insufficient: the maintained code also recomputes the modeled constraints.
- SVG is continuous geometry. Raster previews round physical edges and can visually omit subpixel features; they are not DRC inputs.
python -m pip install -r requirements-dev.txt
python -m pytest -qTests cover representation roundtrips and channel order, both bow-tie orientations, nonlinear area constraints, failed/infeasible inputs, rendering axes, seeded geometry, duplicate-safe splits, checkpoint resume equivalence, sampling and evaluation. See validation notes for measured results and remaining gaps.
@inproceedings{wang2023diffpattern,
title = {DiffPattern: Layout Pattern Generation via Discrete Diffusion},
author = {Wang, Zixiao and Shen, Yunheng and Zhao, Wenqian and Bai, Yang and Chen, Guojin and Farnia, Farzan and Yu, Bei},
booktitle = {2023 60th ACM/IEEE Design Automation Conference (DAC)},
year = {2023},
pages = {1--6},
doi = {10.1109/DAC56929.2023.10248009}
}The diffusion implementation is derived from Google Research D3PM. Its copyright notices are retained. The code is licensed under Apache-2.0; see LICENSE and THIRD_PARTY_NOTICES.md. The layer10001 and layer10003 datasets are included; see data notes for provenance and contents. Historical model outputs and pretrained checkpoints are not included. The quickstart uses synthetic fixtures.
