Skip to content
Open
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
162 changes: 98 additions & 64 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ large_enum_variant = "allow"
[patch.crates-io]

# Uncomment to use unreleased versions of hugr
# hugr = { git = "https://github.com/quantinuum/hugr", "rev" = "de7b9f7581ae02cd80dff7b12794b55635903304" }
# hugr-core = { git = "https://github.com/quantinuum/hugr", "rev" = "de7b9f7581ae02cd80dff7b12794b55635903304" }
# hugr-cli = { git = "https://github.com/quantinuum/hugr", "rev" = "de7b9f7581ae02cd80dff7b12794b55635903304" }
# hugr-llvm = { git = "https://github.com/quantinuum/hugr", "rev" = "de7b9f7581ae02cd80dff7b12794b55635903304" }
hugr = { git = "https://github.com/quantinuum/hugr", branch = "george/debuginfo" }
Copy link
Copy Markdown
Contributor Author

@cgh-qtnm cgh-qtnm Apr 20, 2026

Choose a reason for hiding this comment

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

Need to update to a released version of HUGR and remove these patches before merging.

hugr-core = { git = "https://github.com/quantinuum/hugr", branch = "george/debuginfo" }
hugr-cli = { git = "https://github.com/quantinuum/hugr", branch = "george/debuginfo" }
hugr-llvm = { git = "https://github.com/quantinuum/hugr", branch = "george/debuginfo" }
Comment thread
cgh-qtnm marked this conversation as resolved.
# portgraph = { git = "https://github.com/quantinuum/portgraph", rev = "68b96ac737e0c285d8c543b2d74a7aa80a18202c" }

[workspace.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion qis-compiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ typetag.workspace = true

# Defined here so it can be overridden by the codspeed CI job
# using `cargo add`.
insta = "1.47.0"
insta = "1.47.2"

[package.metadata.cargo-machete]
ignored = ["cbindgen", "pyo3-build-config"]
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
def compile_to_bitcode(pkg_bytes: bytes, opt_level: int = 2) -> bytes:
def compile_to_bitcode(
pkg_bytes: bytes,
opt_level: int = 2,
target_triple: str = "native",
emit_debug: bool = False,
) -> bytes:
"""Compile serialized HUGR to LLVM IR bitcode"""
...

def compile_to_llvm_ir(pkg_bytes: bytes, opt_level: int = 2) -> str:
def compile_to_llvm_ir(
pkg_bytes: bytes,
opt_level: int = 2,
target_triple: str = "native",
emit_debug: bool = False,
) -> str:
"""Compile serialized HUGR to LLVM IR string"""
...

Expand Down
8 changes: 7 additions & 1 deletion qis-compiler/python/tests/generate_hugrs.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "guppylang ==0.21.9",
# "guppylang==0.21.9",
# "guppylang-internals",
# "tket",
# ]
# ///
# TODO: point at re-released guppylang(-internals) once available with debug info. right
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Need to fix this before merging, once latest guppylang is rereleased.

# now the code below is not compatible with the version specified above.

from pathlib import Path

Expand All @@ -25,6 +28,7 @@
x,
z,
)
from guppylang_internals.debug_mode import turn_off_debug_mode, turn_on_debug_mode

resources_dir = Path(__file__).parent / "resources"

Expand Down Expand Up @@ -244,5 +248,7 @@ def foo(a: int) -> None:
rng,
entry_args,
]:
turn_on_debug_mode()
envelope = func()
turn_off_debug_mode()
Comment thread
cgh-qtnm marked this conversation as resolved.
(resources_dir / f"{func.__name__}.hugr").write_bytes(envelope)
Binary file modified qis-compiler/python/tests/resources/check.hugr
Binary file not shown.
Binary file modified qis-compiler/python/tests/resources/discard_qb_array.hugr
Binary file not shown.
Binary file modified qis-compiler/python/tests/resources/entry_args.hugr
Binary file not shown.
Binary file modified qis-compiler/python/tests/resources/flip_some.hugr
Binary file not shown.
Binary file modified qis-compiler/python/tests/resources/measure_qb_array.hugr
Binary file not shown.
Binary file modified qis-compiler/python/tests/resources/no_results.hugr
Binary file not shown.
Binary file modified qis-compiler/python/tests/resources/postselect_exit.hugr
Binary file not shown.
Binary file modified qis-compiler/python/tests/resources/postselect_panic.hugr
Binary file not shown.
Binary file modified qis-compiler/python/tests/resources/print_current_shot.hugr
Binary file not shown.
Binary file modified qis-compiler/python/tests/resources/rng.hugr
Binary file not shown.
Binary file modified qis-compiler/python/tests/resources/rus.hugr
Binary file not shown.
Binary file modified qis-compiler/python/tests/resources/unsupported_pytket_ops.hugr
Binary file not shown.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,74 @@ target triple = "aarch64-apple-darwin"
@res_c3.B223E16D.0 = private constant [13 x i8] c"\0CUSER:BOOL:c3"
@"e_No more qu.3B2EEBF0.0" = private constant [47 x i8] c".EXIT:INT:No more qubits available to allocate."

define void @"__hugr__.__main__.flip_some.<locals>.main.1"() local_unnamed_addr !dbg !4 {
alloca_block:
%qalloc.i = tail call i64 @___qalloc(), !dbg !8
%not_max.not.not.i = icmp eq i64 %qalloc.i, -1, !dbg !8
br i1 %not_max.not.not.i, label %cond_40_case_0.i, label %__hugr__.__tk2_qalloc.36.exit, !dbg !8

cond_40_case_0.i: ; preds = %alloca_block
tail call void @panic(i32 1001, ptr nonnull @"e_No more qu.3B2EEBF0.0"), !dbg !8
unreachable, !dbg !8

__hugr__.__tk2_qalloc.36.exit: ; preds = %alloca_block
tail call void @___reset(i64 %qalloc.i), !dbg !8
tail call void @___rxy(i64 %qalloc.i, double 0x400921FB54442D18, double 0.000000e+00), !dbg !9
%qalloc.i101 = tail call i64 @___qalloc(), !dbg !10
%not_max.not.not.i102 = icmp eq i64 %qalloc.i101, -1, !dbg !10
br i1 %not_max.not.not.i102, label %cond_54_case_0.i, label %__hugr__.__tk2_qalloc.50.exit, !dbg !10

cond_54_case_0.i: ; preds = %__hugr__.__tk2_qalloc.36.exit
tail call void @panic(i32 1001, ptr nonnull @"e_No more qu.3B2EEBF0.0"), !dbg !10
unreachable, !dbg !10

__hugr__.__tk2_qalloc.50.exit: ; preds = %__hugr__.__tk2_qalloc.36.exit
tail call void @___reset(i64 %qalloc.i101), !dbg !10
%qalloc.i103 = tail call i64 @___qalloc(), !dbg !11
%not_max.not.not.i104 = icmp eq i64 %qalloc.i103, -1, !dbg !11
br i1 %not_max.not.not.i104, label %cond_68_case_0.i, label %__hugr__.__tk2_qalloc.64.exit, !dbg !11

cond_68_case_0.i: ; preds = %__hugr__.__tk2_qalloc.50.exit
tail call void @panic(i32 1001, ptr nonnull @"e_No more qu.3B2EEBF0.0"), !dbg !11
unreachable, !dbg !11

__hugr__.__tk2_qalloc.64.exit: ; preds = %__hugr__.__tk2_qalloc.50.exit
tail call void @___reset(i64 %qalloc.i103), !dbg !11
tail call void @___rxy(i64 %qalloc.i103, double 0x400921FB54442D18, double 0.000000e+00), !dbg !12
%qalloc.i105 = tail call i64 @___qalloc(), !dbg !13
%not_max.not.not.i106 = icmp eq i64 %qalloc.i105, -1, !dbg !13
br i1 %not_max.not.not.i106, label %cond_82_case_0.i, label %__hugr__.__tk2_qalloc.78.exit, !dbg !13

cond_82_case_0.i: ; preds = %__hugr__.__tk2_qalloc.64.exit
tail call void @panic(i32 1001, ptr nonnull @"e_No more qu.3B2EEBF0.0"), !dbg !13
unreachable, !dbg !13

__hugr__.__tk2_qalloc.78.exit: ; preds = %__hugr__.__tk2_qalloc.64.exit
tail call void @___reset(i64 %qalloc.i105), !dbg !13
%lazy_measure = tail call i64 @___lazy_measure(i64 %qalloc.i)
tail call void @___qfree(i64 %qalloc.i)
%read_bool = tail call i1 @___read_future_bool(i64 %lazy_measure)
tail call void @___dec_future_refcount(i64 %lazy_measure)
tail call void @print_bool(ptr nonnull @res_c0.7C14CD6E.0, i64 12, i1 %read_bool), !dbg !14
%lazy_measure22 = tail call i64 @___lazy_measure(i64 %qalloc.i101)
tail call void @___qfree(i64 %qalloc.i101)
%read_bool35 = tail call i1 @___read_future_bool(i64 %lazy_measure22)
tail call void @___dec_future_refcount(i64 %lazy_measure22)
tail call void @print_bool(ptr nonnull @res_c1.1F7A6571.0, i64 12, i1 %read_bool35), !dbg !15
%lazy_measure44 = tail call i64 @___lazy_measure(i64 %qalloc.i103)
tail call void @___qfree(i64 %qalloc.i103)
%read_bool57 = tail call i1 @___read_future_bool(i64 %lazy_measure44)
tail call void @___dec_future_refcount(i64 %lazy_measure44)
tail call void @print_bool(ptr nonnull @res_c2.60825383.0, i64 12, i1 %read_bool57), !dbg !16
tail call void @___rxy(i64 %qalloc.i105, double 0x400921FB54442D18, double 0.000000e+00), !dbg !17
%lazy_measure67 = tail call i64 @___lazy_measure(i64 %qalloc.i105)
tail call void @___qfree(i64 %qalloc.i105)
%read_bool80 = tail call i1 @___read_future_bool(i64 %lazy_measure67)
tail call void @___dec_future_refcount(i64 %lazy_measure67)
tail call void @print_bool(ptr nonnull @res_c3.B223E16D.0, i64 12, i1 %read_bool80), !dbg !18
ret void
}

declare i64 @___lazy_measure(i64) local_unnamed_addr

declare void @___qfree(i64) local_unnamed_addr
Expand All @@ -28,74 +96,12 @@ declare void @panic(i32, ptr) local_unnamed_addr #0

declare void @___rxy(i64, double, double) local_unnamed_addr

define i64 @qmain(i64 %0) local_unnamed_addr {
define i64 @qmain(i64 %0) local_unnamed_addr !dbg !19 {
entry:
tail call void @setup(i64 %0)
%qalloc.i.i = tail call i64 @___qalloc()
%not_max.not.not.i.i = icmp eq i64 %qalloc.i.i, -1
br i1 %not_max.not.not.i.i, label %cond_40_case_0.i.i, label %__hugr__.__tk2_qalloc.36.exit.i

cond_40_case_0.i.i: ; preds = %entry
tail call void @panic(i32 1001, ptr nonnull @"e_No more qu.3B2EEBF0.0")
unreachable

__hugr__.__tk2_qalloc.36.exit.i: ; preds = %entry
tail call void @___reset(i64 %qalloc.i.i)
tail call void @___rxy(i64 %qalloc.i.i, double 0x400921FB54442D18, double 0.000000e+00)
%qalloc.i101.i = tail call i64 @___qalloc()
%not_max.not.not.i102.i = icmp eq i64 %qalloc.i101.i, -1
br i1 %not_max.not.not.i102.i, label %cond_54_case_0.i.i, label %__hugr__.__tk2_qalloc.50.exit.i

cond_54_case_0.i.i: ; preds = %__hugr__.__tk2_qalloc.36.exit.i
tail call void @panic(i32 1001, ptr nonnull @"e_No more qu.3B2EEBF0.0")
unreachable

__hugr__.__tk2_qalloc.50.exit.i: ; preds = %__hugr__.__tk2_qalloc.36.exit.i
tail call void @___reset(i64 %qalloc.i101.i)
%qalloc.i103.i = tail call i64 @___qalloc()
%not_max.not.not.i104.i = icmp eq i64 %qalloc.i103.i, -1
br i1 %not_max.not.not.i104.i, label %cond_68_case_0.i.i, label %__hugr__.__tk2_qalloc.64.exit.i

cond_68_case_0.i.i: ; preds = %__hugr__.__tk2_qalloc.50.exit.i
tail call void @panic(i32 1001, ptr nonnull @"e_No more qu.3B2EEBF0.0")
unreachable

__hugr__.__tk2_qalloc.64.exit.i: ; preds = %__hugr__.__tk2_qalloc.50.exit.i
tail call void @___reset(i64 %qalloc.i103.i)
tail call void @___rxy(i64 %qalloc.i103.i, double 0x400921FB54442D18, double 0.000000e+00)
%qalloc.i105.i = tail call i64 @___qalloc()
%not_max.not.not.i106.i = icmp eq i64 %qalloc.i105.i, -1
br i1 %not_max.not.not.i106.i, label %cond_82_case_0.i.i, label %__hugr__.main.1.exit

cond_82_case_0.i.i: ; preds = %__hugr__.__tk2_qalloc.64.exit.i
tail call void @panic(i32 1001, ptr nonnull @"e_No more qu.3B2EEBF0.0")
unreachable

__hugr__.main.1.exit: ; preds = %__hugr__.__tk2_qalloc.64.exit.i
tail call void @___reset(i64 %qalloc.i105.i)
%lazy_measure.i = tail call i64 @___lazy_measure(i64 %qalloc.i.i)
tail call void @___qfree(i64 %qalloc.i.i)
%read_bool.i = tail call i1 @___read_future_bool(i64 %lazy_measure.i)
tail call void @___dec_future_refcount(i64 %lazy_measure.i)
tail call void @print_bool(ptr nonnull @res_c0.7C14CD6E.0, i64 12, i1 %read_bool.i)
%lazy_measure22.i = tail call i64 @___lazy_measure(i64 %qalloc.i101.i)
tail call void @___qfree(i64 %qalloc.i101.i)
%read_bool35.i = tail call i1 @___read_future_bool(i64 %lazy_measure22.i)
tail call void @___dec_future_refcount(i64 %lazy_measure22.i)
tail call void @print_bool(ptr nonnull @res_c1.1F7A6571.0, i64 12, i1 %read_bool35.i)
%lazy_measure44.i = tail call i64 @___lazy_measure(i64 %qalloc.i103.i)
tail call void @___qfree(i64 %qalloc.i103.i)
%read_bool57.i = tail call i1 @___read_future_bool(i64 %lazy_measure44.i)
tail call void @___dec_future_refcount(i64 %lazy_measure44.i)
tail call void @print_bool(ptr nonnull @res_c2.60825383.0, i64 12, i1 %read_bool57.i)
tail call void @___rxy(i64 %qalloc.i105.i, double 0x400921FB54442D18, double 0.000000e+00)
%lazy_measure67.i = tail call i64 @___lazy_measure(i64 %qalloc.i105.i)
tail call void @___qfree(i64 %qalloc.i105.i)
%read_bool80.i = tail call i1 @___read_future_bool(i64 %lazy_measure67.i)
tail call void @___dec_future_refcount(i64 %lazy_measure67.i)
tail call void @print_bool(ptr nonnull @res_c3.B223E16D.0, i64 12, i1 %read_bool80.i)
%1 = tail call i64 @teardown()
ret i64 %1
tail call void @setup(i64 %0), !dbg !24
tail call void @"__hugr__.__main__.flip_some.<locals>.main.1"(), !dbg !24
%1 = tail call i64 @teardown(), !dbg !24
ret i64 %1, !dbg !24
}

declare void @setup(i64) local_unnamed_addr
Expand All @@ -104,6 +110,32 @@ declare i64 @teardown() local_unnamed_addr

attributes #0 = { noreturn }

!name = !{!0}

!0 = !{!"mainlib"}
!llvm.module.flags = !{!0}
!llvm.dbg.cu = !{!1}
!name = !{!3}

!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = distinct !DICompileUnit(language: DW_LANG_Python, file: !2, producer: "guppylang (guppylang-internals-v0.32.0)-v0.21.11", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
!2 = !DIFile(filename: "/Users/george.hodgkins/proj/tket2/qis-compiler/python/tests/generate_hugrs.py", directory: "file:///Users/george.hodgkins/proj/clone-anduril")
!3 = !{!"mainlib"}
!4 = distinct !DISubprogram(name: "flip_some.<locals>.main", linkageName: "__hugr__.__main__.flip_some.<locals>.main.1", scope: null, file: !5, line: 74, type: !6, scopeLine: 75, spFlags: DISPFlagDefinition, unit: !1)
!5 = !DIFile(filename: "/Users/george.hodgkins/proj/tket2/qis-compiler/python/tests/generate_hugrs.py", directory: "")
!6 = !DISubroutineType(types: !7)
!7 = !{null}
!8 = !DILocation(line: 75, column: 20, scope: !4)
!9 = !DILocation(line: 79, column: 8, scope: !4)
!10 = !DILocation(line: 76, column: 20, scope: !4)
!11 = !DILocation(line: 77, column: 20, scope: !4)
!12 = !DILocation(line: 80, column: 8, scope: !4)
!13 = !DILocation(line: 78, column: 20, scope: !4)
!14 = !DILocation(line: 82, column: 8, scope: !4)
!15 = !DILocation(line: 83, column: 8, scope: !4)
!16 = !DILocation(line: 84, column: 8, scope: !4)
!17 = !DILocation(line: 81, column: 8, scope: !4)
!18 = !DILocation(line: 85, column: 8, scope: !4)
!19 = distinct !DISubprogram(name: "qmain", linkageName: "qmain", scope: null, file: !20, type: !21, spFlags: DISPFlagDefinition, unit: !1)
!20 = !DIFile(filename: "COMPILER_GENERATED_CODE", directory: "")
!21 = !DISubroutineType(types: !22)
!22 = !{!23, !23}
!23 = !DIBasicType(name: "i64", size: 64, encoding: DW_ATE_unsigned)
!24 = !DILocation(line: 0, scope: !19)
Loading
Loading