Usage
Compile
The isQ compiler receives the isQ source file as input, and the instruction format is as follows:
isqc compile [options] <Input>
options:
--emit <FORMAT>
: output content format, format value can bemlir, mlirqir, llvm, mlir-optimized, binary, out
[default:out
]-o, --output <OUTFILE>
: output file-O, --opt-level <OPT_LEVEL>
: llvm opt-level such as-O1, -O2, -O3
etc.--target <TARGET_IR>
: target ir, now supportqir, open-qasm3, qcis
[default:qir
]--qcis-config <MAPPING_CONFIG_FILE>
: qcis mapping config file
You can compile isQ source file to qir or qcis using follow commands:
# compile to qir, default output file is source.so
isqc compile source.isq
# compile to qcis, default output file is source.qcis
isqc compile --target qcis --qcis-config MAPPING_CONFIG_FILE source.isq
Qcis instructions can run on real superconducting hardware, so isQ compiler provides qubit-mapping function. You should feed mapping_config_file
like above. The file content needs to include the following fields:
{
// required
"qbit_num": 12, // qubit number on hardware
"topo": [[1,2],[2,3],[3,4],[4,5],[5,6],[6,7],[7,8],[8,9],[9,10],[10,11],[11,12]], // topology of hardware
// option
"init_map": "simulated_annealing" // the way to get init mapping
}
Of course, you can get the intermediate results of compilation by using --emit
like that:
# compile to mlir, default output file is source.mlir
isqc compile --emit mlir source.isq
# compile to llvm(qir), default output file is source.ll
isqc compile --emit llvm source.isq
Simulate
qir
The simulator of isQ provides the simulation of qir
. The input must be a .so file generated by compiler. The instruction format is as follows
isqc simulate [options] <Input>
options:
--shots <NUM>
: simulate times, default is 1--debug
: use debug mod and get theprint
result--cuda <NUM>
: use gpu,NUM
is the number of qubits to be simulated-i <INT>
: int type paramter-d <DOUBLE>
double type paramter
The output is the statistical result of measurement in source.isq, like {"00": 4, "11": 6}
. And if use debug mod, print
result of each simulation can also output to stderr, like {ith simulate print: 1 1}
. When the shot_num is large, there will be many print result. It is suitable that redirect the stderr to a file. For example
qcis
isQ simulator can also simulate qcis
and the option is --qcis
. Another option is --shots <NUM>
which specifies the number of simulation runs, defualt is 1. The output is the statistical result of the measurement, like {"00": 4, "11": 6}
. For example:
Run
You can use isQ’s run
command to compile and simulate quantum programs (compile to qir
)
options
--shots <NUM>
: simulate times, default is 1--debug
: use debug mod and get theprint
result