When computing the gradients of a quantum neural network using the parameter-shift rule, the cost function needs to be calculated twice for the gradient with respect to a single adjustable parameter of the network. When the total number of parameters is high, the quantum circuit for the computation has to be adjusted and run for many times. Here we propose an approach to compute all the gradients using a single circuit only, with a much reduced circuit depth and less classical registers. We also demonstrate experimentally, on both real quantum hardware and simulator, that our approach has the advantages that the circuit takes a significantly shorter time to compile than the conventional approach, resulting in a speedup on the total runtime.
翻译:在使用参数平移规则计算量子神经网络的梯度时,针对网络中单个可调参数的梯度需要计算两次代价函数。当参数总数较多时,用于计算的量子电路需要多次调整并运行。本文提出一种仅使用单个电路计算所有梯度的方法,该方法可大幅降低电路深度并减少经典寄存器数量。我们还在真实量子硬件和模拟器上进行了实验验证,结果表明:与传统方法相比,本方法编译电路所需时间显著缩短,从而加速了总体运行时间。