Commit 6531dc3
authored
[python] Move kernel signature inference out of MLIR compilation (#3930)
I've broken up this PR into two commits that can be reviewed
independently:
The first commit contains "clean-ups". It doesn't introduce any new
functionality nor should it change how anything is currently working. It
just removes function arguments that aren't used, renames a couple of
things and should make the code more readable. I'm including this here
because it made my actual work much easier. These breaking changes are
acceptable as they are within the `python/cudaq/kernel` folder, which is
not publicly exposed (discussed with Bettina).
The second commit is the real contribution:
- The main goal is to parse the kernel signature _before_ running the
MLIR compilation. This is required so that we can delay MLIR compilation
until the first kernel invocation (in a future PR).
- To this end, an AST visitor in `python/cudaq/kernel/analysis.py` is
extended to parse the function annotations. This can be run before MLIR
compilation
- A type `KernelSignature` is introduced to consolidate all kernel type
information that was scattered across many attributes in one place.
- `KernelSignature` now only stores the kernel types as MLIR types
(before, both Python and MLIR types were stored). This makes it easier
to handle as there is a single source of truth (and Python types can be
recovered using `mlirTypeToPyType`)
EDIT: Added a third commit that fixes issue #2895
I've noted that a lot of this Python code uses CamelCase, even though
our style guide ([Google style
guide](#2895)) recommends
snake_case. I'm using snake_case where new names/variables are
introduced, but limited the number of existing names that had to be
changed.
closes #2895
---------
Signed-off-by: Luca Mondada <luca@mondada.net>1 parent b235c5a commit 6531dc3
File tree
15 files changed
+792
-292
lines changed- python
- cudaq
- kernel
- runtime
- runtime/cudaq/platform
- tests/kernel
15 files changed
+792
-292
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | 11 | | |
| 12 | + | |
13 | 13 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | 14 | | |
18 | | - | |
19 | | - | |
| 15 | + | |
20 | 16 | | |
21 | | - | |
22 | | - | |
| 17 | + | |
| 18 | + | |
23 | 19 | | |
24 | 20 | | |
25 | | - | |
26 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
27 | 29 | | |
28 | 30 | | |
29 | | - | |
30 | | - | |
31 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
32 | 46 | | |
33 | 47 | | |
34 | 48 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1360 | 1360 | | |
1361 | 1361 | | |
1362 | 1362 | | |
| 1363 | + | |
1363 | 1364 | | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
1364 | 1368 | | |
1365 | 1369 | | |
1366 | 1370 | | |
1367 | 1371 | | |
1368 | 1372 | | |
1369 | 1373 | | |
1370 | | - | |
1371 | | - | |
1372 | | - | |
1373 | | - | |
1374 | | - | |
1375 | | - | |
1376 | | - | |
1377 | | - | |
| 1374 | + | |
| 1375 | + | |
1378 | 1376 | | |
1379 | 1377 | | |
1380 | 1378 | | |
1381 | 1379 | | |
1382 | | - | |
| 1380 | + | |
1383 | 1381 | | |
1384 | 1382 | | |
1385 | 1383 | | |
1386 | 1384 | | |
1387 | 1385 | | |
1388 | | - | |
1389 | | - | |
| 1386 | + | |
| 1387 | + | |
1390 | 1388 | | |
1391 | 1389 | | |
1392 | 1390 | | |
1393 | 1391 | | |
1394 | | - | |
1395 | | - | |
| 1392 | + | |
1396 | 1393 | | |
1397 | 1394 | | |
1398 | 1395 | | |
| |||
0 commit comments