Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FidelityquantumKernel with aerSimulator in statevector mode and gpu #211

Open
luib01 opened this issue Nov 19, 2024 · 0 comments
Open

FidelityquantumKernel with aerSimulator in statevector mode and gpu #211

luib01 opened this issue Nov 19, 2024 · 0 comments

Comments

@luib01
Copy link

luib01 commented Nov 19, 2024

What should we add?

backend=AerSimulator(method='statevector', device='GPU',blocking_enable=True)

    self.composed_circuit=self.qcircuit.compose(self.feature_map,inplace=False)
    print('Quantum Circuit:')
    print(self.qcircuit)
    print('FEATURE MAP:')
    print(self.composed_circuit)
    #self.composed_circuit=insert_noise(self.composed_circuit,noise_model=noise_model)
    transpiler= generate_preset_pass_manager(backend=backend, optimization_level=3)
    #self.composed_circuit=transpile(circuits=self.composed_circuit,backend=AerSimulator(method='statevector',noise_model=noise_model,device='GPU'),optimization_level=3)
        

        # Create a quantum kernel based on the transpiled feature map
        #Set Primitive sampler
    sampler = qiskit_ibm_runtime.Sampler(backend)
    #sampler.options.default_shots = 100
    print("Noise model inserted form: "+backend.name)
        #self.job=self.backend.run(transpiled)
        #sampler=Sampler(self.backend)
    fidelity=ComputeUncompute(num_virtual_qubits=self.num_qubits,sampler=sampler,pass_manager=transpiler)
    
    kernel=FidelityQuantumKernel(feature_map=self.composed_circuit,fidelity=fidelity,max_circuits_per_job=200)

I have the following error File ~/Progetto/qiskit_machine_learning/kernels/fidelity_quantum_kernel.py:256, in FidelityQuantumKernel._get_kernel_entries(self, left_parameters, right_parameters)
249 job = self._fidelity.run(
250 [self._feature_map] * (end_idx - start_idx),
251 [self._feature_map] * (end_idx - start_idx),
252 chunk_left_parameters, # type: ignore[arg-type]
253 chunk_right_parameters, # type: ignore[arg-type]
254 )
255 # Extend the kernel_entries list with the results from this chunk
--> 256 kernel_entries.extend(job.result().fidelities)
257 return kernel_entries

File ~/.conda/envs/cnr/lib/python3.10/site-packages/qiskit/primitives/primitive_job.py:51, in PrimitiveJob.result(self)
49 def result(self) -> ResultT:
50 self._check_submitted()
---> 51 return self._future.result()

File ~/.conda/envs/cnr/lib/python3.10/concurrent/futures/_base.py:458, in Future.result(self, timeout)
456 raise CancelledError()
457 elif self._state == FINISHED:
--> 458 return self.__get_result()
459 else:
460 raise TimeoutError()

File ~/.conda/envs/cnr/lib/python3.10/concurrent/futures/_base.py:403, in Future.__get_result(self)
401 if self._exception:
402 try:
--> 403 raise self._exception
404 finally:
405 # Break a reference cycle with the exception in self._exception
406 self = None

File ~/.conda/envs/cnr/lib/python3.10/concurrent/futures/thread.py:58, in _WorkItem.run(self)
55 return
57 try:
---> 58 result = self.fn(*self.args, **self.kwargs)
59 except BaseException as exc:
60 self.future.set_exception(exc)

File ~/Progetto/qiskit_machine_learning/state_fidelities/compute_uncompute.py:228, in ComputeUncompute._call(job, circuits, local, local_opts, _sampler, _post_process_v2, num_virtual_qubits)
226 result = job.result()
227 except Exception as exc:
--> 228 raise AlgorithmError("Sampler job failed!") from exc
230 if isinstance(_sampler, BaseSamplerV1):
231 quasi_dists = result.quasi_dists

AlgorithmError: 'Sampler job failed!'

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

No branches or pull requests

1 participant