-
Notifications
You must be signed in to change notification settings - Fork 262
[Python] [refactoring] Replace MidCircuitMeasurementAnalyzer
with existing quake-add-metadata
pass
#2610
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
Merged
Merged
[Python] [refactoring] Replace MidCircuitMeasurementAnalyzer
with existing quake-add-metadata
pass
#2610
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
27b2304
* Remove the Python `MidCircuitMeasurementAnalyzer` and use
khalatepradnya dd90de6
* Patch from Anna to handle the data capture and storage issue.
khalatepradnya 178b6c6
* Added destructor for PyKernelDecorator which in turn calss the
khalatepradnya eb12f85
DCO Remediation Commit for Pradnya Khalate <[email protected]>
khalatepradnya 489350d
Merge branch 'main' into fix-issue-2000
khalatepradnya c87425b
Merge branch 'main' into fix-issue-2000
khalatepradnya 86df985
* Removed import of 'MidCircuitMeasurementAnalyzer'
khalatepradnya 4fe42a2
* Refactor the checks for photonics target into a target handler
khalatepradnya 15d5bf9
* Update the reason for failure for explicit measurements test.
khalatepradnya a4f7d5d
Merge branch 'main' into fix-issue-2000
khalatepradnya 50b2e54
Update python/cudaq/runtime/sample.py
khalatepradnya bc07eaa
Merge branch 'main' into fix-issue-2000
khalatepradnya 92e6819
Merge branch 'main' into fix-issue-2000
khalatepradnya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# ============================================================================ # | ||
# Copyright (c) 2025 NVIDIA Corporation & Affiliates. # | ||
# All rights reserved. # | ||
# # | ||
# This source code and the accompanying materials are made available under # | ||
# the terms of the Apache License 2.0 which accompanies this distribution. # | ||
# ============================================================================ # | ||
|
||
from cudaq.mlir._mlir_libs._quakeDialects import cudaq_runtime | ||
from .photonics_kernel import PhotonicsHandler | ||
|
||
|
||
class TargetHandler: | ||
"""Base class for target-specific behavior""" | ||
|
||
def skip_compilation(self): | ||
# By default, perform compilation on the kernel | ||
return False | ||
|
||
def call_processed(self, decorator, args): | ||
# `None` indicates standard call should be used | ||
return None | ||
|
||
|
||
class DefaultTargetHandler(TargetHandler): | ||
"""Standard target handler""" | ||
pass | ||
|
||
|
||
class PhotonicsTargetHandler(TargetHandler): | ||
"""Handler for `orca-photonics` target""" | ||
|
||
def skip_compilation(self): | ||
return True | ||
|
||
def call_processed(self, kernel, args): | ||
if kernel is None: | ||
raise RuntimeError( | ||
"The 'orca-photonics' target must be used with a valid function." | ||
) | ||
# NOTE: Since this handler does not support MLIR mode (yet), just | ||
# invoke the kernel. If calling from a bound function, need to | ||
# unpack the arguments, for example, see `pyGetStateLibraryMode` | ||
try: | ||
context_name = cudaq_runtime.getExecutionContextName() | ||
except RuntimeError: | ||
context_name = None | ||
|
||
callable_args = args | ||
if "extract-state" == context_name and len(args) == 1: | ||
callable_args = args[0] | ||
|
||
PhotonicsHandler(kernel)(*callable_args) | ||
# `True` indicates call was handled | ||
return True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.