Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 3.8] Control systems resources exceeded #281

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions include/API/errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ enum class ErrorCategory {
QSSLinkSignatureNotFound,
QSSLinkArgumentNotFoundWarning,
QSSLinkInvalidPatchTypeError,
QSSControlSystemResourcesExceeded,
UncategorizedError,
};

Expand Down
3 changes: 3 additions & 0 deletions lib/API/errors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ static std::string_view getErrorCategoryAsString(ErrorCategory category) {
case ErrorCategory::QSSLinkInvalidPatchTypeError:
return "Invalid patch point type";

case ErrorCategory::QSSControlSystemResourcesExceeded:
return "Control system resources exceeded";

case ErrorCategory::UncategorizedError:
return "Compilation failure";
}
Expand Down
8 changes: 8 additions & 0 deletions python_lib/qss_compiler/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,14 @@ def _do_compile(
return_diagnostics=return_diagnostics,
)

for diag in diagnostics:
if diag.category == ErrorCategory.QSSControlSystemResourcesExceeded:
raise exceptions.QSSControlSystemResourcesExceeded(
diag.message,
diagnostics,
return_diagnostics=self.return_diagnostics,
)

if not success:
raise exceptions.QSSCompilationFailure(
"Failure during compilation",
Expand Down
4 changes: 4 additions & 0 deletions python_lib/qss_compiler/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,9 @@ class QSSLinkInvalidArgumentError(QSSLinkingFailure):
"""Raised when argument is invalid"""


class QSSControlSystemResourcesExceeded(QSSCompilerError):
"""Raised when control system resources (such as instruction memory) are exceeded."""


class OpenQASM3ParseFailure(QSSCompilerError):
"""Raised when a parser failure is received"""
49 changes: 31 additions & 18 deletions python_lib/qss_compiler/lib_enums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,37 @@
namespace py = pybind11;

void addErrorCategory(py::module &m) {
py::enum_<qssc::ErrorCategory>(m, "ErrorCategory", py::arithmetic())
.value("OpenQASM3ParseFailure",
qssc::ErrorCategory::OpenQASM3ParseFailure)
.value("QSSCompilerError", qssc::ErrorCategory::QSSCompilerError)
.value("QSSCompilerNoInputError", qssc::ErrorCategory::QSSCompilerNoInputError)
.value("QSSCompilerCommunicationFailure", qssc::ErrorCategory::QSSCompilerCommunicationFailure)
.value("QSSCompilerEOFFailure", qssc::ErrorCategory::QSSCompilerEOFFailure)
.value("QSSCompilerNonZeroStatus", qssc::ErrorCategory::QSSCompilerNonZeroStatus)
.value("QSSCompilationFailure", qssc::ErrorCategory::QSSCompilationFailure)
.value("QSSLinkerNotImplemented", qssc::ErrorCategory::QSSLinkerNotImplemented)
.value("QSSLinkSignatureWarning", qssc::ErrorCategory::QSSLinkSignatureWarning)
.value("QSSLinkSignatureError", qssc::ErrorCategory::QSSLinkSignatureError)
.value("QSSLinkAddressError", qssc::ErrorCategory::QSSLinkAddressError)
.value("QSSLinkSignatureNotFound", qssc::ErrorCategory::QSSLinkSignatureNotFound)
.value("QSSLinkArgumentNotFoundWarning", qssc::ErrorCategory::QSSLinkArgumentNotFoundWarning)
.value("QSSLinkInvalidPatchTypeError", qssc::ErrorCategory::QSSLinkInvalidPatchTypeError)
.value("UncategorizedError", qssc::ErrorCategory::UncategorizedError)
.export_values();
py::enum_<qssc::ErrorCategory>(m, "ErrorCategory", py::arithmetic())
.value("OpenQASM3ParseFailure",
qssc::ErrorCategory::OpenQASM3ParseFailure)
.value("QSSCompilerError", qssc::ErrorCategory::QSSCompilerError)
.value("QSSCompilerNoInputError",
qssc::ErrorCategory::QSSCompilerNoInputError)
.value("QSSCompilerCommunicationFailure",
qssc::ErrorCategory::QSSCompilerCommunicationFailure)
.value("QSSCompilerEOFFailure",
qssc::ErrorCategory::QSSCompilerEOFFailure)
.value("QSSCompilerNonZeroStatus",
qssc::ErrorCategory::QSSCompilerNonZeroStatus)
.value("QSSCompilationFailure",
qssc::ErrorCategory::QSSCompilationFailure)
.value("QSSLinkerNotImplemented",
qssc::ErrorCategory::QSSLinkerNotImplemented)
.value("QSSLinkSignatureWarning",
qssc::ErrorCategory::QSSLinkSignatureWarning)
.value("QSSLinkSignatureError",
qssc::ErrorCategory::QSSLinkSignatureError)
.value("QSSLinkAddressError", qssc::ErrorCategory::QSSLinkAddressError)
.value("QSSLinkSignatureNotFound",
qssc::ErrorCategory::QSSLinkSignatureNotFound)
.value("QSSLinkArgumentNotFoundWarning",
qssc::ErrorCategory::QSSLinkArgumentNotFoundWarning)
.value("QSSLinkInvalidPatchTypeError",
qssc::ErrorCategory::QSSLinkInvalidPatchTypeError)
.value("QSSControlSystemResourcesExceeded",
qssc::ErrorCategory::QSSControlSystemResourcesExceeded)
.value("UncategorizedError", qssc::ErrorCategory::UncategorizedError)
.export_values();
}

void addSeverity(py::module &m) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
features:
- |
A new QSSControlSystemResourcesExceeded error has been added as an error
category. This can be raised as an error whenever the compiler detects that
an input circuit will exceed the capabilities of the control system.
Loading