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

Is there a way to access the energy for solution states to create a graph of how the energy converges to minima? #489

Open
wilhelmagren opened this issue Mar 10, 2023 · 3 comments

Comments

@wilhelmagren
Copy link

Current Problem

We have a direct need to be able to plot how the energy of the states converges to local minima (ground-state of Ising Hamiltonian for which the CQM is constructed from) when using the LeapHybridCQMSampler.

Perhaps this is not possible due to how the hybrid solvers work. And if that's the case, is there anywhere I could read exactly how the hybrid solvers work so I know why we can't access the energies? Perhaps it's not at all an iterative solving process, and then of course, this would not be possible.

Additional context

Context: when solving the optimization problem with VQE using qiskit SDK we can define a callback for the solver. In this callback we are able to store the average energy for the states for each iteration of optimization. Is there any way to do something similar when solving on a Leap Hybrid Solver?

Closing words

I would be very appreciative if anyone could look at this and see whether or not this would be possible to do. Otherwise, please refer me to a place where this has been done already, or, refer me to an explanation as to why its not possible :)

Regards,

@wilhelmagren
Copy link
Author

I can fill in with some more context if that helps.

For the qiskit VQE we define a log function in this way

from dataclasses import dataclass

@dataclass
class VQELog:
    values: list
    parameters: list
    def update(self, count, parameters, mean, _metadata):
        self.values.append(mean)
        self.parameters.append(parameters)
        print(f'Running circuit {count}', end='\r', flush=True)
        
log = VQELog([], [])

and then use the update method of the dataclass as a callback.

with Session(service=service, backend=backend) as session:
    vqe = SamplingVQE(
        sampler=Sampler(session=session),
        ansatz=ansatz,
        optimizer=optimizer,
        callback=log.update,
    )
    solver = MinimumEigenOptimizer(vqe)
    qc_result = solver.solve(qubo)

Is there any similar way you could define a callback when using the LeapHybridCQMSampler to store intermediate solution energies? Would appreciate any feedback on this :)

Regards,

@arcondello
Copy link
Member

Hi @willeagren , unfortunately we don't return the burndowns from the hybrid solver - the only information we return is the amount of runtime and the amount of qpu access time.
dwave-hybrid does provide open source hybrid solvers and hybrid solver construction tools if you want to see more details. Be aware however that the CQM solver is not re-implemented in dwave-hybrid at this time unfortunately.

@wilhelmagren
Copy link
Author

Hi @arcondello, thanks for the reply. Do you know if it would be possible if we instead were using a BQM to sample from? I can't find anything concrete on the repo you linked that would do this.

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

2 participants