Object-oriented API: Mask, LitheEngine, Report¶
The OO façade is a thin wrapper over the existing functional API. It exists so fab-/EDA-shaped callers can think in masks and engines without going through the tensor + registry plumbing directly.
The functional API is unchanged — compute_epe, models.registry, and
workflow.tiling.tile_layout all work exactly as before. Use whichever
shape fits the task.
Quick start¶
from openlithohub import Mask, LitheEngine
mask = Mask.from_oasis("design.oas", layer="1:0", pixel_size_nm=1.0)
engine = LitheEngine(model="neural-ilt", node="3nm-euv")
optimized = engine.optimize(mask)
report = engine.evaluate(optimized, target=mask)
print(report.epe_mean_nm, report.pvband_mean_nm, report.drc_violations)
optimized.to_oasis("optimized.oas")
What goes where¶
| Concept | Class | Wraps |
|---|---|---|
(tensor, pixel_size_nm, layer) |
Mask |
_load_layout_as_tensor, workflow.export.export_oasis |
| Run a model on a layout | LitheEngine |
models.registry, workflow.tiling, workflow.halo |
| Aggregate metric & compliance | Report |
benchmark.metrics.*, benchmark.compliance.* |
Constructors¶
Mask offers explicit and suffix-sniffing constructors:
Mask.from_tensor(t, pixel_size_nm=0.5, layer="1:0")
Mask.from_pt("design.pt")
Mask.from_npy("design.npy")
Mask.from_oasis("design.oas", layer="1:0")
Mask.from_gds("design.gds", layer="1:0")
Mask.load("design.oas", layer="1:0") # dispatches by file suffix
Mask is a frozen dataclass — once constructed, the (tensor, pixel_size_nm,
layer) triplet cannot be mutated. Build a new Mask if you need a
different pitch.
Backward compatibility¶
engine.optimize(...) and engine.evaluate(...) accept either a Mask
or a raw torch.Tensor. Existing tensor-first callers do not need to
change.
Reference¶
openlithohub.api.mask
¶
Mask — frozen dataclass bundling (tensor, pixel_size_nm, layer).
Wraps OpenLithoHub's existing layout I/O so callers can write
Mask.from_oasis("design.oas", layer="1:0") instead of going through
load_layout and export_oasis directly.
Mask
dataclass
¶
A 2-D mask tensor with its physical pixel pitch and (optional) source layer.
The fab/EDA-facing handle that LitheEngine consumes and produces.
Construction is via classmethod constructors. The dataclass is frozen,
so the three fields cannot be rebound after construction — but note
that frozen=True does not protect against in-place mutation of the
underlying tensor (mask.tensor[i, j] = 0 still mutates storage).
Treat Mask as a structural binding of (tensor, pixel_size_nm,
layer), not as a deep-immutable value.
Source code in src/openlithohub/api/mask.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
load(path, *, pixel_size_nm=1.0, layer=None)
classmethod
¶
Suffix-sniffing constructor.
.pt / .npy ignore layer. .oas / .gds honour it.
Source code in src/openlithohub/api/mask.py
openlithohub.api.engine
¶
LitheEngine — thin wrapper over registry + tile/halo/stitch pipeline.
Mirrors the body of server.app._run_optimize minus filesystem I/O so
callers can drive the engine in-process without touching the HTTP server
or the CLI helpers.
LitheEngine
¶
Object-oriented driver for the OpenLithoHub optimization pipeline.
engine = LitheEngine(model="neural-ilt", node="3nm-euv")
optimized = engine.optimize(mask)
report = engine.evaluate(optimized, target=mask)
Source code in src/openlithohub/api/engine.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | |
close()
¶
Tear down the underlying model if the engine constructed it.
Safe to call multiple times. No-op for caller-supplied models (the caller owns those — closing them here would yank resources out from under code the engine never owned).
Source code in src/openlithohub/api/engine.py
optimize(design)
¶
Run the model over design with tiling + halo + stitching.
Returns a binarised Mask matching the input shape and pixel pitch.
Source code in src/openlithohub/api/engine.py
evaluate(predicted, target)
¶
Compute the canonical metric / compliance battery on predicted vs target.
Source code in src/openlithohub/api/engine.py
openlithohub.api.report
¶
Report — flat view over the existing metric / compliance outputs.
No new math. The flat fields are projections of fields already computed
by benchmark.metrics and benchmark.compliance; the raw underlying
results are kept on the dataclass for power users who want every field.
Report
dataclass
¶
Aggregated mask-quality report produced by LitheEngine.evaluate.