Skip to main content
Introducing The Quantum Infrastructure Cloud Learn more
HiQ

Quantum programming language

Quantum programs that measure, decide and try again.

HiQ is the SoftQuantus quantum programming language. Four layers, from classes and interfaces down to pulses, with control flow and typed classical data inside the program, checked before it reaches a machine.

  • Check, synthesize, compile, publish: live
  • Run: not open yet
  • No HiQ program reaches hardware yet
// GHZ state on four qubits: all bits read 0000 or 1111.
program ghz
qubits q[4]
bits m[4]

h q[0]
cx q[0], q[1]
cx q[1], q[2]
cx q[2], q[3]
repeat i in 0..4 {
  measure q[i] -> m[i]
}
ghz.qcos · HiQ Assemblywriting

ok true · 4 qubits · depth 5 · diagnostics []

The card is the checker’s real answer for the GHZ example. The film is a SoftQuantus render.

In practice

Put HiQ to work.

Five programs from the examples, as you would write them. Each one passes the checker today. None of them runs on quantum hardware yet.

HiQ Script

Error correction inside the program.

Encode one bit in three qubits, measure two parities with an ancilla that is used twice, and correct from the syndrome. The correction is decided by the measurement, in the same program, not by a second language wrapped around a circuit.

  • for loops, typed integers and select on a measured syndrome
  • An ancilla taken with alloc and handed back reset with free
  • HiQ Script, checked down to the same IR as Assembly
Open repetition_code.qcos2
l2/repetition_code.qcos2

Three-qubit bit-flip code: encode, inject one error, measure the two parities with a reused ancilla, and correct from the syndrome.

for i = 0 to 1  alloc anc  cx d[i], anc  cx d[i + 1], anc  measure anc into s[i]  free anc resetnext​if s[0] then  let syndrome = syndrome + 1endif s[1] then  let syndrome = syndrome + 2end​select syndrome
lines 16–31source only, not run
Lines 16 to 31 of l2/repetition_code.qcos2, in HiQ Script. The marked line is line 20.

Why HiQ

Circuits list gates. Experiments make decisions.

Most quantum code is a fixed list of gates, with the decisions around it written in a second language and joined by hand. Error correction, adaptive measurement and repeat-until-success need a program that reacts while it runs.

HiQ puts those decisions in the program. The checker reads all of it, names every mistake with a code, a line and a column, and says what a machine needs before anything is compiled.

Four layers

4

layers, from classes and interfaces down to pulses

Objects for libraries, Script for experiments, Assembly for exact control and Pulse for the signal itself.

51

gate names in one table

Shared by every layer, from h and cx to controlled rotations.

77

named diagnostic codes

Each refusal comes back with a code, a line and a column.

24

worked examples

Each passes the checker and states its expected result.

A budget on every loop that waits

A loop that waits on a measurement says how many times it may run, so the checker can bound the program.

while !m budget 16 {  measure anc -> m}

From source to hardware

One path from a program to a machine.

Every step is a route on the QCOS API and a command in the softqcos CLI, with a key from the Softquantus Research Platform. Check, synthesize, compile and publish answer in production today. Running is the step that is not open yet.

QCOS API · softqcos CLI

Five calls, four of them open.

Each card is one call to QCOS with an API key from the Softquantus Research Platform. Choose a step, or let the deck play.

Every route, with what it takes and returns

Check

POST /api/v1/runtime/lang/check

Answered

Command

softqcos lang check ghz.qcos --json

Response

ok
true
declared_qubits
4
peak_qubits
4
expanded_ops
8
depth
5
gate_counts
{ h: 1, cx: 3 }
diagnostics
[]

The check response is the checker's real output for examples/l1/ghz.qcos. The other cards describe what each route returns. Nothing on this page calls the API.

Four layers

Write at the level the work needs.

Objects for libraries, Script for experiments, Assembly for exact control and Pulse for the signal itself. Assembly, Script and Objects all end as the same IR, and a refusal from a lower layer comes back at the line of your source.

HiQ Assembly

One statement per line, braces · .qcos · qcos/0

For exact control of every gate, measurement and branch.

One statement per line: named qubits, routines, real-time branches and switches, and loops that wait on a measurement only with a declared budget.

Lowered to qcos-ir/2

HiQ Assembly reference

HiQ AssemblyFrom source to a machine

teleport.qcos
// Teleportation: the state ry(pi / 3)|0> moves from msg to bob,// using two measurements and real-time corrections.program teleportqubits msg, alice, bobbits m0, m1, out​ry(pi / 3) msg​// Shared Bell pair between alice and bob.h alicecx alice, bob​// Bell measurement on msg and alice.cx msg, aliceh msgmeasure msg -> m0measure alice -> m1​// Corrections decided at run time.if m1 {  x bob}if m0 {  z bob}measure bob -> out

In the language

Qubits, circuits and the decisions around them.

What a HiQ program talks about, and what the checker watches for in each.

HiQ Assemblygates
cx q[0], q[1]crz(pi / 4) q[1], q[2]

One gate table for every layer, from h and cx to controlled rotations, cu and c4x. A gate with the wrong number of qubits or angles is stopped by name.

Renders by SoftQuantus. They illustrate the ideas, not a machine.

Checked before it runs

A mistake stops at its line, not after a run.

The checker returns every error with one of 77 stable codes, a line and a column, and nothing is compiled until the program is clean. Switch between the two versions of this program.

retry.qcosHiQ Assembly · qcos/0
program retryqubits ancbits mh ancmeasure anc -> mwhile !m {  reset anc  h anc  measure anc -> m}

Refused by the checker

loop.unbounded

line 6, column 10

a while loop needs a budget: while <condition> budget <n> { ... }

The loop waits on a measurement. Without a budget, a machine could wait on it forever, so the program never reaches one.

Every code, with what it means: diagnostics reference.

Examples

Programs to start from.

Each one passes the checker and states its expected result in its first comment.

In your editor

Write HiQ in Visual Studio Code.

QCOS Studio is the SoftQuantus extension for Visual Studio Code. It opens the four HiQ file types and helps as you type, with no account and no network. Checking and compiling go through the QCOS API with your key.

  • .qcos3 · HiQ Objects
  • .qcos2 · HiQ Script
  • .qcos · HiQ Assembly
  • .qcosp · HiQ Pulse

On your machine · no key

  • Highlighting, outline, folding and completion that fits where the cursor is
  • Hover, signature help, Go to Definition and Find All References
  • Rename, which refuses with the reason when a change would not be safe
  • Snippets for each layer and the example programs, opened as new files

Through the QCOS API · with a key

  • Problems in the editor: each save sends the source to the checker, unless you turn check on save off
  • The circuit and the control flow of the checked program, drawn beside the source
  • Compile for a target, with the circuit drawn for it and its metrics
  • Estimate Resources, before anything is submitted

Limits today

  • A preview, published on the Visual Studio Marketplace only. It is not on Open VSX.
  • Rename is not available in HiQ Objects, where a method may be reached through an interface or a parent class.
  • Pulse programs are checked and measured, not compiled or run.
  • Run waits for the run route to open in production, and no HiQ program reaches quantum hardware.
  • Untrusted workspaces are not supported, because the extension sends source to the API with your key.

Open language

The language is open. The compiler stays in QCOS.

Everything you need to read and write HiQ is being prepared for release under the Apache License 2.0. The checker, the compiler and the runtime stay in QCOS, and you reach them with an API key.

Open · Apache-2.0

  • The language reference for all four layers
  • Grammars in EBNF, one per layer
  • Tutorials, from a first program to pulses
  • 24 worked examples, already in the developer docs
  • Editor grammars for syntax highlighting
  • An RFC process, governance and a contribution guide

The public repository is being prepared. Until it opens, the reference, the grammars and the examples are published in the developer docs.

In QCOS · through the API

  • The checker and its diagnostics
  • Synthesis from C to reversible oracles
  • The compiler, optimisation levels 0 to 3, hardware profiles
  • Publishing programs in a workspace
  • Runs on Softquantus Cloud, when they open

QCOS is reached with the softqcos CLI or the API and a key from the Softquantus Research Platform. Nothing is installed on your machine but the client.

How we will measure it

Better means numbers, not adjectives.

HiQ makes no claim of speed against other languages. Before its programs run in production, these are the results it has to show.

01

Published conformance

Results against a public test suite, case by case, including the cases that fail.

02

A program end to end

A repeat-until-success program running from source to result on a virtual control system.

03

A record per compile

Each compilation leaves a sealed record that fits the evidence QCOS keeps of each run.

04

A test for every refusal

Each refusal has a name and a test that proves the program is stopped.

05

Cost before running

An estimate of the resources a program needs, given before anything is submitted.

Take part

Help shape HiQ.

We are looking for people who write quantum programs, build compilers or run control systems, to test the checker and compiler now and the first program runs when they open.

PDF, DOC or DOCX, up to 5 MB.

Start with one program.

Read the reference, open an example and check it with the softqcos CLI. Until HiQ programs can run, circuits reach a simulator through the QCOS API, SDK, CLI and MCP server.

32 states, equal amplitude

Grover search over 32 states, computed in your browser as it plays. An illustration, not a run on a quantum computer.