Skip to content

GA‐QAS: Full pipeline

Vu Tuan Hai edited this page May 20, 2024 · 1 revision

In the introduction part, we have introduced the function fitnessW, we also know this function will be called at least $n_{circuit} \times n_{generation}$ times, if fitnessW is a heavy function, that requires a lot of time for GA-QAS, then we propose another way.

The old fitnessW:

def fitnessW(qc: qiskit.QuantumCircuit):

    compiler = QuantumStatePreparation(
        u = qc,
        target_state = state.w(3).inverse()
    ).fit(num_steps = 100)
    return 1 - compiler.compiler.metrics['loss_fubini_study'][-1] # Fitness value

can be reduced by decreasing the num_steps:

def reduced_fitnessW(qc: qiskit.QuantumCircuit):

    compiler = QuantumStatePreparation(
        u = qc,
        target_state = state.w(3).inverse()
    ).fit(num_steps = 10)
    return 1 - compiler.compiler.metrics['loss_fubini_study'][-1] # Fitness value

The, pass both reduced_fitnessW and fitnessW into EEnvironement:

from qoop.evolution.environment import EEnvironment
env = EEnvironment(
     metadata = env_metadata,
     fitness_func = [reduced_fitnessW, fitnessW]
)

The function reduced_fitnessW will be called $n_{circuit} \times n_{generation}$ times, when fitnessW is $n_{generation}$ times.