question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Isometry decomposition does not maintain gate width

See original GitHub issue

The definition of an Isometry instruction does not always have the same number of qubits as the original instruction. e.g.

>>> qc = qk.QuantumCircuit(2)
>>> qc.iso(np.eye(4), [0, 1], [])
<qiskit.circuit.instructionset.InstructionSet object at 0x10b4bfe80>
>>> print(qc)
        β”Œβ”€β”€β”€β”€β”€β”€β”
q_0: |0>─0     β”œ
        β”‚  iso β”‚
q_1: |0>─1     β”œ
        β””β”€β”€β”€β”€β”€β”€β”˜
>>> print(qc.decompose())
        β”Œβ”€β”€β”€β”€β”
q_0: |0>─ Id β”œ
        β””β”€β”€β”€β”€β”˜
q_1: |0>──────

This also occurs for a handful of the examples from https://github.com/Qiskit/qiskit-terra/blob/576b984/test/python/circuit/test_isometry.py#L36 . This confuses e.g. DAGCircuit.substitute_node which expects node replacements to keep the same shape.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Cryoriscommented, Aug 5, 2021

I’m not quite convinced this is really a bug, is it? I would imagine that if you have a gate defined on a set of qubit but it doesn’t actually do anything then shouldn’t it decompose to no operation at all? πŸ™‚

0reactions
kdkcommented, Sep 20, 2021

I don’t think this is an issue anymore (though I’m not exactly sure what’s changed to resolve it). If I try to reproduce the original issue:

>>> qc = qk.QuantumCircuit(2)
>>> qc.iso(np.eye(4), [0, 1], [])
>>> print(qc)
     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
q_0: ─0          β”œ
     β”‚  Isometry β”‚
q_1: ─1          β”œ
     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
>>> print(qc.decompose())
     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
q_0: ─0                 β”œ
     β”‚  circuit-2630_dg β”‚
q_1: ─1                 β”œ
     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
>>> print(qc.decompose().decompose())
     
q_0: 
     
q_1: 
     
>>> qk.transpile(qc, basis_gates=['u', 'cx'], translation_method='translator').draw()

q_0: 
     
q_1: 
     
>>> qk.transpile(qc, basis_gates=['u', 'cx'], translation_method='unroller').draw()
    
q_0: 
     
q_1: 
     

it looks like Isometry no longer generates Ids on some of the qubits (which was weird, but not necessarily a bug). If I try to reproduce the original substitute_node_with_dag issue:

>>> qc = qk.QuantumCircuit(2)
>>> qc.x(0)

>>> qc2 = qk.QuantumCircuit(2)
>>> qc2.append(qc.to_gate(), [0,1])
>>> qc2.draw()
     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
q_0: ─0              β”œ
     β”‚  circuit-2642 β”‚
q_1: ─1              β”œ
     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
>>> qc2.decompose().draw()
     β”Œβ”€β”€β”€β”
q_0: ─ X β”œ
     β””β”€β”€β”€β”˜
q_1: ─────
          
>>> qk.transpile(qc, basis_gates=['u', 'cx'], translation_method='translator').draw()
     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
q_0: ─ U(Ο€,0,Ο€) β”œ
     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
q_1: ────────────
                 
>>> qk.transpile(qc, basis_gates=['u', 'cx'], translation_method='unroller').draw()
     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
q_0: ─ U(Ο€,0,Ο€) β”œ
     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
q_1: ────────────
                 

things behave as expected, so I think this can be closed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Quantum Circuits for Sparse Isometries - arXiv
The main idea behind the decomposition there is to use pivoting gates, which permute the entries of the state such that the non-zero...
Read more >
Quantum circuits for isometries - White Rose Research Online
lower bound on the number of C-not gates required to decompose an arbitrary isometry from m to n qubits, and give three explicit...
Read more >
Machine Learning For Decomposing Arbitrary Unitary ...
There is something called Isometries [2] where we can decompose any unitary circuit using CNOTs and single-qubit gates.
Read more >
Quasiprobability decompositions with reduced sampling ...
However, this decomposition set does not necessarily produce the optimal ... This corresponds to simulating an ideal quantum gate U usingΒ ...
Read more >
Quantum Circuits for Isometries
Every quantum gate can be decomposed into a sequence of ... number of C-not gates required to decompose an isometry for arbitrary m...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found