Skip to content

Run a custom FabCheck deck

This walkthrough runs a compiled FabCheck deck against example layouts in GDSFactory+ Cloud. It requires a GDSFactory+ subscription and network access; Cloud uploads your layout for checking. Use Cloud for this walkthrough: Local (Beta) DRC is not ready for this workflow in the 2.2 release.

First follow Write your first FabCheck DRC deck to download the example files and compile rules-recompiled.fcd. Alternatively, use the supplied rules.fcd and example layouts from that page.

Run the example in Cloud

violations.gds contains one top cell, VIOLATIONS, with three rectangles on layer 10/0, on a 1 nm database grid. The corrected layout uses the top-cell name CORRECTED. These names match their filenames apart from letter case.

  • A 2 µm long strip that is only 0.10 µm wide.
  • Two 2 × 0.5 µm strips separated by a 0.15 µm gap.

The app flow is open layout → Check DRC → Cloud → Add custom deck… → select your .fcd → select rules → Run in cloud.

  1. Open fabcheck/violations.gds in the layout viewer using Explorer or Ctrl+P. You should see three rectangles: two wide strips separated by a narrow gap above a separate thin strip, as shown below.

    violations.gds open in the GF+ layout viewer, showing two wide blue hatched rectangles separated by a narrow gap above a separate thin rectangle.

    Click the checkmark menu in the viewer toolbar, then choose Check DRC.

    The GDS viewer checkmark menu with Check DRC selected.

  2. Select Cloud at the top of the DRC panel. Complete the DRC project setup if prompted. Keep Cloud selected throughout this walkthrough.

    DRC panel for violations.gds with Cloud mode selected and a red arrow pointing to the Cloud option.

  3. Click Add custom deck… in the rule picker.

    Cloud DRC panel for violations.gds with a red arrow pointing to Add custom deck beside the Built-in: demopdk chip.

  4. Under Compiled decks in workspace, select fabcheck/rules-recompiled.fcd, the file you just compiled. Use Refresh if it is missing, or Choose another file… to browse for it. You can also drag a .fcd onto the panel. If you skipped authoring, select the supplied fabcheck/rules.fcd instead. Use Change file… to switch decks.

    The arrow points to fabcheck/rules-recompiled.fcd, the file to select. This screenshot shows the picker before switching from the supplied rules.fcd; click the circle beside rules-recompiled.fcd to select your newly compiled deck.

    Compiled decks in the Cloud DRC panel, with a red arrow pointing to the unselected fabcheck/rules-recompiled.fcd entry above the currently selected fabcheck/rules.fcd.

  5. Remove the built-in deck from this run. Adding a custom deck does not replace the built-in rules: both sources can remain enabled. If you see a Built-in: demopdk chip above the rule list, click the × on that chip. Keep the Custom deck: fabcheck/… chip. This removes the built-in rule source from the run; it does not delete your DRC project or its configuration.

    Cloud DRC panel with fabcheck/rules-recompiled.fcd selected and 13 rules selected, with a red arrow pointing to the × on the Built-in: demopdk chip to remove the built-in rule source.

    With the rule search empty and the source filter set to All sources, confirm that the list contains only M1.WIDTH and M1.SPACE, both checked and marked Custom, and the footer says 2 rules selected. If it says 13 rules selected, the demo PDK's built-in rules are still included. Filtering the list to show custom rules does not by itself remove the built-in source.

    Your panel should now match the screenshot below: Cloud selected, Custom deck: fabcheck/rules-recompiled.fcd loaded, and only M1.WIDTH and M1.SPACE checked, both marked Custom. The + Built-in deck button shows that the built-in source is not enabled, and the footer confirms 2 rules selected.

    Cloud DRC panel with fabcheck/rules-recompiled.fcd selected, the built-in deck disabled, M1.WIDTH and M1.SPACE checked as Custom rules, and 2 rules selected in the footer.

  6. Click Run in cloud. This submits your layout for checking. When the run completes, inspect the results by category and select a finding to highlight its location in the layout.

    Completed Cloud DRC run for violations.gds with two findings under the VIOLATIONS cell. The minimum-width finding is selected, highlighting the thin bottom strip in red in the layout viewer.

See Check for Design Errors for more illustrations of report navigation.

Read the findings and check the corrected layout

The supplied deck was executed with the compiled-deck DRC adapter to produce the reference reports below. Expect the same findings when you run the two custom rules on violations.gds:

Rule Requirement Measured example geometry Report items
M1.WIDTH Width ≥ 0.20 µm Bottom strip is 0.10 µm wide 1
M1.SPACE Gap ≥ 0.30 µm Upper strips are 0.15 µm apart 1

The downloadable reference violation report records those two findings. The width marker covers the thin strip; the spacing marker identifies the gap between the upper strips. These dimensions come from the GDS coordinates; the report supplies the rule messages and marker geometry.

The corrected GDS widens the bottom strip to 0.20 µm and moves the upper strip to leave a 0.30 µm gap. Open fabcheck/corrected.gds in the viewer and repeat the Cloud steps with the same deck and both rules selected. Expect zero report items. The supplied corrected.lyrdb records that result from the compiled-deck adapter. Equality passes these minimum checks.

corrected.gds open in the layout viewer above the DRC panel, showing a completed Cloud run with a PASSED outcome and No errors.

Change rules and adapt the deck

After changing a rule in rules.py, validate it, compile it to a fresh .fcd filename, and select that new file with Change file… before rerunning in Cloud. Confirm the selected deck path and rule count each time.

For a simple experiment, lower the width threshold to 0.05 µm and update its message to match. Compile to a new filename and run against violations.gds: expect the width finding to disappear while the spacing finding remains. Selecting the original example deck again should restore both findings.

Start by changing the layer/datatype and the two thresholds, then check a deliberately failing layout and a passing one. If a run unexpectedly reports no findings, confirm that the selected layer contains geometry and that both rules are selected. Empty input geometry is not evidence that you chose the correct layer.

Use thresholds that fit your layout grid. FabCheck defaults to rejecting lengths that cannot be represented on that grid; compilation cannot check this until a layout is supplied for execution.

Optional: combine custom and foundry rules

In Cloud mode, you can enable Built-in deck alongside your custom deck to combine the foundry rules with your own checks, or run either source on its own. Search by rule ID or tag and use the source filter to find the rules you want. This changes the set of checks, so the two-findings/zero-findings expectations above apply only when running the two example custom rules on their own.

Optional: run from the command line

With the Python SDK CLI installed and your API key configured, you can submit the compiled deck, wait for completion, and download its report in one command. From your project root, replace my-project with your DRC project identifier:

Bash
gfp check drc fabcheck/violations.gds --project my-project --compiled-deck fabcheck/rules-recompiled.fcd --outpath fabcheck/violations.lyrdb

This runs all rules in the custom deck without built-in rules. Do not pass --process; any built-in process saved in project settings is ignored for a custom deck. You can omit --outpath to use the normal build/lyrdb/drc/violations.lyrdb output. A successful command means the run completed and the report was downloaded; inspect its findings to check for violations. See the CLI reference for details.

Optional: submit and retrieve results from Python

The Python SDK can submit a compiled FabCheck deck without opening VS Code. Use Python 3.12, an SDK version that exposes compiled_deck_path, an existing DRC project, a subscription with cloud DRC access, and network access. Install gdsfactoryplus and fabcheck==0.2.0 in your Python environment. Configure your API key with gfp configure --api-key ... or the GFP_API_KEY environment variable. A Python process started in a signed-in GF+ window can also use its provided session when no API key is configured.

You can compile a deck directly from Python. Run this in the folder containing the downloaded layouts:

Python
from fabcheck import Deck

deck = Deck("sdk-example", units="um")
metal = deck.layer(10, 0, name="M1")
deck.rule("M1.WIDTH", "M1 must be at least 0.2 um wide", violations=metal.min_width(0.2))
deck.write("rules.fcd")

This writes the compiled rules; it does not check the layout. Submit the deck with your GDS or OAS layout using check_drc. Replace your-drc-project below with your existing DRC project identifier. The standalone SDK does not discover this identifier from the current project's pyproject.toml.

Python
from pathlib import Path

import httpx
from gdsfactoryplus import get_settings
from gdsfactoryplus.check import check_drc
from gdsfactoryplus.cli.check import wait_for_drc_report
from gdsfactoryplus.credentials import auth_headers

settings = get_settings()
project_slug = "your-drc-project"
api_key = settings["api"]["key"]
submission = check_drc(
    "violations.gds",
    project_slug=project_slug,
    api_key=api_key,
    compiled_deck_path=Path("rules.fcd"),
)
print(submission["sub_id"], submission["status"])

# Poll this submission, export its results, and download the LYRDB report.
with httpx.Client(
    base_url=str(settings["api"]["host"]).rstrip("/"),
    headers=auth_headers(api_key),
    timeout=60,
    follow_redirects=True,
) as client:
    report = wait_for_drc_report(client, submission, project_slug, timeout=3600)
Path("violations.lyrdb").write_bytes(report)

check_drc returns the remote submission record immediately after upload; acceptance does not mean execution completed or the layout passed. The existing report helper waits for completion and downloads the report, raising on a failed run or timeout. Inspect the LYRDB findings in GF+ or KLayout; a completed run can still contain violations.

This SDK call runs all rules in the custom deck, without built-in rules. Omit process and builtin_rule_names when supplying compiled_deck_path; even explicit empty values raise ValueError. Omitting the custom path retains the existing built-in-deck workflow. Use the GUI for mixed-source or custom rule-subset selection. File errors and rejected submissions raise ValueError; the SDK does not fall back to built-in execution.

Optional: recreate the example layouts

Download make_layouts.py, then run:

Bash
uv pip install klayout==0.30.12
python make_layouts.py

The script writes violations.gds and corrected.gds in the current directory. It uses integer coordinates with layout.dbu = 0.001 µm per database unit: a width of 100 is 0.10 µm, and a gap of 300 is 0.30 µm. It needs no foundry PDK.