From b22b7d7bfed69db769d7a23de51cf0c50ad8bc3e Mon Sep 17 00:00:00 2001 From: John Lapeyre Date: Thu, 2 May 2024 16:01:27 -0400 Subject: [PATCH] Remove check for U gate in map_gate_ids * This requires modifying the external parser crate. * Depend temporarily on the branch of the parser with this modification. * Make another change required by other upstream improvments. * Cargo config files are changed because of above changes. --- Cargo.lock | 10 +++++----- crates/qasm3/Cargo.toml | 2 +- crates/qasm3/src/build.rs | 4 ---- crates/qasm3/src/expr.rs | 4 ++-- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1f06d100f846..f05d367ea22f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -891,7 +891,7 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "oq3_lexer" version = "0.5.0" -source = "git+https://github.com/jlapeyre/openqasm3_parser?branch=update-for-qiskit-importer#fa3738e6c02c9a25f5528b2a915f8cf053b35b84" +source = "git+https://github.com/jlapeyre/openqasm3_parser?branch=no-U-in-gate-list#fc8dfa7a561c48106946b7ef14724dbc9c71d791" dependencies = [ "unicode-properties", "unicode-xid", @@ -900,7 +900,7 @@ dependencies = [ [[package]] name = "oq3_parser" version = "0.5.0" -source = "git+https://github.com/jlapeyre/openqasm3_parser?branch=update-for-qiskit-importer#fa3738e6c02c9a25f5528b2a915f8cf053b35b84" +source = "git+https://github.com/jlapeyre/openqasm3_parser?branch=no-U-in-gate-list#fc8dfa7a561c48106946b7ef14724dbc9c71d791" dependencies = [ "drop_bomb", "oq3_lexer", @@ -910,7 +910,7 @@ dependencies = [ [[package]] name = "oq3_semantics" version = "0.5.0" -source = "git+https://github.com/jlapeyre/openqasm3_parser?branch=update-for-qiskit-importer#fa3738e6c02c9a25f5528b2a915f8cf053b35b84" +source = "git+https://github.com/jlapeyre/openqasm3_parser?branch=no-U-in-gate-list#fc8dfa7a561c48106946b7ef14724dbc9c71d791" dependencies = [ "boolenum", "hashbrown 0.12.3", @@ -922,7 +922,7 @@ dependencies = [ [[package]] name = "oq3_source_file" version = "0.5.0" -source = "git+https://github.com/jlapeyre/openqasm3_parser?branch=update-for-qiskit-importer#fa3738e6c02c9a25f5528b2a915f8cf053b35b84" +source = "git+https://github.com/jlapeyre/openqasm3_parser?branch=no-U-in-gate-list#fc8dfa7a561c48106946b7ef14724dbc9c71d791" dependencies = [ "ariadne", "oq3_syntax", @@ -931,7 +931,7 @@ dependencies = [ [[package]] name = "oq3_syntax" version = "0.5.0" -source = "git+https://github.com/jlapeyre/openqasm3_parser?branch=update-for-qiskit-importer#fa3738e6c02c9a25f5528b2a915f8cf053b35b84" +source = "git+https://github.com/jlapeyre/openqasm3_parser?branch=no-U-in-gate-list#fc8dfa7a561c48106946b7ef14724dbc9c71d791" dependencies = [ "cov-mark", "either", diff --git a/crates/qasm3/Cargo.toml b/crates/qasm3/Cargo.toml index ef0fce87d545..2c620a62a19c 100644 --- a/crates/qasm3/Cargo.toml +++ b/crates/qasm3/Cargo.toml @@ -18,4 +18,4 @@ extension-module = ["pyo3/extension-module"] pyo3.workspace = true indexmap.workspace = true hashbrown.workspace = true -oq3_semantics = { git = "https://github.com/jlapeyre/openqasm3_parser", branch = "update-for-qiskit-importer"} +oq3_semantics = { git = "https://github.com/jlapeyre/openqasm3_parser", branch = "no-U-in-gate-list"} diff --git a/crates/qasm3/src/build.rs b/crates/qasm3/src/build.rs index 82d4e532b01e..9761e1f602ac 100644 --- a/crates/qasm3/src/build.rs +++ b/crates/qasm3/src/build.rs @@ -231,10 +231,6 @@ impl BuilderState { // Gates mapped via CustomGates will not raise an exception. fn map_gate_ids(&mut self, _py: Python, ast_symbols: &SymbolTable) -> PyResult<()> { for (name, name_id, defined_num_params, defined_num_qubits) in ast_symbols.gates().iter() { - if *name == "U" { - // The sole built in gate. `gphase` is treated specially. - continue; - } let pygate = self.pygates.get(*name).ok_or_else(|| { QASM3ImporterError::new_err(format!("can't handle non-built-in gate: '{}'", name)) })?; diff --git a/crates/qasm3/src/expr.rs b/crates/qasm3/src/expr.rs index 8fc4c8a8a534..f53bcbb9b201 100644 --- a/crates/qasm3/src/expr.rs +++ b/crates/qasm3/src/expr.rs @@ -241,11 +241,11 @@ pub fn eval_qarg( qarg: &asg::GateOperand, ) -> PyResult { match qarg { - asg::GateOperand::Identifier(iden) => broadcast_bits_for_identifier( + asg::GateOperand::Identifier(symbol) => broadcast_bits_for_identifier( py, &our_symbols.qubits, &our_symbols.qregs, - iden.symbol().as_ref().unwrap(), + symbol.as_ref().unwrap(), ), asg::GateOperand::IndexedIdentifier(indexed) => { let iden_symbol = indexed.identifier().as_ref().unwrap();