Esempio n. 1
0
    def submit(self, qlm_batch):
        """
        Submits a QLM batch of jobs and returns the corresponding QiskitJob.

        Args:
            qlm_batch: :class:`~qat.core.Batch` or :class:`~qat.core.Job`.
                    If a single job is provided, a batch is created
                    from this job.
        Returns:
            :class:`~qat.interop.qiskit.QiskitJob` object with the same
            interface as a job derived from JobV1 for the user to have
            information on their job execution
        """
        if self.backend is None:
            raise ValueError("Backend cannot be None")

        if isinstance(qlm_batch, Job):
            qlm_batch = Batch(jobs=[qlm_batch])
        qiskit_circuits = []
        for qlm_job in qlm_batch.jobs:
            qiskit_circuit = job_to_qiskit_circuit(qlm_job)
            qiskit_circuits.append(qiskit_circuit)
        async_job = execute(qiskit_circuits,
                            self.backend,
                            shots=qlm_batch.jobs[0].nbshots
                            or self.backend.configuration().max_shots,
                            coupling_map=None)
        return QiskitJob(qlm_batch, async_job,
                         self.backend.configuration().max_shots)
Esempio n. 2
0
    def _submit_batch(self, qlm_batch):
        """
        Submits a Batch object to execute on a Qiskit backend.

        Args:
            qlm_batch:

        Returns:
            A QLM BatchResult object
        """
        if self.backend is None:
            raise ValueError("Backend cannot be None")

        if isinstance(qlm_batch, Job):
            qlm_batch = Batch(jobs=[qlm_batch])
        qiskit_circuits = []
        for qlm_job in qlm_batch.jobs:
            qiskit_circuit = job_to_qiskit_circuit(qlm_job)
            qiskit_circuits.append(qiskit_circuit)
        qiskit_result = execute(
            qiskit_circuits,
            self.backend,
            shots=qlm_batch.jobs[0].nbshots
            or self.backend.configuration().max_shots,
            coupling_map=None,
            optimization_level=self.optimization_level).result()
        results = generate_qlm_list_results(qiskit_result)
        new_results = []
        for result in results:
            new_results.append(WResult.from_thrift(result))
        return _wrap_results(qlm_batch, new_results,
                             self.backend.configuration().max_shots)
Esempio n. 3
0
    def submit_job(self, qlm_job):
        """
        Submits a Job to execute on a Qiskit backend.

        Args:
            qlm_job: :class:`~qat.core.Job` object

        Returns:
            :class:`~qat.core.wrappers.result.Result` object
        """
        if self.backend is None:
            raise ValueError("Backend cannot be None")

        qiskit_circuit = job_to_qiskit_circuit(qlm_job)
        qiskit_result = execute(qiskit_circuit, self.backend,
                                shots=qlm_job.nbshots,
                                coupling_map=None).result()
        result = generate_qlm_result(qiskit_result)
        return result
Esempio n. 4
0
    def submit_job(self, qlm_job):
        """
        Submits a QLM job to be executed on the previously
        selected backend, if no backends are chosen an exception is raised.

        Args:
            qlm_job: :class:`~qat.core.Job` object to be executed

        Returns:
            A :class:`~qat.interop.qiskit.providers.QiskitJob` object with the same
            interface as a job derived from BaseJob for the user to have
            information on their job execution
        """
        if self.backend is None:
            raise ValueError("Backend cannot be None")

        qiskit_circuit = job_to_qiskit_circuit(qlm_job)
        async_job = execute(qiskit_circuit, self.backend,
                            shots=qlm_job.nbshots, coupling_map=None)
        return QiskitJob(qlm_job, async_job)