Skip to main content
Introducing The Quantum Infrastructure Cloud Learn more

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

LayerSchemaFileStyleLowers to
HiQ Objectsqcos-l3/0.qcos3classes, interfaces and one mainHiQ Script
HiQ Scriptqcos-l2/0.qcos2imperative, end and next close blocksHiQ Assembly
HiQ Assemblyqcos/0.qcosone statement per line, bracesqcos-ir/2
Pulseqcos-pulse/0.qcospone statement per line, units on every timeqcos-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.

QubitsAnglesGates
10hxyzssdgttdgsxsxdgid
11rxryrzpphaseu1
12u2
13uu3U
20cxCXcyczchcscsdgswapiswapecrdcx
21cpcphasecu1crxcrycrzrxxryyrzzrzx
23cu3
24cu
30ccxcczcswaprccx
40c3x
50c4x
01gphase

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.

WhatLimit
Source256 KiB
Statements after expansion20,000
Array size65,536
Block and expression nesting64
Call depth64
Integer width64 bits
Diagnostics returned50
Real-time loop budget2^20
Objects in a HiQ Objects program65,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.