-
Notifications
You must be signed in to change notification settings - Fork 40
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
[WIP] Create a runtime OQD device that generates openapl #1479
Open
paul0403
wants to merge
11
commits into
main
Choose a base branch
from
paul0403/rtd_oqd_openaplGen
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5717092
init: run a empty "hello oqd world!" capi stub
paul0403 04bb28f
strip down to minimal runnable llvm ir
paul0403 4447715
delete frontend example
paul0403 5127837
setup build system for oqd capi
paul0403 ed42da1
typo
paul0403 c0090df
remove extra lines in cmake
paul0403 66ff047
format
paul0403 294730a
add tests cmake
paul0403 1afbcfe
update github action scripts
paul0403 fb9d323
update cmake
paul0403 76b56dd
is CI actually running the test??
paul0403 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 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,57 @@ | ||
; ModuleID = 'LLVMDialectModule' | ||
source_filename = "LLVMDialectModule" | ||
|
||
@"{'shots': 1000}" = internal constant [16 x i8] c"{'shots': 1000}\00" | ||
@oqd = internal constant [4 x i8] c"oqd\00" | ||
@"/home/paul.wang/catalyst_new/catalyst/frontend/catalyst/utils/../../catalyst/third_party/oqd/src/build/librtd_oqd.so" = internal constant [117 x i8] c"/home/paul.wang/catalyst_new/catalyst/frontend/catalyst/utils/../../catalyst/third_party/oqd/src/build/librtd_oqd.so\00" | ||
|
||
declare void @__catalyst__oqd__greetings() | ||
|
||
declare void @__catalyst__rt__finalize() | ||
|
||
declare void @__catalyst__rt__initialize(ptr) | ||
|
||
declare void @__catalyst__rt__device_release() | ||
|
||
declare void @__catalyst__rt__device_init(ptr, ptr, ptr, i64) | ||
|
||
define void @jit_f() { | ||
call void @f_0() | ||
ret void | ||
} | ||
|
||
define void @_catalyst_pyface_jit_f(ptr %0, ptr %1) { | ||
call void @_catalyst_ciface_jit_f(ptr %0) | ||
ret void | ||
} | ||
|
||
define void @_catalyst_ciface_jit_f(ptr %0) { | ||
call void @jit_f() | ||
ret void | ||
} | ||
|
||
define void @f_0() { | ||
call void @__catalyst__rt__device_init(ptr @"/home/paul.wang/catalyst_new/catalyst/frontend/catalyst/utils/../../catalyst/third_party/oqd/src/build/librtd_oqd.so", ptr @oqd, ptr @"{'shots': 1000}", i64 1000) | ||
call void @__catalyst__oqd__greetings() | ||
call void @__catalyst__rt__device_release() | ||
ret void | ||
} | ||
|
||
define void @setup() { | ||
call void @__catalyst__rt__initialize(ptr null) | ||
ret void | ||
} | ||
|
||
define void @teardown() { | ||
call void @__catalyst__rt__finalize() | ||
ret void | ||
} | ||
|
||
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite) | ||
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0 | ||
|
||
attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) } | ||
|
||
!llvm.module.flags = !{!0} | ||
|
||
!0 = !{i32 2, !"Debug Info Version", i32 3} |
This file contains 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,21 @@ | ||
import pennylane as qml | ||
import pytest | ||
|
||
import catalyst | ||
from catalyst import qjit | ||
from catalyst.third_party.oqd import OQDDevice | ||
from catalyst.debug import get_compilation_stage, replace_ir | ||
|
||
dev = OQDDevice(backend="default", shots=1000, wires=8) | ||
|
||
@qjit#(keep_intermediate=True) | ||
@qml.qnode(dev) | ||
def f(): | ||
qml.Hadamard(wires=0) | ||
return qml.probs() | ||
|
||
with open("6_llvm_ir.ll", "r") as file: | ||
ir = file.read() | ||
replace_ir(f, "llvm_ir", ir) | ||
|
||
f() |
This file contains 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 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,24 @@ | ||
// Copyright 2025 Xanadu Quantum Technologies Inc. | ||
|
||
// 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. | ||
|
||
#include <iostream> | ||
|
||
extern "C" { | ||
|
||
void __catalyst__oqd__greetings() { | ||
std::cout << "Hello OQD world!" << std::endl; | ||
} | ||
|
||
|
||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changelog