Comments (1)
Yes. This is expected behavior. You cannot nest Circuit.Compile, Circuit.Run or Circuit.Fold. The standard technique is do each of these once. Here is a version of your code as an fsx script in samples:
#if INTERACTIVE
#I @"..\bin" // Tell fsi where to find the Liquid dll
#r "Liquid1.dll"
#r "Liquid2.dll"
#else
namespace Microsoft.Research.Liquid // Tell the compiler our namespace
#endif
open System // Open any support libraries
open Microsoft.Research.Liquid // Get necessary Liquid libraries
open Util // General utilites
open Operations // Basic gates and operations
open Tests // Just gets us the RenderTest call for dumping files
module Script = // The script module allows for incremental loading
[<LQD>] // LQD flags this as being callable from the command line
let Main() = // Name of callable function
logOpen "Liquid.log" false
show "Starting sample script..." // show does printf + logs and ensemble runs
let k = Ket(4)
let qs = k.Qubits
let expand (qs: Qubits) =
match (List.map(fun l -> [l]) qs) with
| [_;_;_;_] ->
let labellingStart (qbs: Qubits) =
LabelL "\\ket{k_i}" [qbs.[3]]
LabelL "\\ket{k_{i+1}}" [qbs.[2]]
LabelL "\\ket{k_{i+2}}" [qbs.[1]]
LabelL "\\ket{k_{i+3}}" [qbs.[0]]
labellingStart qs
// ... Remainder of circuit function ....
H >< qs
M >< qs
| x -> failwithf "4 qubits must be given, instead was given %A" x
let circ = Circuit.Compile expand qs
let circ = circ.Fold()
circ.RenderHT "Test"
#if INTERACTIVE
do Script.Main() // If interactive, then run the routine automatically
#endif
This will generate a drawing of the circuit as "Test.htm" (and Test.tex). What you really want to do comes under the area of Circuit manipulation. You can take any function and compile it to a circuit (as well as fold it). If you made your labels in one circuit and your real algorithm in one (or more) other compiled circuits, then you could just walk the circuit data structure and splice them together (this functionality is not built into the system).
If you take a look in the kit at \Liquid\UserCode\DaveWecker\AltOutput.fs
you'll see an example where I programmatically walk the circuit data structure to emit QASM
code. you could just walk your separate circuits to generate a single new one for execution or rendering.
from liquid.
Related Issues (20)
- Generating Circuit Diagram for Shor's Algorithm in Microsoft LIQUi> HOT 2
- Missing Methods HOT 13
- incorrect BitControl QASM output from AltOutput.fs HOT 1
- Hope that Liquid uses lower .NETFramework version for portability HOT 1
- Operation with different kets or the use of more than 24 qubits HOT 4
- Looking for help in compiling the Liquid.sln with VS2017 and windows 10 HOT 2
- Blockchain in QC HOT 1
- Please solve the halting problem :) HOT 2
- Please help me cheat at video games :) HOT 2
- Get FS0193 error when executing fsi --use:Teleport.fsx HOT 3
- Source code of __QLSA HOT 1
- Depolarized and amplitude damping noise in __NoiseAmp() HOT 1
- Memory Issues HOT 2
- Apply gate to second qubit in ket? HOT 2
- CSP Mixed Content error HOT 2
- Behaviour Entanglement HOT 4
- Limited Number of Qubits HOT 3
- LiquidTikz as a standalone library HOT 1
- Some questions about the ensemble computations across the 5 machines
- How to run Liquid on more than one machine?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from liquid.