Skip to main content

Questions tagged [q#]

Q# is a domain-specific programming language used to express quantum algorithms. This tag should be used for questions related to creating/programming quantum algorithms using the 'Q#' language. If the question is unrelated to, or arising from some non-quantum aspect of Q#, it might be better to ask on StackOverflow. If appropriate, also use the [programming] tag.

Filter by
Sorted by
Tagged with
0 votes
0 answers
24 views

How to apply an SX gate in Q# [closed]

I'm trying to apply a square root of X gate, but cannot seem to find a way to do this easily in Q#, or even define my own gate from an array.
BigPea's user avatar
  • 1
0 votes
1 answer
20 views

How to calculate 'crossing-prefactor' for AQRE

We see that the crossing-prefactor for surface codes in Azure Quantum Resource Estimator is 0.03, and it is cited in this paper https://arxiv.org/pdf/1208.0928, however, how is there a formula for ...
spencerdearman's user avatar
1 vote
1 answer
34 views

Changing the 'compilerRunTimeoutMs' timeout variable on Azure Quantum Resource Estimator

Is there any way to change the variable 'compilerRunTimeoutMs' so that I can increase the timeout for Azure Quantum Resource Estimator. The only way that seems to be an option currently is to build ...
spencerdearman's user avatar
1 vote
1 answer
33 views

Migration guide from Classic QDK to Modern QDK for Q#

Is there any sort of migration guide from the classic QDK to the modern QDK. When I am trying to use functions, I keep running into this This documentation refers to the Classic QDK, which has been ...
spencerdearman's user avatar
0 votes
1 answer
32 views

Strange non-normal distribution histogram when applying Hadamard gate in a loop

Recently I have explored Q# quantum programming language. My basic test was this,- for 10000 times in a loop reset qubit to ...
Agnius Vasiliauskas's user avatar
1 vote
1 answer
41 views

Microsoft Classic QDK simulator

Is it possible to change the simulator used by the Classic QDK with Python simulation ? It's reported that Classic QDK supports several simulators (sparse, full-state...). Which one is used when ...
Arnaud's user avatar
  • 13
2 votes
1 answer
175 views

Is there a way to implement Smolin's variant of Shor's algorithm?

I'm currently investigating Shor's algorithm and especially Smolin's variant, that he described in his article: https://arxiv.org/abs/1301.7007 My applied changes according to Smolin's variant are ...
SageCat's user avatar
  • 135
1 vote
1 answer
27 views

Is there a way to measure a time spent for simulation? Does Q# support something like this?

I want to measure the time spent for simulation of different algorithms to make some assumption about their efficiency. I use Microsoft Azure Quantum SDK and VS Code setup.
SageCat's user avatar
  • 135
1 vote
1 answer
80 views

How write a marking oracle if greater than with Q#?

I'm trying to write a code to find a minimum in a list. I follow this paper : A quantum algorithm for finding the minimum. So I need to write an operator to mark the case $T [j] < T[y]$. My idea is ...
Cyrano's user avatar
  • 13
1 vote
1 answer
33 views

Understanding command Ignore in Q#

Consider the following code on which I want to run the resource estimator: ...
Marco Fellous-Asiani's user avatar
1 vote
1 answer
24 views

Applying Hadamard on inexistent qubit doesn't make Q# compilation fail: why?

This question is perhaps a bit unusual as I am not complaining that my code doesn't compile but rather that it compiles ;) Consider the following code: ...
Marco Fellous-Asiani's user avatar
1 vote
1 answer
62 views

Q#: how to write an algorithm in modular form (I don't understand the syntax and the documentation is a bit obscure)

I would like to make a resource estimate based on Azure resource estimator. However, the circuits I am interested in depend on some classical parameters: for this reason, I would like to make a ...
Marco Fellous-Asiani's user avatar
0 votes
1 answer
55 views

Displaying the circuit diagram associated to a circuit in Q#+Python

I am learning the Q# language, and my script is in Python (I am using the online Azure interface). I created an example quantum circuit on three qubits: ...
Marco Fellous-Asiani's user avatar
1 vote
1 answer
34 views

DumpRegister sometimes blank?

I'm just getting into the baffling world of Quantum Computing so forgive me if this is straightforward... I'm using Microsoft's Q# simulator so I know I'm allowed to peek into the internals of a Qubit ...
Oli Reading's user avatar
1 vote
1 answer
52 views

How can I get the source code of “RUS” and “PQF”

Currently, I’m studying these two papers: “Efficient Synthesis of Universal Repeat-Until-Success Circuits” and “Efficient synthesis of probabilistic quantum circuits with fallback”. I want the source ...
劉承瀚's user avatar
0 votes
1 answer
98 views

Cannot import namespace from a Q# file to run it in a python script

I'm trying to run a Q# skript from python host. To do so I've installed qsharp package for python and followed all instructions as described under following link: https://learn.microsoft.com/de-de/...
Deniss's user avatar
  • 1
1 vote
1 answer
60 views

Changing target Quantinuum Processor

I am trying to go through the Q# tutorial at https://learn.microsoft.com/en-us/training/modules/qsharp-create-first-quantum-development-kit/4-random-number-generator before I get my hands dirty and ...
PuzzledFish's user avatar
0 votes
0 answers
60 views

My First Own Grover Search with Q#

After I read the "[Quantum computing foundations](https://learn.microsoft.com/en-us/training/paths/quantum-computing-fundamentals/) of Microsoft I would like to be sure I understand a little the ...
Cyrano's user avatar
  • 13
2 votes
1 answer
74 views

How to create an arbitrary state for debugging purposes in the local computer?

Is there a way to create an arbitrary state in Q# just for debugging purposes in the local computer via the quantum full state simulator?
Fabio Dias's user avatar
0 votes
1 answer
201 views

What is the data type "Unit is Adj" in Q#?

I came across it as the return type of operations in this paper: https://arxiv.org/abs/2204.13835. It is also used in various places in the Q# documentation.
shashvat's user avatar
  • 847
0 votes
1 answer
146 views

VS Code/Q#: No namespace with the name "Microsoft.Quantum.Canon" exists [closed]

I am running the current latest version of Visual Studio Code on POP_OS (Ubuntu 22.04 LTS) and have installed all requirements to get Q# running on my machine: I have installed the SDK following ...
Matthias's user avatar
  • 111
0 votes
1 answer
56 views

Is there any paper about the encoding process in the machine learning API?

I want to know more details about the encoding process in machine learning. I have read the source code about the "ApproximateInputEncoder" method. It seems like a complex method. So is ...
W.xueshan's user avatar
1 vote
0 answers
64 views

What's meaning of the expression like "Qubit[] => Result"

In Q#,there are lots of expressions like "Qubit[] => Result". It can be the type of return result,like this: ...
W.xueshan's user avatar
0 votes
1 answer
37 views

How to caculate the resources used by an operation when the operation receives arguments?

I want to use Q# to evaluate the real resources of an operation, but some problems happen. I want to evaluate the resource of training model operation for the example of half-moons data classification....
W.xueshan's user avatar
0 votes
1 answer
26 views

Where can I find the package of "testing" when run the Linear Algebra exercise of QuantumKatas?

I want to run the Linear Algebra tutorial exercise of QuantumKatas in vscode. But the package of "testing" can't be found. The package of "qsharp" and "pytest" have been ...
W.xueshan's user avatar
1 vote
2 answers
142 views

How to caculate the inner product of two vectors with Q#

For example, if $a$ is a row vector, $b$ is a column vector, how to use Q# to calculate the inner product of these two? Which method or operator can be used? Just $a*b$? Any others? Really need your ...
W.xueshan's user avatar
1 vote
1 answer
42 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: ...
Muhy's user avatar
  • 163
0 votes
1 answer
51 views

Q# Application Template available for VS2022? [closed]

Implemented Grover Search Tutorial using Q# in VS2019. Moved to Windows 11 and also installed VS2022. Project opens and runs OK in VS2022. However code has no intellisense and color. i.e. program.qs ...
Bob Clegg's user avatar
1 vote
2 answers
161 views

Implementing the Oracle in Grover

I need your expert opinions/comments on this problem. Suppose I have a database (say 16 entries), such that db[0] = 0.12, db[1] = 0.84, db[2] = 0.55, ..., db[15] = 0.91. I want the oracle to mark ...
Kai's user avatar
  • 51
0 votes
0 answers
84 views

Q# Grover Tutorial Problem

Referring to the Q# tutorial on Grover algorithm in https://docs.microsoft.com/en-us/azure/quantum/tutorial-qdk-grovers-search?tabs=tabid-visualstudio, I replicated the code exactly in Visual Studio ...
Kai's user avatar
  • 51
4 votes
1 answer
60 views

Missing types, namespaces, directives, and assembly references

I use VS Code for C# and Unity3D and TypeScript and <...
Muhy's user avatar
  • 163
1 vote
1 answer
273 views

Q#/VS: No namespace with the name "Microsoft.Quantum.Canon" exists

I am trying to run a simple "Hello World" project in Q#, following this tutorial. I have completed the following steps (Step #s from tutorial link): Step 1: Installed the latest version of ...
Daniel Widdis's user avatar
1 vote
3 answers
2k views

Which quantum computing frame is suitable for optimization problems?

As in the computer world, not all programming languages are suitable for everything. Php = Backend Javascript = Frontend Data Analsys/ML = Python embedded systems = C Mobilphone/apps = Android / Swift ...
Enrique Benito Casado's user avatar
2 votes
1 answer
151 views

Passing arrays to operations/functions in Q# Jupyter Notebooks

In order to pass inputs to Q# operations/functions with Jupyter Notebooks, one uses the magic command, %simulate, and writes out the inputs as key-value pairs, <...
Calvin Stefano Mera's user avatar
0 votes
1 answer
125 views

Q# install issue

I have followed the instructions to install Q# using conda as recommended, and given by MS. When I try to import qsharp from my virtual env within a Python program, ...
Tony Holdroyd's user avatar
1 vote
2 answers
131 views

Circuit to transform $|0\rangle$ into $\alpha|0\rangle + \beta|1\rangle$ for any $\alpha, \beta$

Hi I'm new to QC and doing some katas in Q#. I got stuck on this excercise and would appreciate help: Quantum circuit to get following state qubit: $\alpha|0\rangle + \beta|1\rangle$ when the input is ...
user15791's user avatar
0 votes
1 answer
162 views

Things that I can compare between QDK and Qiskit

I am planning to write an article which compares QDK and Qiskit Mainly talking about the different interfaces, and difference in running few algorithms What all parameters should I compare and take ...
Aryan Arora's user avatar
3 votes
1 answer
150 views

Quantum Katas - Tutorials - Oracles - Task 3.3 (OR oracle of all bits except for a single bit)

Let $x$ be an arbitrary state composed of $N$ qubits and $k$ be an integer such that $0\leq k \leq N.$ The task is to ignore the $k$-th bit and to flip the sign of $x$ if any of the remaining bits are ...
Calvin Stefano Mera's user avatar
0 votes
1 answer
65 views

Quantum Katas - Tutorials - SingleQubitGates - Exercise 7 - Preparing an arbitrary state

Exercise 7 "Preparing an arbitrary state" from the Quantum Katas - Tutorials - SingleQubitGates asks to prepare a state $\alpha|0\rangle + e^{i\theta}\beta|1\rangle$, using parameters $\...
Cicero Chen's user avatar
5 votes
2 answers
1k views

Measuring entanglement entropy using a stabilizer circuit simulator

I'm trying to simulate stabilizer circuits using the Clifford tableau formalism that lets you scale up to hundreds of qubits. What I want to do is find the entanglement entropy on by splitting my ...
Germ's user avatar
  • 315
1 vote
1 answer
215 views

How to use QFT operation in Q#?

I see the QFT operation in the document given by Microsoft, but I don't know how to call it. ...
Damon's user avatar
  • 13
3 votes
1 answer
102 views

What all parameters can we take into account when comparing different quantum programming languages

I am planning to write a paper which compares Qiskit and Q# in the following circuits/algorithms Bell circuits Controlled swap to test similarity of two registers Phase kickback between two qubits ...
Aryan Arora's user avatar
1 vote
1 answer
139 views

Accessing tuple data in Q#

I am continuing my work on the SAT katas, but I thing I am missing something on the way the tuple data type works. In this example code, I am trying to access the data in a tuple type : ...
BrockenDuck's user avatar
1 vote
1 answer
229 views

Take every second element of the array in Q#

Very quick question, I am trying to implement SAT solving in Q# using Grover's Algorithm. I want to take every second element from an array starting at the second element, represented with a range ...
BrockenDuck's user avatar
5 votes
1 answer
152 views

Q# installation on Heroku

I'm trying to deploy a simple Quantum App written using Python on Heroku Server which is also using Microsoft's Q#, but getting the below error: ...
Shadab Hussain's user avatar
7 votes
1 answer
220 views

Q# Simulation Behavior

I am attempting to run a series of tests on a Q# program I'm running on the local simulator, but I'm not seeing any way to use >1 shot and collect the results of those shots at once, as in ...
Xavier McCaig's user avatar
1 vote
1 answer
35 views

Q# Callable Not Accessible from Open Namespace

I am trying to to call ApplyMultiplyControlledAnd(), and I'm receiving an error saying "The callable ApplyMultiplyControlledAnd exists in an open namespace, ...
Xavier McCaig's user avatar
1 vote
1 answer
146 views

Braket and Q# Simulators

I have implemented Shor's algorithm in Qiskit, and everything works as expected within the IBM Q experience for both the IBM qasm_simulator and real hardware. However, after I've implemented Shors in ...
Xavier McCaig's user avatar
3 votes
2 answers
65 views

Creating a resource count unit test in Q#

I want to create a unit test in Q# that runs an operation and asserts that it used at most 10 Toffoli operations. How do I do this? For example, what changes do I have to make to the code below? ...
Craig Gidney's user avatar
  • 40.7k
1 vote
1 answer
166 views

Correctly configuring a Q# test project in Visual Studio Code

I have some Q# code which I'm editing using visual studio code. The codebase is divided into a src/ folder and a test/ folder. ...
Craig Gidney's user avatar
  • 40.7k