玻色量子Kaiwu怎么在anaconda里面进行安装?

Akkio
2025-01-09 10:50:18
人工智能
技术教程
本帖最后由 Akkio 于 2025-1-23 11:08 编辑


本文将详细讲解怎么在anaconda里面安装一下玻色量子库。


安装anaconda这个请自行解决。


首先请去官网打开这个链接:https://platform.qboson.com/sdkDownload


第一步:下载这个文件到这个路径:C:\Users\LENOVO\kaiwu


就是要放在anaconda里面。然后在官网上下载这个:kaiwu-1.0.3-py3-none-any.whl





点击windows1.1.0这个按钮。接下来旁边有一个SDK授权码。注意一下到期时间,然后后面跑代码就复制粘贴就好。


第二步:打开anaconda prompt


核心思路是创造一个python环境为3.8的新环境。接下来我会告诉你们命令:


conda create --name myenv python=3.8

接下来是:


conda activate myenv

注意一下:myenv这个是你取的名字,是什么没影响。


source activate myenv

(这段代码是macOS/Linux下才会用的,windows玩家请跳过)


第三步:安装Kaiwu库。


cd C:\Users\LENOVO\kaiwu

这个是Kaiwu的路径。


pip install kaiwu-1.0.3-py3-none-any.whl

接下来安装就行。这里提示一下,因为Kaiwu这边会夹带一些常用库,所以新环境是不用担心这个numpy和pandas没有的,会自动安装。


第四步:总结一下就是让你创造的新环境在anaconda里面有选项。


conda env list

查一下环境。


conda activate myenv
conda install jupyter

conda install ipykernel

python -m ipykernel install --user --name=myenv --display-name="Python (myenv)"

弄好之后重新打开一下anaconda,再去跑一下代码就好。


import numpy as np
import kaiwu as kw
import pandas as pd
# Define the input adjacency matrix for the graph
adj_matrix = np.array([               
                          [0, 1, 0, 1, 1, 0, 0, 1, 1, 0],               
                          [1, 0, 1, 0, 0, 1, 1, 1, 0, 0],               
                          [0, 1, 0, 1, 1, 0, 0, 0, 1, 0],               
                          [1, 0, 1, 0, 0, 1, 1, 0 ,1, 0],               
                          [1, 0, 1, 0, 0, 1, 0, 1, 0, 1],               
                          [0, 1, 0, 1, 1, 0, 0, 0, 1, 1],               
                          [0, 1, 0, 1, 0, 0, 0, 0, 0, 1],               
                          [1, 1, 0, 0, 1, 0, 0, 0, 1, 0],               
                          [1, 0, 1, 1, 0, 1, 0, 1, 0, 1],               
                          [0, 0, 0, 0, 1, 1, 1, 0, 1, 0]])
# Get the number of nodes in the graph
num_nodes = len(adj_matrix)
# Create a QUBO variable array 'x' with 'num_nodes' variables
# each representing a node in the graph
x = kw.qubo.ndarray(num_nodes,'x',kw.qubo.Binary)
# Define the objective function for the QUBO model of Max cut problem
obj = -x.T @ adj_matrix @ (1-x)
# parse QUBO
obj = kw.qubo.make(obj)
# Extract the QUBO matrix and store it in a pandas DataFrame
qubo_matrix = kw.qubo.qubo_model_to_qubo_matrix(obj)['qubo_matrix']
# Check whether the QUBO matrix satisfy the precision requirement
kw.qubo.check_qubo_matrix_bit_width(qubo_matrix)
# Save the QUBO matrix to a CSV file without including index or header
df = pd.DataFrame(qubo_matrix)
csv_file_path = 'qubo_matrix.csv'
#这个路径你们可以改一下,这样你们就可以在指定路径看到文件了
df.to_csv(csv_file_path,index=False,header=False)

接下来是解释一下授权码:


import kaiwu as kw
kw.license.init(user_id="", sdk_code="")

请换成你们自己的授权码。


小结:玻色量子安装起来不难,有两个点需要注意一下:


第一,需要保证python版本在3.8以上。


python --version

一般base会低一点。


第二,就是注意whl文件路径问题,不要错了。


第三,注意要在anaconda的new的下拉菜单中确保正常显示这个环境,确保下次打开是有的。


好啦,本次分享就到这里,欢迎使用玻色量子。


本文转载自微信公众号:师苑数模





1202
0
0
0
关于作者
相关文章
  • AI 逆向设计复合材料新突破:VAE-CDGM + 贝叶斯优化,精准生成高 ...
    同济大学团队在《Computer Modeling in Engineering & Sciences》2026 年 146 卷发表该研究,提 ...
    了解详情 
  • 综述:多尺度模拟与机器学习在高熵合金研究中的当前应用现状 ...
    上海交通大学与武汉理工大学团队在《Journal of Materials Research and Technology》2023 年 26 ...
    了解详情 
  • 物理学家用扩散模型(四):Score Matching + 加噪=NCSN ...
    上一篇:物理学家用扩散模型(三):反向SDE从噪声生成目标分布3.5 Score Matching3.5.1 Fisher ...
    了解详情 
  • 物理学家用扩散模型(三):反向SDE从噪声生成目标分布 ...
    上一篇:物理学家用扩散模型(二):随机量子化+Score函数=扩散模型3.3 正向与反向扩散的数学基 ...
    了解详情 
  • 物理学家用扩散模型(二):随机量子化+Score函数=扩散模型 ...
    本文衔接生成式模型基础,聚焦随机量子化与扩散模型的核心关联及机制。随机量子化通过引入虚构时 ...
    了解详情 
领取成功
本月5个550bit真机配额已发放给您,配额将在2个月后到期,请及时使用哦~
活动中心
联系我们
二维码
返回顶部
返回
活动中心

完成任务,轻松获取真机配额

×
每日必做
新手任务
长期任务
其他任务
快速回复 返回顶部 返回列表
玻色有奖小调研
填写问卷,将免费赠送您1个1000bit真机配额
(单选) 您是从哪个渠道得知我们的?*
您是从哪个社交媒体得知我们的?*
您是通过哪个学校的校园宣讲得知我们的呢?
取消

提交成功

真机配额已发放到您的账户,可前往【云平台】查看

量子AI开发者认证

考核目标

开发者能够成功搭建Kaiwu-PyTorch-Plugin项目基础环境,并成功运行示例代码,根据示例提示,输出指定的值并填写至相应的输入框中。

通过奖励

5个一年效期的1000量子比特真机配额

专属「量子AI开发者」社区认证标识

开发者权益

每月固定权益:5个550量子比特真机配额
前往考核

第一步

按照README提示成功安装Kaiwu-PyTorch-Plugin库环境依赖
前往GitHub

第二步

运行 community-assessment 分支下的 run_rbm.py 代码示例

第三步

理解示例代码,手动打印并填写如下数值:

正相采样的状态

负相采样的状态

正相的能量值

负相的能量值

*

提交答案

开发者权益

每月固定权益:5个550量子比特的真机配额

恭喜您完成考核

您将获得量子AI开发者认证标识及考核奖励

1000 bit*5

配额

Quantum AI Developer Certification

Assessment Objectives

Developers should successfully set up the basic environment for the Kaiwu-PyTorch-Plugin project, run the QBM-VAE sample code, and calculate the correct FID value based on the random seed value provided by the system.

Pass Rewards

10 quotas for 550-qubit real quantum machines with a one-year validity period

Exclusive "Quantum AI Developer" Community Certification Badge

Developer Benefits

Fixed Monthly Benefits: 5 quotas for 550-qubit real quantum machines
Proceed to Assessment

Step 1

Install the environment dependencies for the Kaiwu-PyTorch-Plugin library according to the README instructions
Go to GitHub

Step 2

Replace the Seed Value

Your seed value is

Step 3

Enter the FID Value You Calculated

*

Submit Answer

Developer Benefits

Fixed Monthly Benefits: 5 quotas of 550-qubit real machines

Congratulations on Completing the Assessment

You will receive the Quantum AI Developer Certification Badge and Assessment Rewards

550bit*10

Quotas