コード例 #1
0
    def build_super_layers(self):
        super_layers_all = tq.QuantumModuleList()

        for k in range(self.arch['n_blocks']):
            super_layers_all.append(
                tq.Super1QLayer(op=tq.RX,
                                n_wires=self.n_wires,
                                has_params=True,
                                trainable=True))
            super_layers_all.append(
                tq.Super1QLayer(op=tq.S, n_wires=self.n_wires))
            super_layers_all.append(
                tq.Super2QAllLayer(op=tq.CNOT,
                                   n_wires=self.n_wires,
                                   jump=1,
                                   circular=True))

            super_layers_all.append(
                tq.Super1QLayer(op=tq.RY,
                                n_wires=self.n_wires,
                                has_params=True,
                                trainable=True))
            super_layers_all.append(
                tq.Super1QLayer(op=tq.T, n_wires=self.n_wires))
            super_layers_all.append(
                tq.Super2QAllLayer(op=tq.SWAP,
                                   n_wires=self.n_wires,
                                   jump=1,
                                   circular=True))

            super_layers_all.append(
                tq.Super1QLayer(op=tq.RZ,
                                n_wires=self.n_wires,
                                has_params=True,
                                trainable=True))
            super_layers_all.append(
                tq.Super1QLayer(op=tq.T, n_wires=self.n_wires))
            super_layers_all.append(
                tq.Super2QAllLayer(op=tq.SSWAP,
                                   n_wires=self.n_wires,
                                   jump=1,
                                   circular=True))

            super_layers_all.append(
                tq.Super1QLayer(op=tq.U1,
                                n_wires=self.n_wires,
                                has_params=True,
                                trainable=True))
            super_layers_all.append(
                tq.Super2QAllLayer(op=tq.CU3,
                                   n_wires=self.n_wires,
                                   has_params=True,
                                   trainable=True,
                                   jump=1,
                                   circular=True))

        return super_layers_all
コード例 #2
0
        def __init__(self, n_wires, arch):
            super().__init__()
            self.n_wires = n_wires
            self.arch = arch

            self.super_layers_all = tq.QuantumModuleList()
            self.n_blocks = arch['n_blocks']
            self.n_layers_per_block = arch['n_layers_per_block']
            self.n_front_share_blocks = arch['n_front_share_blocks']

            for k in range(self.n_blocks):
                self.super_layers_all.append(
                    tq.Super1QLayer(op=tq.RX,
                                    n_wires=self.n_wires,
                                    has_params=True,
                                    trainable=True))
                self.super_layers_all.append(
                    tq.Super1QLayer(op=tq.RY,
                                    n_wires=self.n_wires,
                                    has_params=True,
                                    trainable=True))
                self.super_layers_all.append(
                    tq.Super1QLayer(op=tq.RZ,
                                    n_wires=self.n_wires,
                                    has_params=True,
                                    trainable=True))
                self.super_layers_all.append(
                    tq.Super2QAllLayer(op=tq.CRX,
                                       n_wires=self.n_wires,
                                       has_params=True,
                                       trainable=True,
                                       jump=1,
                                       circular=True))
                self.super_layers_all.append(
                    tq.Super2QAllLayer(op=tq.CRY,
                                       n_wires=self.n_wires,
                                       has_params=True,
                                       trainable=True,
                                       jump=1,
                                       circular=True))
                self.super_layers_all.append(
                    tq.Super2QAllLayer(op=tq.CRZ,
                                       n_wires=self.n_wires,
                                       has_params=True,
                                       trainable=True,
                                       jump=1,
                                       circular=True))
            self.sample_n_blocks = None