量程开发工具包 Toffoli 模拟器Quantum Development Kit Toffoli Simulator

量程开发工具包提供了一个 Toffoli 模拟器,它是一种特殊用途的模拟器,可以模拟限制为 X、CNOT-CONTAINS 和多受控 X 量程操作的量程算法(所有传统逻辑和计算都可用)。The Quantum Development Kit provides a Toffoli simulator, which is a special-purpose simulator that can simulate quantum algorithms that are limited to X, CNOT, and multi-controlled X quantum operations (all classical logic and computations are available).

尽管 Toffoli 模拟器比完整状态模拟器的操作受到限制更多,但它可以模拟更多 qubits。While the Toffoli simulator is much more restricted in operation than the full state simulator, it can simulate far more qubits. Toffoli 模拟器可用于数百万 qubits,而完整状态模拟器一般限制为大约30。The Toffoli simulator can be used with millions of qubits, while the full state simulator is generally limited to about 30. 它可以执行和调试在计算机上用 Q # 编写的有限的一组量程算法;例如,可以使用这些入口来实现计算布尔函数的 oracles,因此在上经过测试的可以使用此模拟器改变大量 qubits。It can execute and debug a limited set of quantum algorithms written in Q# on your computer; for instance, oracles that evaluate Boolean functions can be implemented using these gates and so tested on vary large numbers of qubits using this simulator.

此量程模拟器通过 ToffoliSimulator 类公开。This quantum simulator is exposed via the ToffoliSimulator class. 若要使用模拟器,只需创建此类的一个实例,并将其传递给要执行的量程操作的 Run 方法,同时执行其余的参数:To use the simulator, simply create an instance of this class and pass it to the Run method of the quantum operation you want to execute along with the rest of the parameters:

    var sim = new ToffoliSimulator();
    var res = myOperation.Run(sim).Result;
    ///...

其他操作Other Operations

当结果操作等于 X 或标识时,ToffoliSimulator 支持旋转和指数化 Paulis,如 RExpThe ToffoliSimulator supports rotations and exponentiated Paulis, such as R and Exp, when the resulting operation is equal to X or to the identity.

支持度量和断言,但仅在 Pauli ZMeasurement and assert are supported, but only in the Pauli Z basis. 请注意,某些度量值的概率始终为0或 1;Toffoli 模拟器中没有随机性。Note that the probability of some measurement is always either 0 or 1; there is no randomness in the Toffoli simulator.

支持 DumpMachineDumpRegisterDumpMachine and DumpRegister are supported. 它们都输出每个 qubit 的当前 Z的状态,每行一个 qubit。They both output the current Z-basis state of each qubit, one qubit per line.

QubitCountQubitCount

默认情况下,ToffoliSimulator 为 65536 qubits 分配空间。By default, the ToffoliSimulator allocates space for 65,536 qubits. 如果你的算法需要超过此值,则可以通过向构造函数提供 qubitCount 参数的值来更改 qubit 计数。If your algorithm requires more than this, you can change the qubit count by providing a value for the qubitCount parameter to the constructor. 每个额外的 qubit 都需要额外的内存字节,因此,估计过高所需的 qubits 数量不会产生很大的代价。Each additional qubit requires an additional byte of memory, so there is no significant cost to overestimating the number of qubits you'll need.

例如:For example:

    var sim = new ToffoliSimulator(qubitCount: 1000000);
    var res = myLargeOperation.Run(sim).Result;