diff --git a/Cargo.lock b/Cargo.lock index 0c75178..029f708 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,7 +14,7 @@ dependencies = [ [[package]] name = "allocator" version = "0.0.0" -source = "git+https://github.com/microsoft/qdk.git?branch=main#c1ca1a247cd0a9687a9fa0fbd08ff72ef5f451aa" +source = "git+https://github.com/microsoft/qdk.git?tag=v1.23.0#fd9428d60cc1af98f25fe124b90487a3c1c3f95b" dependencies = [ "mimalloc-sys", ] @@ -539,7 +539,7 @@ checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" [[package]] name = "library" version = "0.0.0" -source = "git+https://github.com/microsoft/qdk.git?branch=main#c1ca1a247cd0a9687a9fa0fbd08ff72ef5f451aa" +source = "git+https://github.com/microsoft/qdk.git?tag=v1.23.0#fd9428d60cc1af98f25fe124b90487a3c1c3f95b" [[package]] name = "linux-raw-sys" @@ -597,7 +597,7 @@ dependencies = [ [[package]] name = "mimalloc-sys" version = "0.0.0" -source = "git+https://github.com/microsoft/qdk.git?branch=main#c1ca1a247cd0a9687a9fa0fbd08ff72ef5f451aa" +source = "git+https://github.com/microsoft/qdk.git?tag=v1.23.0#fd9428d60cc1af98f25fe124b90487a3c1c3f95b" dependencies = [ "cc", ] @@ -735,7 +735,7 @@ dependencies = [ [[package]] name = "qdk_simulators" version = "0.0.0" -source = "git+https://github.com/microsoft/qdk.git?branch=main#c1ca1a247cd0a9687a9fa0fbd08ff72ef5f451aa" +source = "git+https://github.com/microsoft/qdk.git?tag=v1.23.0#fd9428d60cc1af98f25fe124b90487a3c1c3f95b" dependencies = [ "quantum-sparse-sim", ] @@ -743,7 +743,7 @@ dependencies = [ [[package]] name = "qsc" version = "0.0.0" -source = "git+https://github.com/microsoft/qdk.git?branch=main#c1ca1a247cd0a9687a9fa0fbd08ff72ef5f451aa" +source = "git+https://github.com/microsoft/qdk.git?tag=v1.23.0#fd9428d60cc1af98f25fe124b90487a3c1c3f95b" dependencies = [ "allocator", "env_logger", @@ -776,7 +776,7 @@ dependencies = [ [[package]] name = "qsc_ast" version = "0.0.0" -source = "git+https://github.com/microsoft/qdk.git?branch=main#c1ca1a247cd0a9687a9fa0fbd08ff72ef5f451aa" +source = "git+https://github.com/microsoft/qdk.git?tag=v1.23.0#fd9428d60cc1af98f25fe124b90487a3c1c3f95b" dependencies = [ "indenter", "miette", @@ -787,7 +787,7 @@ dependencies = [ [[package]] name = "qsc_circuit" version = "0.0.0" -source = "git+https://github.com/microsoft/qdk.git?branch=main#c1ca1a247cd0a9687a9fa0fbd08ff72ef5f451aa" +source = "git+https://github.com/microsoft/qdk.git?tag=v1.23.0#fd9428d60cc1af98f25fe124b90487a3c1c3f95b" dependencies = [ "log", "miette", @@ -810,7 +810,7 @@ dependencies = [ [[package]] name = "qsc_codegen" version = "0.0.0" -source = "git+https://github.com/microsoft/qdk.git?branch=main#c1ca1a247cd0a9687a9fa0fbd08ff72ef5f451aa" +source = "git+https://github.com/microsoft/qdk.git?tag=v1.23.0#fd9428d60cc1af98f25fe124b90487a3c1c3f95b" dependencies = [ "num-bigint", "num-complex", @@ -831,7 +831,7 @@ dependencies = [ [[package]] name = "qsc_data_structures" version = "0.0.0" -source = "git+https://github.com/microsoft/qdk.git?branch=main#c1ca1a247cd0a9687a9fa0fbd08ff72ef5f451aa" +source = "git+https://github.com/microsoft/qdk.git?tag=v1.23.0#fd9428d60cc1af98f25fe124b90487a3c1c3f95b" dependencies = [ "bitflags", "miette", @@ -842,7 +842,7 @@ dependencies = [ [[package]] name = "qsc_doc_gen" version = "0.0.0" -source = "git+https://github.com/microsoft/qdk.git?branch=main#c1ca1a247cd0a9687a9fa0fbd08ff72ef5f451aa" +source = "git+https://github.com/microsoft/qdk.git?tag=v1.23.0#fd9428d60cc1af98f25fe124b90487a3c1c3f95b" dependencies = [ "qsc_ast", "qsc_data_structures", @@ -855,7 +855,7 @@ dependencies = [ [[package]] name = "qsc_eval" version = "0.0.0" -source = "git+https://github.com/microsoft/qdk.git?branch=main#c1ca1a247cd0a9687a9fa0fbd08ff72ef5f451aa" +source = "git+https://github.com/microsoft/qdk.git?tag=v1.23.0#fd9428d60cc1af98f25fe124b90487a3c1c3f95b" dependencies = [ "miette", "ndarray", @@ -875,7 +875,7 @@ dependencies = [ [[package]] name = "qsc_fir" version = "0.0.0" -source = "git+https://github.com/microsoft/qdk.git?branch=main#c1ca1a247cd0a9687a9fa0fbd08ff72ef5f451aa" +source = "git+https://github.com/microsoft/qdk.git?tag=v1.23.0#fd9428d60cc1af98f25fe124b90487a3c1c3f95b" dependencies = [ "indenter", "num-bigint", @@ -886,7 +886,7 @@ dependencies = [ [[package]] name = "qsc_formatter" version = "0.0.0" -source = "git+https://github.com/microsoft/qdk.git?branch=main#c1ca1a247cd0a9687a9fa0fbd08ff72ef5f451aa" +source = "git+https://github.com/microsoft/qdk.git?tag=v1.23.0#fd9428d60cc1af98f25fe124b90487a3c1c3f95b" dependencies = [ "clap", "qsc_data_structures", @@ -896,7 +896,7 @@ dependencies = [ [[package]] name = "qsc_frontend" version = "0.0.0" -source = "git+https://github.com/microsoft/qdk.git?branch=main#c1ca1a247cd0a9687a9fa0fbd08ff72ef5f451aa" +source = "git+https://github.com/microsoft/qdk.git?tag=v1.23.0#fd9428d60cc1af98f25fe124b90487a3c1c3f95b" dependencies = [ "library", "miette", @@ -911,7 +911,7 @@ dependencies = [ [[package]] name = "qsc_hir" version = "0.0.0" -source = "git+https://github.com/microsoft/qdk.git?branch=main#c1ca1a247cd0a9687a9fa0fbd08ff72ef5f451aa" +source = "git+https://github.com/microsoft/qdk.git?tag=v1.23.0#fd9428d60cc1af98f25fe124b90487a3c1c3f95b" dependencies = [ "indenter", "num-bigint", @@ -922,7 +922,7 @@ dependencies = [ [[package]] name = "qsc_linter" version = "0.0.0" -source = "git+https://github.com/microsoft/qdk.git?branch=main#c1ca1a247cd0a9687a9fa0fbd08ff72ef5f451aa" +source = "git+https://github.com/microsoft/qdk.git?tag=v1.23.0#fd9428d60cc1af98f25fe124b90487a3c1c3f95b" dependencies = [ "miette", "qsc_ast", @@ -938,7 +938,7 @@ dependencies = [ [[package]] name = "qsc_lowerer" version = "0.0.0" -source = "git+https://github.com/microsoft/qdk.git?branch=main#c1ca1a247cd0a9687a9fa0fbd08ff72ef5f451aa" +source = "git+https://github.com/microsoft/qdk.git?tag=v1.23.0#fd9428d60cc1af98f25fe124b90487a3c1c3f95b" dependencies = [ "qsc_data_structures", "qsc_fir", @@ -948,7 +948,7 @@ dependencies = [ [[package]] name = "qsc_parse" version = "0.0.0" -source = "git+https://github.com/microsoft/qdk.git?branch=main#c1ca1a247cd0a9687a9fa0fbd08ff72ef5f451aa" +source = "git+https://github.com/microsoft/qdk.git?tag=v1.23.0#fd9428d60cc1af98f25fe124b90487a3c1c3f95b" dependencies = [ "bitflags", "enum-iterator", @@ -963,7 +963,7 @@ dependencies = [ [[package]] name = "qsc_partial_eval" version = "0.0.0" -source = "git+https://github.com/microsoft/qdk.git?branch=main#c1ca1a247cd0a9687a9fa0fbd08ff72ef5f451aa" +source = "git+https://github.com/microsoft/qdk.git?tag=v1.23.0#fd9428d60cc1af98f25fe124b90487a3c1c3f95b" dependencies = [ "miette", "num-bigint", @@ -981,7 +981,7 @@ dependencies = [ [[package]] name = "qsc_passes" version = "0.0.0" -source = "git+https://github.com/microsoft/qdk.git?branch=main#c1ca1a247cd0a9687a9fa0fbd08ff72ef5f451aa" +source = "git+https://github.com/microsoft/qdk.git?tag=v1.23.0#fd9428d60cc1af98f25fe124b90487a3c1c3f95b" dependencies = [ "miette", "qsc_data_structures", @@ -998,7 +998,7 @@ dependencies = [ [[package]] name = "qsc_project" version = "0.0.0" -source = "git+https://github.com/microsoft/qdk.git?branch=main#c1ca1a247cd0a9687a9fa0fbd08ff72ef5f451aa" +source = "git+https://github.com/microsoft/qdk.git?tag=v1.23.0#fd9428d60cc1af98f25fe124b90487a3c1c3f95b" dependencies = [ "async-trait", "futures", @@ -1019,7 +1019,7 @@ dependencies = [ [[package]] name = "qsc_qasm" version = "0.0.0" -source = "git+https://github.com/microsoft/qdk.git?branch=main#c1ca1a247cd0a9687a9fa0fbd08ff72ef5f451aa" +source = "git+https://github.com/microsoft/qdk.git?tag=v1.23.0#fd9428d60cc1af98f25fe124b90487a3c1c3f95b" dependencies = [ "bitflags", "enum-iterator", @@ -1040,7 +1040,7 @@ dependencies = [ [[package]] name = "qsc_rca" version = "0.0.0" -source = "git+https://github.com/microsoft/qdk.git?branch=main#c1ca1a247cd0a9687a9fa0fbd08ff72ef5f451aa" +source = "git+https://github.com/microsoft/qdk.git?tag=v1.23.0#fd9428d60cc1af98f25fe124b90487a3c1c3f95b" dependencies = [ "bitflags", "indenter", @@ -1056,7 +1056,7 @@ dependencies = [ [[package]] name = "qsc_rir" version = "0.0.0" -source = "git+https://github.com/microsoft/qdk.git?branch=main#c1ca1a247cd0a9687a9fa0fbd08ff72ef5f451aa" +source = "git+https://github.com/microsoft/qdk.git?tag=v1.23.0#fd9428d60cc1af98f25fe124b90487a3c1c3f95b" dependencies = [ "indenter", "qsc_data_structures", @@ -1190,7 +1190,7 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "resource_estimator" version = "0.0.0" -source = "git+https://github.com/microsoft/qdk.git?branch=main#c1ca1a247cd0a9687a9fa0fbd08ff72ef5f451aa" +source = "git+https://github.com/microsoft/qdk.git?tag=v1.23.0#fd9428d60cc1af98f25fe124b90487a3c1c3f95b" dependencies = [ "fasteval", "miette", diff --git a/Cargo.toml b/Cargo.toml index ad02f06..2e0275d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,10 +9,10 @@ edition = "2024" crate-type = ["lib", "cdylib", "staticlib"] [dependencies] -qsc = { git = "https://github.com/microsoft/qdk.git", branch = "main" } -qsc_eval = { git = "https://github.com/microsoft/qdk.git", branch = "main" } -qsc_circuit = { git = "https://github.com/microsoft/qdk.git", branch = "main" } -resource_estimator = { git = "https://github.com/microsoft/qdk.git", branch = "main" } +qsc = { git = "https://github.com/microsoft/qdk.git", tag = "v1.23.0" } +qsc_eval = { git = "https://github.com/microsoft/qdk.git", tag = "v1.23.0" } +qsc_circuit = { git = "https://github.com/microsoft/qdk.git", tag = "v1.23.0" } +resource_estimator = { git = "https://github.com/microsoft/qdk.git", tag = "v1.23.0" } thiserror = "1.0" num-bigint = "0.4.5" num-complex = "0.4" diff --git a/src/quantikz.rs b/src/quantikz.rs index 00ffa98..db0ad64 100644 --- a/src/quantikz.rs +++ b/src/quantikz.rs @@ -2,7 +2,7 @@ use qsc::{ LanguageFeatures, PackageType, SourceMap, interpret::{CircuitEntryPoint, CircuitGenerationMethod, Interpreter}, target::Profile, }; -use qsc_circuit::{Circuit, Operation, TracerConfig}; +use qsc_circuit::{Circuit, ComponentColumn, Operation, TracerConfig}; use std::collections::HashMap; use crate::sim::QsError; @@ -56,10 +56,20 @@ fn generate_quantikz_circuit( pub fn circuit_to_quantikz(c: &Circuit) -> String { let (mut rows, register_to_row) = build_rows(c); - let col_count = c.component_grid.len(); + + let grid = if c.component_grid.len() == 1 + && c.component_grid[0].components.len() == 1 + && !c.component_grid[0].components[0].children().is_empty() + { + c.component_grid[0].components[0].children() + } else { + &c.component_grid + }; + + let col_count = grid.len(); let mut table = initialize_table(rows.len(), col_count, &rows); - populate_table(c, ®ister_to_row, &mut table, &mut rows); + populate_table(grid, ®ister_to_row, &mut table, &mut rows); render_latex(&rows, &table) } @@ -103,12 +113,12 @@ fn initialize_table(row_count: usize, col_count: usize, rows: &[Row]) -> Vec], rows: &mut [Row], ) { - for (col_index, col) in c.component_grid.iter().enumerate() { + for (col_index, col) in grid.iter().enumerate() { let table_col = col_index; for op in &col.components { // For measurements, we want to draw on the qubit line, so we treat qubits as targets for visual placement