Skip to content

Feat/add cr and cz macros#14

Open
paulQM wants to merge 47 commits intomainfrom
feat/add-cr-cz-macros
Open

Feat/add cr and cz macros#14
paulQM wants to merge 47 commits intomainfrom
feat/add-cr-cz-macros

Conversation

@paulQM
Copy link
Copy Markdown
Contributor

@paulQM paulQM commented Sep 18, 2025

Implements macros for CR and CZ gates on transmons (both flux tunable and fixed with fixed and tunable couplers)

Contains also fixes:

  • Different formula for calculating blob distances in gef readout. Old formula did not work.
  • Fix bug where if machine.set_all_fluxes got a qubit_pair, it would try call on the z line, not the coupler line.

from quam.components.pulses import Pulse, ReadoutPulse
from quam.core import quam_dataclass
from quam.utils.qua_types import QuaVariableBool, QuaVariableFloat, QuaVariableInt

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is there a reason for not using the framework that the IQCC team is using?
Especially with

@quam_dataclass
class TwoQubitGate(QuamComponent, ABC):
    
    extras: Dict[str, Any] = field(default_factory=dict)
    
    @property
    def transmon_pair(self):
        from ..transmon_pair import TransmonPair

        if isinstance(self.parent, TransmonPair):
            return self.parent
        elif hasattr(self.parent, "parent") and isinstance(self.parent.parent, TransmonPair):
            return self.parent.parent
        else:
            raise AttributeError("TwoQubitGate is not attached to a QubitPair. 2Q_gate: {self}")

    @property
    def qubit_control(self):
        return self.transmon_pair.qubit_control

    @property
    def qubit_target(self):
        return self.transmon_pair.qubit_target
    
    @property
    def coupler(self):
        return self.transmon_pair.coupler    

    def __call__(self):
        self.execute()


@quam_dataclass
class CZGate(TwoQubitGate):
    """CZ Operation for a qubit pair"""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The implementation here seems to be more general and can be attached to any qubit type. Any recommendation for when to extend the class and when to use macro?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In terms of consistency with the other custom_gates, cross_resonance is also implemented as macro. We could refactor this, but what is your current thought? My thought right now is that macro works because the implementation depends on what user have and can choose which appropriate gate to attached rather than being pre-defined.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I recently discussed it with @nulinspiratie and his advice is to use the Gate macros for 1 and 2 qubit gates and keep using the standard methods for other functions such as reset, readout...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@TheoLaudatQM I'd prefer consistency and open for changes. Here the class inherits quam.components.macro.QubitPairMacro. The IQCC implementation inherits TwoQubitGate(QuamComponent, ABC). Which approach should we take here? @nulinspiratie

@TheoLaudatQM TheoLaudatQM requested a review from soonqm September 26, 2025 07:01
qua_T = QuaVariable | QuaExpression


@quam_dataclass
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The apply method in this class seems too big. I would recommend splitting it up into several methods. For example, each cr_type should be its own method or function. Also, I would expect that many of the parameters in apply are actually gate parameters similar to zz_correction_phase

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@nulinspiratie Refactored the macro and decomposed them to methods. There are many parameters but many of them are for the operations (pulses) of involved elements. Is there a better way to manage these?

The location of the file was moved to: custom_gates/fixed_transmon_pair/two_qubit_gates.py following the changes in the flux tunable one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants