QNGOptimizer not working in Keeping expectations low challenge

I was trying the Keeping expectations low challenge, when I use QNGOptimizer it shows an error.

Failure message: Runtime Error: Failed to execute run() function: Singular matrix.

Below is the code I used in optimize_circuit. Copy paste this in optimize_circuit to reproduce the error.

    dev = qml.device("default.qubit", range(WIRES))

    circuit = qml.QNode(variational_circuit, dev)

    # Write your code to minimize the circuit
    optimizer = qml.QNGOptimizer()
    update_params = params
    max_iter = 200

    for i in range(max_iter):
        [update_params, _], prev_cost  = optimizer.step_and_cost(circuit, update_params, hamiltonian)
        if i % 10 == 0:
            print(f"Cost : {prev_cost}")
            
    return circuit(update_params, hamiltonian)

But the above code works fine when I use qml.AdamOptimizer().
Am I using the qml.QNGOptimizer wrong ?

Hey @Tarun_Kumar!

The QNGO optimizer is a little complicated and not applicable to the task at hand :sweat_smile:. Definitely go read the paper (Quantum Natural Gradient – Quantum) to see how it works!