Applying sigmoid to Hamiltonian

Hi!

I read in a paper that certain optimization schemes can be improved by applying a sigmoid transformation to the cost Hamiltonian of the system

Skärmbild 2025-01-31 105437

where H_c is the cost Hamiltonian and E_\tau is the energy expectation value at the current optimization step, whereas \sigma_0 and \sigma_T are scalar values which are not important for the purpose of my question. In this specific case, the cost Hamiltonian H_c is a sum of Pauli-Z strings, and is thus diagonal in the computational basis. The idea is that applying the sigmoid “stretches” the energy spectrum around the current energy of the system in a way that can be beneficial for optimization problems where the goal is to find the ground state of H_c.

I would like to try out this idea in my own simulations, but I am not sure how to implement the transformation efficiently. The goal is that at each optimization step in a VQE, I want to calculate the gradient and optimize the parameters of my ansatz \psi(\bar{\theta}) with respect to \langle f(H_C) \rangle, rather than the original Hamiltonian \langle H_c \rangle. How can I incorporate this feature into a Pennylane optimization framework? Exactly calculating the eigenvalues of the Hamiltonian is not an option, since that would defeat the purpose of trying to efficiently solve the optimization problem.

For those interested, the paper is found here.

Hi @erima , welcome to the Forum!

You could potentially implement a cost function that applies the sigmoid transformation, and use that in your optimization step.

For example, if you look at PennyLane’s demo on VQE, you’ll see that it follows the following structure:

  1. Build the Hamiltonian
  2. Build a QNode
  3. Build a cost function that takes only the parameters you want to optimize
  4. Build an optimization routine that finds the gradients of the cost function

For what you want to do you could modify the cost function such that it doesn’t simply return the value of the circuit, but instead the value of the circuit after the transformation.

Here’s some pseudocode as an example:

def sigmoid(Hc,E_T):
    # Write the function for the sigmoid transformation
    return result

# Write a cost function that depends on the parameters you want to optimize
def cost_fn(params):
    # Calculate the output of your circuit
    E_T = circuit(params, wires=range(qubits))
    # Calculate the sigmoid
    cost = sigmoid(Hc,E_T)
    # Return the cost
    return cost

I’m not sure that this will work but it’s something you could try.

I hope this helps!