你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

浏览 Azure Quantum 网站

在 Azure Quantum 网站上的 Azure Quantum 中借助 Copilot 开始量子计算,发现最新的量子突破,并创建和运行量子程序。

Azure Quantum 网站功能:

  • Azure Quantum 中的 Copilot - AI 与量子世界相遇。 Azure Quantum 中的 Copilot 是一种生成 AI 助手,可帮助你学习和探索量子计算。
  • Azure Quantum 中的代码 - 使用内置代码窗口和编译器直接在浏览器中浏览和运行 Q# 代码,并将作业提交到内存中模拟器或免费的 Quantinuum H 系列模拟器。 使用 Azure Quantum 中的 Copilot 解释 Q# 代码,并从提示生成代码。
  • 量子元素 - 量子计算最重要的应用之一将是化学领域。 目前为个人预览版,Quantum Elements 使用 Azure Quantum 中的 Copilot 来设计、编码和呈现分子模型。
  • Quantum Katas - 讲授量子计算概念和编程语言的 Q# 动手教程。 有关详细信息,请参阅使用 Quantum Katas 学习Q#
  • 代码示例 - Azure Quantum 代码库是一组丰富的示例,使用 Q#、Python 和 Qiskit 代码演示量子方案。
  • 量子概念 - 从量子理论的基础知识到量子计算的高级技术,概念库是一门速成课程,可让你快速掌握量子计算。
  • 视频 - 浏览视频库,采访领先的量子计算研究人员和创新者。
  • Azure Quantum 博客 - 随时了解最新的量子计算研究和创新。

只需使用 Microsoft (MSA) 电子邮件帐户即可开始探索 Azure Quantum。 可以在 上 https://account.microsoft.com/免费创建 MSA。

运行 Q# 程序

若要开始探索 Azure Quantum 中的 Copilot 和编码,请使用“ 量子样本 ”下拉列表中的一个示例。

  1. 导航到使用任何 Microsoft (MSA) 帐户 的 Azure Quantum 中的代码

  2. 选择“ 量子样本 ”,然后选择“ 随机数生成器”。 以下代码将复制到代码窗口。

    /// # Sample
    /// Quantum Random Number Generator
    ///
    /// # Description
    /// This program implements a quantum ranndom number generator by setting qubits
    /// in superposition and then using the measurement results as random bits.
    namespace Sample {
        open Microsoft.Quantum.Measurement;
        open Microsoft.Quantum.Intrinsic;
    
        @EntryPoint()
        operation Main() : Result[] {
            // Generate 5-bit random number.
            let nBits = 5;
            return GenerateNRandomBits(nBits);
        }
    
        /// # Summary
        /// Generates N random bits.
        operation GenerateNRandomBits(nBits : Int) : Result[] {
            // Allocate N qubits.
            use register = Qubit[nBits];
    
            // Set the qubits into superposition of 0 and 1 using the Hadamard
            // operation `H`.
            for qubit in register {
                H(qubit);
            }
    
            // At this point each has 50% chance of being measured in the |0〉 state
            // and 50% chance of being measured in the |1〉 state.
            // Measure each qubit and reset them all so they can be safely
            // deallocated.
            let results = MeasureEachZ(register);
            ResetAll(register);
            return results;
        }
    }
    
  3. 选择“ 内存中模拟器”。

  4. 选择“运行”。

  • 结果显示在“ 结果 ”字段中,结果的直方图显示在代码窗口下方。
  • 可以移动 “选择拍摄次数”的 滑块,以指定程序的运行次数。
  • 拍摄” 字段显示每个镜头的结果。

若要使用其他模拟器再次运行程序,请执行以下操作:

  1. 选择 “内存中模拟器 ”下拉列表,然后选择“ Quantinuum H 系列模拟器”。
  2. 选择当前限制为 20) (拍摄数,然后选择 “运行”。
  • 作业状态显示在代码窗口顶部。
  • 结果的直方图显示在代码窗口下方。 目前,Quantinuum H 系列仿真器不提供每次拍摄的结果。

提示 Copilot

  • 在代码窗口中,选择“ 说明代码 ”,提示 Azure Quantum 中的 Copilot 生成代码示例分析。

可以在 Azure Quantum 中提示 Copilot 获取与量子相关的几乎所有内容,例如:

  • “说明 MResetZ 操作”
  • “编写 Q# 纠缠两个量子比特的代码”
  • “解释量子干扰”

在 VS Code for the Web 上打开代码示例

若要进一步浏览示例代码,只需单击一下即可在 VS Code for the Web 中打开代码,并利用改进的错误消息、 Q# 语法突出显示和集成调试等功能。 如果已设置 Azure 帐户,可以从 VS Code 直接连接到 Azure Quantum 工作区。

若要在 VS Code for the Web 中打开代码,

  1. 选择代码窗口底部的 VS Code 图标。

    用于启动 VS Code 的图标的屏幕截图。

后续步骤

还可以使用 Azure 门户 或通过设置本地开发环境来运行量子程序。