orca-rfic 1.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- orca/__init__.py +94 -0
- orca/__main__.py +18 -0
- orca/geometry/__init__.py +0 -0
- orca/geometry/base_geometry.py +112 -0
- orca/geometry/cells/__init__.py +0 -0
- orca/geometry/cells/inductor.py +639 -0
- orca/geometry/cells/transformer.py +497 -0
- orca/geometry/constraints.py +179 -0
- orca/geometry/drc.py +310 -0
- orca/geometry/input_parameters.py +207 -0
- orca/geometry/layers.py +89 -0
- orca/geometry/presets/SG13G2_200um.xml +61 -0
- orca/geometry/presets/SG13G2_nosub.xml +57 -0
- orca/geometry/presets/__init__.py +0 -0
- orca/geometry/presets/inductor_octa.py +127 -0
- orca/geometry/presets/inductor_octa.simcfg +54 -0
- orca/geometry/presets/tf_octa_c_ports.py +119 -0
- orca/geometry/presets/tf_octa_c_ports.simcfg +94 -0
- orca/gui/__init__.py +0 -0
- orca/gui/app.py +19 -0
- orca/gui/help_texts.py +64 -0
- orca/gui/pipeline_window.py +310 -0
- orca/gui/theme.py +671 -0
- orca/gui/utils.py +76 -0
- orca/gui/widgets/__init__.py +0 -0
- orca/gui/widgets/geometry_selector.py +120 -0
- orca/gui/widgets/stage_widget.py +151 -0
- orca/logger.py +18 -0
- orca/orca.py +131 -0
- orca/pipeline/__init__.py +0 -0
- orca/pipeline/context.py +193 -0
- orca/pipeline/drc_stage.py +149 -0
- orca/pipeline/export_onnx_stage.py +115 -0
- orca/pipeline/gds_conversion_stage.py +175 -0
- orca/pipeline/gds_gen_stage.py +164 -0
- orca/pipeline/pipeline_stage.py +33 -0
- orca/pipeline/simulation_stage.py +251 -0
- orca/pipeline/test_model_stage.py +182 -0
- orca/pipeline/training_stage.py +163 -0
- orca/simulation/__init__.py +0 -0
- orca/simulation/combine_snp_results.py +501 -0
- orca/simulation/gds_converter.py +122 -0
- orca/simulation/launchers.py +222 -0
- orca/simulation/simulate.py +106 -0
- orca/simulation/slurm.py +229 -0
- orca/training/__init__.py +0 -0
- orca/training/basis_expansion.py +196 -0
- orca/training/codecs.py +169 -0
- orca/training/datasets/__init__.py +0 -0
- orca/training/datasets/base_dataset.py +171 -0
- orca/training/datasets/geo_to_ntwk.py +55 -0
- orca/training/datasets/geo_to_s_param.py +67 -0
- orca/training/datasets/geo_to_s_param_single_f.py +73 -0
- orca/training/guarantees.py +54 -0
- orca/training/losses.py +53 -0
- orca/training/models/__init__.py +8 -0
- orca/training/models/base_model.py +150 -0
- orca/training/models/mlp.py +81 -0
- orca/training/models/transformer.py +56 -0
- orca/training/normalize.py +214 -0
- orca/training/onnx_wrapper.py +51 -0
- orca/training/predictors.py +120 -0
- orca/training/spec.py +71 -0
- orca/training/trainer.py +272 -0
- orca/training/tuner.py +176 -0
- orca/utils/__init__.py +0 -0
- orca/utils/class_finder.py +97 -0
- orca/utils/postprocessing.py +332 -0
- orca_rfic-1.5.0.dist-info/METADATA +479 -0
- orca_rfic-1.5.0.dist-info/RECORD +74 -0
- orca_rfic-1.5.0.dist-info/WHEEL +5 -0
- orca_rfic-1.5.0.dist-info/entry_points.txt +2 -0
- orca_rfic-1.5.0.dist-info/licenses/LICENSE +201 -0
- orca_rfic-1.5.0.dist-info/top_level.txt +1 -0
orca/__init__.py
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Import stuff here so that they are available at the package level (i.e. from orca import ORCA, BaseGeometry, InputParameters)
|
|
2
|
+
|
|
3
|
+
from .geometry.base_geometry import BaseGeometry
|
|
4
|
+
from .geometry.input_parameters import InputParameterIterator
|
|
5
|
+
from .orca import ORCA
|
|
6
|
+
from .pipeline.context import PipelineContext
|
|
7
|
+
from .pipeline.drc_stage import DRCChecker
|
|
8
|
+
from .pipeline.gds_conversion_stage import GDSConverter
|
|
9
|
+
from .pipeline.gds_gen_stage import GDSGenerator
|
|
10
|
+
from .pipeline.pipeline_stage import PipelineStage
|
|
11
|
+
from .pipeline.simulation_stage import PalaceSimulator
|
|
12
|
+
from .training.codecs import FlatReImCodec, OutputCodec, UpperTriangleReImCodec
|
|
13
|
+
from .training.guarantees import PhysicsGuarantees
|
|
14
|
+
from .training.spec import FrequencyMode, IOSpec
|
|
15
|
+
|
|
16
|
+
__all__ = [
|
|
17
|
+
"ORCA",
|
|
18
|
+
"BaseGeometry",
|
|
19
|
+
"DRCChecker",
|
|
20
|
+
"FlatReImCodec",
|
|
21
|
+
"FrequencyMode",
|
|
22
|
+
"GDSConverter",
|
|
23
|
+
"GDSGenerator",
|
|
24
|
+
"IOSpec",
|
|
25
|
+
"InputParameterIterator",
|
|
26
|
+
"OutputCodec",
|
|
27
|
+
"PalaceSimulator",
|
|
28
|
+
"PhysicsGuarantees",
|
|
29
|
+
"PipelineContext",
|
|
30
|
+
"PipelineStage",
|
|
31
|
+
"UpperTriangleReImCodec",
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
# Everything that needs PyTorch (the "train" extra) is imported on first access
|
|
35
|
+
# instead of here, so that `import orca` works in a simulation-only install, e.g.
|
|
36
|
+
# on an HPC cluster. The names stay importable as `orca.ModelTrainer` etc.; a
|
|
37
|
+
# missing torch is reported the moment such a name is used.
|
|
38
|
+
_TRAINING_EXPORTS = {
|
|
39
|
+
"ModelTrainer": ".pipeline.training_stage",
|
|
40
|
+
"OnnxExporter": ".pipeline.export_onnx_stage",
|
|
41
|
+
"ModelTester": ".pipeline.test_model_stage",
|
|
42
|
+
"OrcaModel": ".training.models.base_model",
|
|
43
|
+
"register_model": ".training.models.base_model",
|
|
44
|
+
"available_models": ".training.models.base_model",
|
|
45
|
+
"OrcaMLP": ".training.models.mlp",
|
|
46
|
+
"BasisExpansion": ".training.basis_expansion",
|
|
47
|
+
"IdentityBasis": ".training.basis_expansion",
|
|
48
|
+
"ChebyshevBasis": ".training.basis_expansion",
|
|
49
|
+
"register_basis": ".training.basis_expansion",
|
|
50
|
+
"available_bases": ".training.basis_expansion",
|
|
51
|
+
"Trainer": ".training.trainer",
|
|
52
|
+
"TrainingConfig": ".training.trainer",
|
|
53
|
+
"TrainingResult": ".training.trainer",
|
|
54
|
+
"HyperparameterTuner": ".training.tuner",
|
|
55
|
+
"ComplexMSELoss": ".training.losses",
|
|
56
|
+
"MSEPlusLogCoshLoss": ".training.losses",
|
|
57
|
+
"NetworkPredictor": ".training.predictors",
|
|
58
|
+
"TorchNetworkPredictor": ".training.predictors",
|
|
59
|
+
"OnnxNetworkPredictor": ".training.predictors",
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
#: Top-level modules provided by the "train" extra in pyproject.toml.
|
|
63
|
+
_TRAIN_EXTRA_MODULES = frozenset(
|
|
64
|
+
{"torch", "sklearn", "optuna", "onnx", "onnxruntime", "onnxscript"}
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def __getattr__(name: str):
|
|
69
|
+
module_name = _TRAINING_EXPORTS.get(name)
|
|
70
|
+
if module_name is None:
|
|
71
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
72
|
+
|
|
73
|
+
from importlib import import_module
|
|
74
|
+
|
|
75
|
+
try:
|
|
76
|
+
module = import_module(module_name, __name__)
|
|
77
|
+
except ModuleNotFoundError as e:
|
|
78
|
+
package = e.name.split(".")[0] if e.name else None
|
|
79
|
+
if package not in _TRAIN_EXTRA_MODULES:
|
|
80
|
+
raise
|
|
81
|
+
raise ModuleNotFoundError(
|
|
82
|
+
f"orca.{name} needs the '{package}' package, which is part of ORCA's "
|
|
83
|
+
"optional training dependencies. Install them with "
|
|
84
|
+
"`pip install -e '.[train]'` (or `uv sync --extra train`); "
|
|
85
|
+
"GDS generation, conversion and Palace simulation work without them.",
|
|
86
|
+
name=e.name,
|
|
87
|
+
) from e
|
|
88
|
+
value = getattr(module, name)
|
|
89
|
+
globals()[name] = value # cache, so __getattr__ runs once per name
|
|
90
|
+
return value
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def __dir__():
|
|
94
|
+
return sorted(set(globals()) | set(_TRAINING_EXPORTS))
|
orca/__main__.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
|
|
3
|
+
from orca.gui.app import run_gui
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def main():
|
|
7
|
+
"""
|
|
8
|
+
Main entry point for ORCA.
|
|
9
|
+
If no arguments are provided, launches the GUI.
|
|
10
|
+
"""
|
|
11
|
+
# Future CLI argument parsing can go here
|
|
12
|
+
if len(sys.argv) == 1 or (len(sys.argv) > 1 and sys.argv[1] == "--gui"):
|
|
13
|
+
run_gui()
|
|
14
|
+
else:
|
|
15
|
+
sys.exit("CLI usage not yet implemented. Use --gui to launch the graphical interface.")
|
|
16
|
+
|
|
17
|
+
if __name__ == "__main__":
|
|
18
|
+
main()
|
|
File without changes
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from abc import ABC, abstractmethod
|
|
4
|
+
from dataclasses import dataclass
|
|
5
|
+
from functools import cached_property
|
|
6
|
+
from typing import TYPE_CHECKING, Any
|
|
7
|
+
|
|
8
|
+
if TYPE_CHECKING:
|
|
9
|
+
from orca.geometry.input_parameters import InputParameterIterator
|
|
10
|
+
from orca.training.datasets.base_dataset import BaseDataset
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@dataclass
|
|
14
|
+
class BaseGeometry(ABC):
|
|
15
|
+
"""
|
|
16
|
+
Physical definition of a geometry class: how to draw it, which stackup and
|
|
17
|
+
simulation settings it uses, and which parameters may vary.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
name: str
|
|
21
|
+
stackup_xml: str
|
|
22
|
+
simconfig_filename: str
|
|
23
|
+
input_parameter_iterator: InputParameterIterator
|
|
24
|
+
|
|
25
|
+
@property
|
|
26
|
+
def input_iterator(self) -> InputParameterIterator:
|
|
27
|
+
# Return the input parameter iterator, ensuring it is initialized with iter()
|
|
28
|
+
return iter(self.input_parameter_iterator)
|
|
29
|
+
|
|
30
|
+
@cached_property
|
|
31
|
+
def dataset(self) -> BaseDataset:
|
|
32
|
+
"""
|
|
33
|
+
The dataset used to train a model of this geometry, built once per
|
|
34
|
+
instance by :meth:`create_dataset`. Each geometry instance gets its own
|
|
35
|
+
dataset, so the normalizer statistics fitted in one training run never
|
|
36
|
+
leak into another.
|
|
37
|
+
"""
|
|
38
|
+
return self.create_dataset()
|
|
39
|
+
|
|
40
|
+
@cached_property
|
|
41
|
+
def n_ports(self) -> int:
|
|
42
|
+
"""
|
|
43
|
+
Number of ports of the Palace simulation, read from the ``ports`` list of
|
|
44
|
+
the simulation config. This sets the ``.sNp`` extension of the Touchstone
|
|
45
|
+
results and must match the codec of :attr:`dataset`.
|
|
46
|
+
"""
|
|
47
|
+
from orca.simulation.simulate import read_simconfig
|
|
48
|
+
|
|
49
|
+
return len(read_simconfig(self.simconfig_filename)["ports"])
|
|
50
|
+
|
|
51
|
+
def is_feasible(self, params: dict[str, Any]) -> bool: # noqa: ARG002 - hook with a default
|
|
52
|
+
"""
|
|
53
|
+
Whether a parameter combination describes a layout that can be drawn.
|
|
54
|
+
|
|
55
|
+
Called before :meth:`create_gds_file`, for every draw of the input
|
|
56
|
+
parameter iterator; infeasible draws are rejected and redrawn, so the
|
|
57
|
+
requested number of samples is met and only buildable layouts are
|
|
58
|
+
simulated. Override this for cheap, closed-form constraints between
|
|
59
|
+
parameters (a winding that must fit its diameter, a via array that must
|
|
60
|
+
fit its trace). Do not clamp or repair parameters instead: the parameter
|
|
61
|
+
table records the requested values, and a repaired layout would train
|
|
62
|
+
the model on a geometry it does not have.
|
|
63
|
+
|
|
64
|
+
The default accepts everything. :meth:`create_gds_file` should still
|
|
65
|
+
raise ``ValueError`` for a combination it cannot draw; that is the
|
|
66
|
+
safety net, this is the filter.
|
|
67
|
+
"""
|
|
68
|
+
return True
|
|
69
|
+
|
|
70
|
+
def feasibility_constraints(self) -> list[str]:
|
|
71
|
+
"""
|
|
72
|
+
:meth:`is_feasible` as expressions a consumer of the model can evaluate.
|
|
73
|
+
|
|
74
|
+
Each string is a boolean expression over the input parameter names in
|
|
75
|
+
the grammar of :mod:`orca.geometry.constraints`, for example
|
|
76
|
+
``"bottom_linewidth <= bottom_winding_diameter / 3"``. The ONNX
|
|
77
|
+
exporter writes them to the ``input_constraints`` metadata key, so
|
|
78
|
+
COBRA can refuse a query for a geometry that cannot be built rather
|
|
79
|
+
than return a prediction the model was never trained for.
|
|
80
|
+
|
|
81
|
+
They must accept exactly the parameter sets :meth:`is_feasible`
|
|
82
|
+
accepts; derive both from the same numbers. The default declares no
|
|
83
|
+
constraints, which a consumer reads as "the whole parameter box".
|
|
84
|
+
"""
|
|
85
|
+
return []
|
|
86
|
+
|
|
87
|
+
@staticmethod
|
|
88
|
+
@abstractmethod
|
|
89
|
+
def create_gds_file(name: str, output_path: str, params: dict[str, Any]) -> str:
|
|
90
|
+
"""
|
|
91
|
+
Creates a GDS file based on the current input parameters.
|
|
92
|
+
Input parameters are a list of values defining the geometry, e.g. width, length, radius etc.
|
|
93
|
+
and will also be used as inputs for the AI/ML model.
|
|
94
|
+
|
|
95
|
+
Returns:
|
|
96
|
+
str: Path to the created GDS file.
|
|
97
|
+
"""
|
|
98
|
+
|
|
99
|
+
@abstractmethod
|
|
100
|
+
def create_dataset(self) -> BaseDataset:
|
|
101
|
+
"""
|
|
102
|
+
Builds the training dataset for this geometry: a :class:`BaseDataset`
|
|
103
|
+
subclass with its output codec and normalizers. Called once per instance,
|
|
104
|
+
the first time :attr:`dataset` is read.
|
|
105
|
+
|
|
106
|
+
Import the ``orca.training`` modules inside this method rather than at
|
|
107
|
+
the top of the geometry file, so the geometry can still be used for GDS
|
|
108
|
+
generation and simulation when PyTorch is not installed.
|
|
109
|
+
|
|
110
|
+
Returns:
|
|
111
|
+
BaseDataset: A fresh, unfitted dataset.
|
|
112
|
+
"""
|
|
File without changes
|