DevelopersHiQ / Language
Language reference
HiQ has three source languages, HiQ Objects, HiQ Script and HiQ Assembly. Each one lowers to the one below it, and all of them end as a qcos-ir/2 program. A fourth, the pulse layer, describes the schedule below the gates and lowers to the control level.
Layers
| Layer | Schema | File | Style | Lowers to |
|---|---|---|---|---|
| HiQ Objects | qcos-l3/0 | .qcos3 | classes, interfaces and one main | HiQ Script |
| HiQ Script | qcos-l2/0 | .qcos2 | imperative, end and next close blocks | HiQ Assembly |
| HiQ Assembly | qcos/0 | .qcos | one statement per line, braces | qcos-ir/2 |
| Pulse | qcos-pulse/0 | .qcosp | one statement per line, units on every time | qcos-ir/1, control level |
.qcos, .qcos2, .qcos3, .qcosp, qcos-l2/0, qcos-l3/0 and qcos-pulse/0 are the identifiers the QCOS service reads. There is no QASM on this path: the languages neither read nor write it.
A refusal from a lower layer comes back at the line of your source that caused it. So an Objects program can report an Assembly code such as gate.unknown, and codes are stable.
This reference is normative. Where it and the hosted checker (POST /api/v1/runtime/lang/check) disagree, one of the two has a bug.
Gates
All three source languages share this table of 51 names, aliases included. A gate is written name(angles) q1, q2. Angles are omitted when the gate takes none.
| Qubits | Angles | Gates |
|---|---|---|
| 1 | 0 | hxyzssdgttdgsxsxdgid |
| 1 | 1 | rxryrzpphaseu1 |
| 1 | 2 | u2 |
| 1 | 3 | uu3U |
| 2 | 0 | cxCXcyczchcscsdgswapiswapecrdcx |
| 2 | 1 | cpcphasecu1crxcrycrzrxxryyrzzrzx |
| 2 | 3 | cu3 |
| 2 | 4 | cu |
| 3 | 0 | ccxcczcswaprccx |
| 4 | 0 | c3x |
| 5 | 0 | c4x |
| 0 | 1 | gphase |
A wrong name is gate.unknown, a wrong qubit count is gate.arity, and a wrong angle count is gate.params.
Limits
The hosted checker works within these limits.
| What | Limit |
|---|---|
| Source | 256 KiB |
| Statements after expansion | 20,000 |
| Array size | 65,536 |
| Block and expression nesting | 64 |
| Call depth | 64 |
| Integer width | 64 bits |
| Diagnostics returned | 50 |
| Real-time loop budget | 2^20 |
| Objects in a HiQ Objects program | 65,536 |
Example programs
There are complete programs for every layer: Bell, GHZ, teleportation, superdense coding, Deutsch-Jozsa, Bernstein-Vazirani, Grover, the Fourier transform, phase estimation, the repetition code, repeat-until-success, parallel tasks, and Rabi, Ramsey and echo schedules. Each one passes the checker and states its expected result in its first comment. Read them with full source.
Check, compile and run
Programs are checked, synthesised, compiled and published through the QCOS API, with a key from the Softquantus Research Platform. Running is not open in production yet. Every route and CLI command.