Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "oqd-core"
version = "0.1.0"
version = "0.2.0dev1"
requires-python = ">=3.10"
readme = "README.md"
license = { text = "Apache 2.0" }
Expand Down Expand Up @@ -64,10 +64,7 @@ fixable = ["ALL"]
oqd-compiler-infrastructure = { git = "https://github.com/openquantumdesign/oqd-compiler-infrastructure" }

[dependency-groups]
dev = [
"jupyter>=1.1.1",
"pre-commit>=4.1.0",
]
dev = ["jupyter>=1.1.1", "pre-commit>=4.1.0", "ruff>=0.13.1"]


[project.urls]
Expand Down
79 changes: 79 additions & 0 deletions src/oqd_core/backend.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Copyright 2024-2025 Open Quantum Design

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


import inspect
import warnings
from abc import ABC, abstractmethod
from typing import Any

########################################################################################

__all__ = [
"MetaBackendRegistry",
"BackendRegistry",
"BackendBase",
]

########################################################################################


class MetaBackendRegistry(type):
def __new__(cls, clsname, superclasses, attributedict):
attributedict["backends"] = dict()
return super().__new__(cls, clsname, superclasses, attributedict)

def register(cls, backend):
if not issubclass(backend, BackendBase):
raise TypeError("You may only register subclasses of BackendBase.")

if backend.__name__ in cls.backends.keys():
warnings.warn(
f"Overwriting previously registered backend `{backend.__name__}` of the same name.",
UserWarning,
stacklevel=2,
)

cls.backends[backend.__name__] = backend


class BackendRegistry(metaclass=MetaBackendRegistry):
pass


class BackendBase(ABC):
@abstractmethod
def run(self, program, args):
pass

def __init_subclass__(cls, **kwargs):
super().__init_subclass__(**kwargs)

args = inspect.getfullargspec(cls.run)

if "program" not in args.annotations:
warnings.warn(
f"Misisng type hint for argument `program` in run method of {cls.__name__}. Defaults to Any."
)

cls.run.__annotations__["program"] = Any

if "args" not in args.annotations:
warnings.warn(
f"Misisng type hint for argument `args` in run method of {cls.__name__}. Defaults to Any."
)

cls.run.__annotations__["args"] = Any

BackendRegistry.register(cls)
13 changes: 0 additions & 13 deletions src/oqd_core/backend/__init__.py

This file was deleted.

26 changes: 0 additions & 26 deletions src/oqd_core/backend/base.py

This file was deleted.

49 changes: 0 additions & 49 deletions src/oqd_core/backend/metric.py

This file was deleted.

184 changes: 0 additions & 184 deletions src/oqd_core/backend/task.py

This file was deleted.

3 changes: 1 addition & 2 deletions src/oqd_core/compiler/analog/passes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
# limitations under the License.

from .analysis import analysis_canonical_hamiltonian_dim, analysis_term_index
from .assign import assign_analog_circuit_dim, verify_analog_args_dim
from .assign import assign_analog_circuit_dim
from .canonicalize import analog_operator_canonicalization

__all__ = [
"assign_analog_circuit_dim",
"verify_analog_args_dim",
"analog_operator_canonicalization",
"analysis_canonical_hamiltonian_dim",
"analysis_term_index",
Expand Down
Loading
Loading