Skip to content
Open
Show file tree
Hide file tree
Changes from 87 commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
0351238
first draft for some bridge fixes
bettinaheim Sep 30, 2025
6e2a893
getting closer with the testing
bettinaheim Sep 30, 2025
461a32e
more tests and fixes
bettinaheim Oct 1, 2025
3249b15
finished the tuple testing
bettinaheim Oct 2, 2025
1cf4e67
some clean up
bettinaheim Oct 6, 2025
77c02a8
allow to deconstruct lists
bettinaheim Oct 6, 2025
912c905
more clean up
bettinaheim Oct 6, 2025
1b6024a
don't assume stack size
bettinaheim Oct 6, 2025
f8e7835
fixed controlled and adjoint
bettinaheim Oct 7, 2025
9104265
tests for callable kernel args with control and adjoint
bettinaheim Oct 7, 2025
0d8d34d
argument conversion needs reexamination
bettinaheim Oct 8, 2025
a5e4944
handling the vect<bool> conversion in the argument conversion
bettinaheim Oct 8, 2025
bd73206
minor clean up
bettinaheim Oct 8, 2025
95054ff
some test clean up
bettinaheim Oct 8, 2025
418ae3b
some test clean up
bettinaheim Oct 8, 2025
7fab128
some bridge clean up
bettinaheim Oct 9, 2025
c8c699d
added a test
bettinaheim Oct 9, 2025
3ada403
more tests
bettinaheim Oct 9, 2025
7c48168
forgot something
bettinaheim Oct 9, 2025
9d611eb
forgot something
bettinaheim Oct 9, 2025
8f5e619
moving processing of veq functions
bettinaheim Oct 9, 2025
a96dccd
minor things
bettinaheim Oct 10, 2025
8ed8d07
reverting a bad change
bettinaheim Oct 10, 2025
6439bca
proper tests for comparison and found some bugs
bettinaheim Oct 10, 2025
6fb2fe7
more tests
bettinaheim Oct 10, 2025
cf202a1
Merge branch 'main' into list-comprehension
bettinaheim Oct 13, 2025
0c03364
we have some issues with data conversion for __quantum__* functions i…
bettinaheim Oct 13, 2025
e164d88
Merge branch 'list-comprehension' of https://github.com/bettinaheim/c…
bettinaheim Oct 13, 2025
8173b7b
last remaining tests for now
bettinaheim Oct 13, 2025
383584b
forgot to commit matching bridge changes
bettinaheim Oct 13, 2025
4bae1a3
adding missing return
bettinaheim Oct 14, 2025
de6e27e
Merge branch 'main' into list-comprehension
bettinaheim Oct 14, 2025
e96b872
formatting
bettinaheim Oct 14, 2025
db8531d
spelling
bettinaheim Oct 14, 2025
491994a
more formatting
bettinaheim Oct 14, 2025
8c4eb96
more formatting
bettinaheim Oct 14, 2025
62b5caa
pull the modulo change out of this PR
bettinaheim Oct 14, 2025
d4f34a5
formatting
bettinaheim Oct 14, 2025
a4c1470
draft manually pushing and poping stack frames before making this cle…
bettinaheim Oct 15, 2025
4fbb505
to be reverted/revised
bettinaheim Oct 15, 2025
bdbaba1
updating tests for python 3.11-3.13
bettinaheim Oct 15, 2025
277c7f7
Merge branch 'main' into list-comprehension
bettinaheim Oct 15, 2025
fd8074e
adjusting tests for the new errors (or lack thereof)
bettinaheim Oct 15, 2025
26ae70c
Merge branch 'list-comprehension' of https://github.com/bettinaheim/c…
bettinaheim Oct 15, 2025
3011f86
support star for expanding qubit arrays in lists
bettinaheim Oct 15, 2025
f5b183f
minimal support for binary ops in list comprehension
bettinaheim Oct 15, 2025
84515aa
that should update all tests
bettinaheim Oct 16, 2025
9a24085
Merge branch 'main' into list-comprehension
bettinaheim Oct 16, 2025
c49be64
spelling and formatting
bettinaheim Oct 16, 2025
91ee130
Merge branch 'list-comprehension' of https://github.com/bettinaheim/c…
bettinaheim Oct 16, 2025
aa56ce0
allowing almost all binary operators in list comprehension
bettinaheim Oct 16, 2025
81e48f6
formatting
bettinaheim Oct 16, 2025
74eb44d
adding some unpack tests
bettinaheim Oct 16, 2025
59050a5
ajusting example to not use the same local variable as a captured value
bettinaheim Oct 16, 2025
2497c9f
formatting
bettinaheim Oct 16, 2025
88f3b95
ajustments after merge
bettinaheim Oct 16, 2025
dbecdf9
Merge branch 'main' into python-modulo
bettinaheim Oct 20, 2025
1301201
Merge branch 'main' into python-bridge
bettinaheim Oct 21, 2025
e58fc94
Merge branch 'python-modulo' into python-bridge
bettinaheim Oct 21, 2025
a64cb69
clean up before making the frames automatic
bettinaheim Oct 21, 2025
c11cf08
overlooked a failing test
bettinaheim Oct 21, 2025
87e587b
eliminating the attribute sometimes producing two values
bettinaheim Oct 21, 2025
86f785d
removing the manual pushing and popping of frames
bettinaheim Oct 22, 2025
fe3a626
should be an ok structure for the stack
bettinaheim Oct 22, 2025
5961a75
making some decent progress towards making sure we fail when somethin…
bettinaheim Oct 22, 2025
93b975c
validated the gate update
bettinaheim Oct 22, 2025
29ec9d9
just some comments
bettinaheim Oct 22, 2025
486b227
general helper to group values
bettinaheim Oct 23, 2025
01fe16f
minor things
bettinaheim Oct 23, 2025
a9f662c
cleaning up loops
bettinaheim Oct 24, 2025
4643b51
eliminating code duplication in visit_for
bettinaheim Oct 24, 2025
f107ca5
clean up
bettinaheim Oct 27, 2025
f37f20a
more clean up
bettinaheim Oct 27, 2025
55e6177
wip to clean up the handling of reference types
bettinaheim Oct 29, 2025
9b78a5f
more wip
bettinaheim Oct 29, 2025
be3884b
some progress with clean up
bettinaheim Oct 30, 2025
4c5c8ba
minor thing
bettinaheim Oct 30, 2025
04aea9c
first complete outline
bettinaheim Oct 31, 2025
05d1892
existing python kernel tests pass
bettinaheim Oct 31, 2025
59c6978
whitespace fixes
bettinaheim Oct 31, 2025
da53fcf
clean up
bettinaheim Oct 31, 2025
c58e77a
creating list copies when needed
bettinaheim Oct 31, 2025
ffa3697
some clean up for the assignment tests
bettinaheim Oct 31, 2025
c9f2d8d
more assignment tests
bettinaheim Nov 3, 2025
ae0d14b
confirmed value behavior
bettinaheim Nov 3, 2025
74363e9
added an error when we have lists in structs
bettinaheim Nov 4, 2025
dd4ac73
that should do for the assignment tests
bettinaheim Nov 4, 2025
2f929cd
updating most mlir tests
bettinaheim Nov 4, 2025
3a81c6e
python tests are ok, but we have some gaps - commit before closing them
bettinaheim Nov 5, 2025
f625eb2
close to the final version
bettinaheim Nov 6, 2025
7041ab6
clean up
bettinaheim Nov 6, 2025
cf3a0e9
feeling good about assignments now
bettinaheim Nov 6, 2025
cf041b3
python kernel and mlir tests pass
bettinaheim Nov 7, 2025
d665ffa
updates from main
bettinaheim Nov 7, 2025
024d10b
test updates from merge
bettinaheim Nov 7, 2025
cb0e259
fixing list[bool] arg issue
bettinaheim Nov 10, 2025
2a0bb39
other bridge fixes after merge
bettinaheim Nov 10, 2025
64c6d60
python kernel and mlir tests pass
bettinaheim Nov 10, 2025
5a82186
Merge branch 'main' into python-bridge
bettinaheim Nov 11, 2025
02e5fcb
last clean up from merge
bettinaheim Nov 12, 2025
bdcb5f7
removing the now unnecessary loads throughout the bridge
bettinaheim Nov 13, 2025
6dfbdd6
some formatting
bettinaheim Nov 13, 2025
692a668
addressing some review comments
bettinaheim Nov 18, 2025
b873ec0
minor things
bettinaheim Nov 18, 2025
15cbd2e
whitespace
bettinaheim Nov 19, 2025
cf0aebb
undoing change left over from merge
bettinaheim Nov 19, 2025
5156f98
Merge branch 'main' into python-bridge
bettinaheim Nov 19, 2025
c9d37e9
formatting
bettinaheim Nov 19, 2025
eacfe78
spelling
bettinaheim Nov 19, 2025
53b1e33
formatting
bettinaheim Nov 19, 2025
639ebf2
minor thing
bettinaheim Nov 19, 2025
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
3 changes: 3 additions & 0 deletions lib/Frontend/nvqpp/ConvertStmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@ bool QuakeBridgeVisitor::VisitReturnStmt(clang::ReturnStmt *x) {
if (!cudaq::cc::isDynamicType(eleTy))
tySize = irb.getByteSizeOfType(loc, eleTy);
if (!tySize) {
// TODO: we need to recursively create copies of all
// dynamic memory used within the type. See the
// implementation of `visit_Return` in the Python bride.
TODO_x(toLocation(x), x, mangler, "unhandled vector element type");
return false;
}
Expand Down
3 changes: 1 addition & 2 deletions lib/Optimizer/CodeGen/CCToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,7 @@ class SizeOfOpPattern : public ConvertOpToLLVMPattern<cudaq::cc::SizeOfOp> {
ConversionPatternRewriter &rewriter) const override {
auto inputTy = sizeOfOp.getInputType();
auto resultTy = sizeOfOp.getType();
if (quake::isQuakeType(inputTy) || cudaq::cc::isDynamicType(inputTy)) {
// Types that cannot be reified produce the poison op.
if (quake::isQuakeType(inputTy)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change appears to be incorrect. Can you explain how these changes can statically determine the size of an object that's size is only known at runtime?

Copy link
Collaborator Author

@bettinaheim bettinaheim Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we need a more fine-grained check here. Is dynamic fails for arrays of unknown size (I believe sizeof would need to fail in this case as well), span-like types, and any structs that contain these.
Span-like types are vectors and char spans. For vectors, sizeof should not fail, since the size of the vector is perfectly known (three pointers) - not sure about char spans and how they are used.
isDynamicType is also used in a bunch of contexts, however, for which vectors indeed need to be considered dynamic. I can create a new helper isDynamicallySizedType that indeed reflects when the size of the type itself is not known at compile time.

rewriter.replaceOpWithNewOp<cudaq::cc::PoisonOp>(sizeOfOp, resultTy);
return success();
}
Expand Down
26 changes: 26 additions & 0 deletions lib/Optimizer/Transforms/GenKernelExecution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,32 @@ class GenerateKernelExecution
thunk = genThunkFunction(loc, builder, classNameStr, structTy, funcTy,
funcOp);

// The `argsCreator` function doesn't properly deal with structs
// that contain dynamic types. Since we want to revise that in a
// future version, I am opting to simply give a comprehensive enough
// error here rather than fixing that. If we don't fail here, the
// invocation of the `argsCreator` as it is will segfault.
auto checkDynamicStructMember = [&module](llvm::ArrayRef<mlir::Type> tys) {
mlir::LogicalResult res = success();
for (auto ty : tys) {
if (cudaq::cc::isDynamicType(ty)) {
if (auto strTy = dyn_cast<cudaq::cc::StructType>(ty)) {
for (auto memTy : strTy.getMembers()) {
if (cudaq::cc::isDynamicType(memTy))
res = module.emitError("dynamically sized element types for function arguments or returns are not supported");
return res;
}
}
}
}
return res;
};

if (failed(checkDynamicStructMember(funcTy.getInputs().drop_front(startingArgIdx))))
return signalPassFailure();
if (failed(checkDynamicStructMember(funcTy.getResults())))
return signalPassFailure();

// Generate the argsCreator function used by synthesis.
if (startingArgIdx == 0) {
argsCreatorFunc = genKernelArgsCreatorFunction(
Expand Down
8 changes: 5 additions & 3 deletions python/cudaq/kernel/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,11 @@ def visit_Call(self, node):
'attr') and node.func.attr in globalAstRegistry:
self.depKernels[node.func.attr] = globalAstRegistry[
node.func.attr]
elif node.func.value.id == 'cudaq' and node.func.attr in [
'control', 'adjoint'
] and node.args[0].id in globalAstRegistry:
elif isinstance(node.func.value, ast.Name) and \
node.func.value.id == 'cudaq' and \
node.func.attr in ['control', 'adjoint'] and \
isinstance(node.args[0], ast.Name) and \
node.args[0].id in globalAstRegistry:
self.depKernels[node.args[0].id] = globalAstRegistry[
node.args[0].id]

Expand Down
Loading