Questions tagged [q#]
Q# (Q-Sharp) is a domain-specific programming language used for expressing quantum algorithms. It is offered as part of the Quantum Development Kit developed by Microsoft.
128
questions
-1
votes
0
answers
35
views
Has anyone had problems installing Q# QDK on VS2022? looks like you need dotnet 4.5 [closed]
I installed VS2022 Community Edition, then installed the Microsoft Quantum Development Kit Extension from the Visual Studio marketplace from within VS. The extension downloaded and the VSIX installer ...
0
votes
2
answers
42
views
Syntax for creating immutable array in Q#
I'm trying to run this example from https://learn.microsoft.com/en-us/azure/quantum/user-guide/language/statements/variabledeclarationsandreassignments.The compiler tells me that syntax for the array ...
-1
votes
1
answer
50
views
Install Quantum Development Kit (QDK) in Ubuntu, without conda
I mean to use QDK in Ubuntu 22.04LTS.
I have a virtualenv, but no conda.
I installed qsharp in my venv with
$ pip3 install qsharp
but then
$ python -c "import qsharp"
IQ# is not installed.
...
0
votes
1
answer
31
views
QS5026 - The variable cannot be reassigned here
I'm following tutorial from the official Microsoft learning page (https://learn.microsoft.com/en-us/azure/quantum/tutorial-qdk-explore-entanglement?pivots=ide-azure-portal) about quantum entanglement.
...
0
votes
0
answers
18
views
Export a quantum circuit in Q#
Is it possible to export a quantum circuit to a .qc or OpenQASM file or to simply print the list of gates?
More specifically I would like to extract a quantum circuit from a ResourcesEstimator.
For ...
0
votes
0
answers
28
views
%debug magic command not working in the Q# Jupyter Notebook environment
As per the documentation provided by Microsoft Azure Quantum at this link , I followed the steps given and installed Q# with Jupyter Notebook, using Anaconda.
I then wrote the following Q# program in ...
0
votes
1
answer
107
views
Get a sequence of numbers in Q#
I would like to get a list of a mathematical sequence in Q#, but I have an error that I can't solve.
I use Azure Quantum to deploy the code in a Notebook.
Here is what I do:
First I connect to Azure ...
1
vote
0
answers
97
views
VS Code installing a specific .NET SDK version
Is there anyway you can get VS Code to install a specific .NET SDK version that you have used in an old application?
I have an old Q# app that uses SDK version 3.1.416 with netcoreapp 3.1 but I don't ...
0
votes
1
answer
483
views
Why Pauli Z can be used to measure a single qubit ?
According to the Q# documentation, a single qubit can be measured by M.The method uses Pauli-Z. But why Pauli Z can be used to measure a single qubit? I have known the matrix of Pauli-Z like below:
...
0
votes
1
answer
44
views
What's the meaning of type 'd in q#
As shown in the picture above. What's the meaning of type 'd? What's type the return value of "Zipped" should be?
0
votes
1
answer
52
views
where can I get the detailed tutorial or document for Q# machine learning
Recently, I'm learning the Q# language for machine learning. The sample of half-moons has been run correctly. Now I want to learn the detail of the code. But there is too little explanation to find. ...
1
vote
1
answer
24
views
Result and IQArray could not be found
I am following this MS tutorial to add functionality to my Q#/C#host project.
However, I get two errors on my operations:
The type or namespace name 'Result' could not be found (are you missing a ...
0
votes
0
answers
29
views
No more terminal output from Q# on both Terminal and VS Code on MacOS
When using the sample QDK code, I do not get any terminal output from within VS Code, nor the Terminal.app.
Screenshot
Here is the Code:
namespace test {
open Microsoft.Quantum.Canon;
open ...
3
votes
1
answer
100
views
Missing types, namespaces, directives, and assembly references
I use VS Code for C# and Unity3D and TypeScript and Angular and Python programming, so I have pretty much every required extension, including the .NET Framework and Core as well as the Quantum ...
0
votes
1
answer
363
views
How to create a new Q# Project in VSCode
I am trying to figure out how to start writing code using Microsoft Q# and QDK, but am running into a lot of issues as there aren't any good documents that help you set up projects from scratch. I ...
1
vote
2
answers
64
views
VS2019 Community Edition Q# Application Hello World Reference problem
I am a Q# Beginner.
Using Visual Studio 2019 Version 16.11.4. Community Edition
Dotnet 5.0.401
Using the Q# Application Template I create a new Q# 'Hello World' Application.
The Packages list ...
1
vote
3
answers
204
views
How do I get Hellow Quantum world to run in Visual Studio 2019
This is my first attempt at Q#. I followed the instructions here: How do I get the missing dependencies? Please see my screen shot
https://learn.microsoft.com/en-us/azure/quantum/install-command-line-...
1
vote
1
answer
122
views
Python calling q# file on IONQ QPU results in error about a System.Text.Json, Version=5.0.0.0 file not being found
Attempting to learn how to call q# from Python code and have it run for real on the IONQ QPU as it does (or appears to do) using VS and >dotnet run of the raw q# code. I followed the guides and ...
0
votes
1
answer
141
views
Cannot create Q# projects
I'm new to quantum computing and I've been trying to follow instructions on https://learn.microsoft.com/en-us/azure/quantum/install-command-line-qdk?tabs=tabid-vscode to dive into this field, but I've ...
0
votes
2
answers
204
views
Return two numbers in Q Sharp (Q#) (Quantum Development Kit)
So, basically, I did the tutorial to create a random number on the website of Microsoft Azure and now I am trying to add some functionalities, including their suggestion add a minimum number.
The ...
1
vote
1
answer
158
views
How could you use Q# within Unity?
I was wondering how one would go about using Q# within Unity. I want to endow agents within a Unity simulation with quantum-like behavior, and I was wondering whether it was possible.
I've seen ...
1
vote
0
answers
223
views
Q# Create new project...' resulted in an error
I'm following these instructions to install Q#
https://learn.microsoft.com/en-us/learn/modules/qsharp-create-first-quantum-development-kit/2-install-quantum-development-kit-code
I have the following ...
1
vote
2
answers
180
views
Why can't I create a Q#create project on VisualStudio Code with QDK || ISSUE :command "'quantum.newProject' failed.)"
help regarding the issue below would be really appreciated :
Command 'Q#: Create new project...' resulted in an error (Running the contributed command: 'quantum.newProject' failed.)
I was trying to ...
0
votes
1
answer
543
views
Q#: Error on dotnet run: System.ComponentModel.Win32Exception (5): Access is denied
I tried to install Q# a few days ago using the instructions listed here, but unfortunately, when I try to run the example program using the command dotnet run, it returns an error. Maybe I just did ...
0
votes
1
answer
92
views
Passing complex objects to Q# operations
I want to pass a complex object to a Q# operation from Python code. I defined the same data structure on both sides: in Python as a class and in Q# as a newtype.
Than I prepared a JSON representation ...
0
votes
2
answers
81
views
Q# : QDK Errors
I've recently tried to install the QDK via the VSCode extension in my Windows 10 Desktop and VSCode wasn't able to find the Microsoft libraries even after I was able to execute the code by the dotnet ...
0
votes
1
answer
54
views
My Q# language server won't stop downloading on VS Code
I'm trying to create a Q# New Project in VS Code, but VS Code won't let me do that until I have my Q# language server downloaded.
I'm using a mac. And the Q# language server just kept downloading for ...
1
vote
1
answer
109
views
How to return measurement probabilities from the QDK Full-state simulator?
Is there a way for the QDK full-state simulator to return the wavefunction or the measurement probabilities of a quantum state? Specifically to a C# host application?
I want to sample from the output ...
0
votes
1
answer
125
views
How to run Microsoft QDK from source
What is the general procedure for building and including QDK source code in a C# host project?
Following Develop with Q# and .NET I have set up a C# host project which references a Q# library on linux....
1
vote
1
answer
75
views
qsharp and python: remove 'preparing qsharp environment' message from console
I started tutorial of qsharp and i wrote my first qsharp and python (host) codes. But when i run qsharp codes in console, gets some messages in console.
I want console shows only qsharp outputs.
1
vote
1
answer
48
views
Importing function from IQsharp notebook to Python notebook
I'm working with two notebooks: one for Q# operations and one for python3 to activate and analyze - both of them are on the same directory.
How can I import a Q# operation (from the IQsharp notebook) ...
2
votes
1
answer
63
views
Q# unit testing to check phase
I want to test a phase oracle by testing if the phase of qubit flipped.
I tried to do it by
AssertQubitIsInStateWithinTolerance((Complex(0., 0.), Complex(-1., 0.)), qubit, 1e-5);
But it doesn't ...
1
vote
1
answer
118
views
How to access the AST generated by the Q# compiler?
Background
Part of the project I'm working on requires me to analyze Q# source code and perform specific actions when certain syntax elements are encountered. For example, say I'd like to count how ...
1
vote
1
answer
2k
views
How to solve "jupyter_client.kernelspec.NoSuchKernel: No such kernel named iqsharp" in python?
I was trying to print hello world in Microsoft's Q#.
When I ran the code It's shows like this.
Even I installed the package. I don't know where the problem is.
I think it's in jupyter notebook's ...
0
votes
1
answer
205
views
Difference between R1 and Rz in Q#
As far as I know, both Rz and R1 operations in Q# rotate a qubit about the z-axis. In Q# API reference (https://learn.microsoft.com/en-us/qsharp) I found out that the only difference between them is ...
0
votes
1
answer
200
views
Cannot create Q# Quantum Application in Visual Studio
I'm going to create Q# application for the first time. I installed the "Microsoft Quantum Development Kit" and I have .not core 3.1.301 (the latest)
I use VS 2019 Community Edition.
In VS, I see the ...
4
votes
1
answer
331
views
Q# Program does not contain a static 'Main' method suitable for an entry point
I'm creating a program in Q#.
Problem
You are given two qubits in state |00⟩. Your task is to create the following state on them:
1/3–√(|00⟩+|01⟩+|10⟩)
You have to implement an operation which ...
2
votes
1
answer
74
views
How can I change the format of the Qubit IDs of the Q# DumpMachine?
In Q#, the DumpMachine function gives an overview of the state of the quantum system. Its output (in a Q# Jupyter Notebook) looks like this:
Is there a way for me to change the way the basis states ...
3
votes
1
answer
226
views
Jupyter Notebook not finding IQSharp
I have been trying to get a Q# running for the Quantum Katas, but have been having some difficulty in finding the Q# kernal. The only kernal that shows up is the Python 3 one which is used for the ...
0
votes
0
answers
36
views
Changing the signature of EntryPoint opeartion in auto-generated drivers
It appears that Q# now auto-generates C# drivers from annotations in new versions. When creating a plain command-line project from a VS Code template, we are presented with the following operation:
@...
1
vote
0
answers
214
views
Q# Could Not Find Workspaces due to DotNet Core
I get error for every parts of the code since I think net core problem.
/usr/local/share/dotnet/sdk/3.1.300/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(59,5): ...
1
vote
1
answer
101
views
Jupyter Notebook Q# kernal not connecting
I recently updated iqsharp(from 0.10 to 0.11) for jupyter notebooks (via Anaconda) and ever since, the Q# kernel stopped connecting when I open a new or existing Q# notebook. I have tried uninstalling ...
0
votes
2
answers
375
views
Unable to build a Q# program in VS Code
I am new to quantum computing and have just installed Microsoft's Visual Studio Code and the QDK extension for it. However, when I try to build and run (dotnet run from the terminal), it is unable to ...
1
vote
1
answer
154
views
Why do I get an error when I use DumpMachine in q#?
Here is my code:
using (q = Qubit()) {
Message("Input:");
Message("q = ∣0❭, index = 1");
Message("Requaired Output:");
Message("∣0❭: 0.707107 + 0....
1
vote
1
answer
95
views
How do you take an user input?
How do you take an user input as integer or string?
0
votes
1
answer
407
views
Python/Q#: Module not found error, with .qs file in the same directory
Lately I started working with Q# and python as host language. I was working on a project and everything seemed fine. Suddenly I get the error "module not found" and I seem to get it in all my previous ...
0
votes
1
answer
67
views
Polynomial Equations in Q# E=MC^2
I am trying to understand how to use quantum computing and have started to understand some of the basic gates and other concepts, but am not able to understand how to put it to practice in real world ...
0
votes
1
answer
2k
views
"jupyter-kernelspec" not found while installing iqsharp however it exists on PATH
While installing QDK for use with python as described in this guide, on executing dotnet iqsharp install I get the following exception
Traceback (most recent call last):
File "c:\users\hp\appdata\...
0
votes
2
answers
127
views
How to fix this problem with Q# installation: "Preparing Q# environment... Access to the path 'C:\Users\Sanjiv\Application Data' is denied."
I installed Q# with Python as per the instructions on Microsoft's site. Then, I tested the installation. It ran fine the first time. But subsequently, when I try to run any program, I get the ...
0
votes
1
answer
53
views
What is the minimum required file to generate a .yaml from a .nw in newchem?
I am using nwchem (with powershell as described in https://learn.microsoft.com/en-us/quantum/libraries/chemistry/installation) to generate .yamls so that I can do resource estimation using q#.
I ...