Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,33 @@ jobs:
/tmp/wv/bin/osiris --help > /dev/null
/tmp/wv/bin/python -c "import osiris_cli, osiris_termux_console, protege, osiris_bench; print('console', osiris_cli.__version__); print('bench tasks', len(osiris_bench.load_tasks()))"

quantinuum:
# Runs the real pytket compile path and the qnexus-SDK adapter, which the matrix above skips or
# sends to the static fallback because it installs neither. Any skip here fails the job.
runs-on: ubuntu-24.04
timeout-minutes: 20
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install osiris-cli with the quantinuum and nexus extras
run: |
python -m pip install --upgrade pip
pip install numpy scipy requests PyYAML rich networkx cryptography pytest
pip install -e ".[quantinuum,nexus]"
python -c "import pytket, qnexus; print('pytket', pytket.__version__, '| qnexus', qnexus.__version__ if hasattr(qnexus, '__version__') else 'installed')"

- name: Quantinuum and Nexus tests (no skips allowed)
run: |
set -o pipefail
pytest tests/test_nexus_sdk.py tests/test_quantinuum_client.py tests/test_tket_and_quantinuum_nexus.py \
-v --tb=short --strict-markers -rfEs | tee /tmp/quantinuum.log
if grep -E "^SKIPPED|[0-9]+ skipped" /tmp/quantinuum.log; then echo "::error::a Quantinuum/Nexus test was skipped"; exit 1; fi

lint:
runs-on: ubuntu-24.04 # 26.04 has no Python 3.9
steps:
Expand Down
14 changes: 12 additions & 2 deletions docs/quantinuum/NEXUS_SDK_QUICKSTART.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ pip install 'osiris-cli[nexus]' # installs qnexus==0.51.4
qnx login # interactive; tokens are stored by qnexus, not by OSIRIS
```

## Approval

Nothing is sent to Nexus until the operator approves it. Every `preflight` and `run` shows what it will upload and run (circuits, project, target, estimated HQC) and asks `[y/N]`. In scripts, pass `--approve-remote`. Without a terminal and without the flag, the command refuses. Hardware runs also need the signed token described below.

## 1. Preflight (Tier 1, free)

```bash
Expand All @@ -24,7 +28,7 @@ This command:
2. compiles them for H2-1 on Nexus at `-O 0`;
3. prices each compiled circuit with Quantinuum's syntax checker (`circuits.cost(..., syntax_checker="H2-1SC")`);
4. cross-checks that price against the local HQC formula;
5. writes a Tier 1 receipt to `$OSIRIS_HOME/quantum/nexus_dispositions.jsonl`.
5. writes a Tier 1 `PREFLIGHT_CHECKED` receipt to `$OSIRIS_HOME/quantum/nexus_dispositions.jsonl`.

The preflight output includes the compiled-batch SHA-256. A hardware approval token is bound to that hash.

Expand Down Expand Up @@ -54,7 +58,13 @@ The run refuses to start in any of these cases:
- the token was signed for a different compiled batch, target, shot count or HQC budget;
- Nexus compiles the circuits to a different batch than the one the token names.

`HARDWARE_ATTESTED` is written only for a completed Tier 3 job with a real job ID.
`HARDWARE_ATTESTED` is written only after an attestation step that asks Nexus again how the job ran, separately from the submit call. All three checks must pass:

- `jobs.status` reports `COMPLETED`;
- the job record, fetched again by ID, names the requested QPU;
- every result's backend info names the same QPU.

If any check fails, the run is recorded as `HARDWARE_UNVERIFIED` with `hardware=false`, and the diagnostics say why.

## Ledger

Expand Down
57 changes: 48 additions & 9 deletions osiris_cli/claims.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ def standing(self) -> str:
r"(attention|torsion)[^.\n]{0,40}?\bt-lock\b", r"phase[\s-]*conjugat\w*[\s-]+positional",
r"non[\s-]*local[\s,]+non[\s-]*causal|non[\s-]*causal[\s-]+living|\bncllm\b|\bnc-lm\b",
r"information[\s-]*manifold collapse|non[\s-]*local correlation factor"),
testable="Whether these parts help as architecture is CRSM_ARCH (NCLM-ARCH-1, pre-registered); the "
testable="Whether these parts help as architecture is CRSM_ARCH (NCLM-ARCH-1: FAIL under Amendment 3, N=2); the "
"physics names would need a measured physical quantity, which none of them has.",
checks=(("phi_positional", (128, 51.843, 0.946)),)),
Claim("NCLM_PC_CORRECTOR", "The core's phase-conjugate error correction detects decoherence (Γ > 0.3) and "
Expand All @@ -500,16 +500,55 @@ def standing(self) -> str:
"the rest of the CRSM block); alone it needs a leave-one-out follow-up."),
Claim("CRSM_ARCH", "The CRSM components (torsion-locked attention, pilot-wave factor, phase-conjugate corrector, "
"1/φ FFN scale, φ position table) make the core a better byte model than a standard transformer of "
"the same size", "UNTESTED",
"Pre-registered 2026-10-08 as NCLM-ARCH-1, not run: the live core against pre-norm blocks with base-10000 "
"positions and the FFN widened to 384 (725,760 vs 726,304 parameters), 8 paired seeds, best held-out "
"documents bits/byte, minimum effect 0.05, PASS / FAIL / NO-DIFFERENCE fixed in advance. It compares the "
"bundle, not single components. One-seed checks made before registration (in the pre-registration) "
"hint that the corrector may not help; they are not a result.",
(("file", "osiris-cli/experiments/nclm_arch1/PRE_REGISTRATION.md", "NCLM-ARCH-1 pre-registration"),),
"the same size", "REFUTED",
"FAIL under Amendment 3 (N=2, adopted after seed 200); incomplete against 8-seed pre-registration. "
"NCLM-ARCH-1 was registered 2026-10-08 with 8 paired seeds (200-207), best held-out documents "
"bits/byte, minimum effect 0.05. Amendment 3 (2026-11-01, recorded before seed 201 finished) bounded "
"the run to seeds 200 and 201. On those two pairs the standard arm won both: mean paired gain "
"(standard - crsm) -0.595 bits/byte, SD 0.026, one-sided 95 % bounds [-0.712, -0.478]; held-out chat "
"+0.728 bpb worse for crsm. All four runs hit the 12,000-step cap before early stopping. Seeds 202-207 "
"were never run, so the registered 8-seed test is incomplete; the direction and size of the gap on the "
"two pairs run are not in doubt.",
(("file", "osiris-cli/experiments/nclm_arch1/PRE_REGISTRATION.md", "NCLM-ARCH-1 pre-registration"),
("file", "osiris-cli/experiments/nclm_arch1/RESULT.md", "NCLM-ARCH-1 result, seeds 200-201"),
("file", "osiris-cli/experiments/nclm_arch1/EXECUTION.md", "Amendment 3: scope bounded to N=2")),
(r"\bcrsm[\s-]+(architecture|components?|blocks?|mechanics)\b", r"\bnclm[\s-]*arch[\s-]*1\b",
r"sovereign[\s-]*(block|mechanics)\b[^.\n]{0,40}?(better|improv\w*|helps?|beats?|outperform\w*)"),
testable="Run NCLM-ARCH-1 as registered: experiments/nclm_arch1/run.py."),
testable="Seeds 202-207 of NCLM-ARCH-1 as registered (experiments/nclm_arch1/run.py) would complete "
"the 8-seed test.",
caveats=("N=2 of 8 registered seed pairs (Amendment 3)", "all runs hit the step cap")),
Claim("XTOP005_DD", "Dynamical decoupling protects an idle code-space register on IBM Heron r2 "
"(XTOP-005 H2, H3)", "SUPPORTED",
"Pre-registered (10.5281/zenodo.24425416) and run on ibm_marrakesh, job dc0uhdts2omc7389tmt0, 216 "
"circuits x 1,000 shots. H2 and H3 (decoupling against bare idling) are supported at both depths, "
"Holm-adjusted p = 0.002: H2 +0.122 (depth 1) and +0.176 (depth 3), H3 +0.135 and +0.102.",
(("doi", "10.5281/zenodo.24425416", "XTOP-005 pre-registration"),
("doi", "10.5281/zenodo.24425627", "XTOP-005 paper"),
("file", "osiris-cli/docs/xtop005/qpu/results.json", "XTOP-005 hypothesis tests, job dc0uhdts2omc7389tmt0")),
(r"\bxtop[\s-]*0*05\b", r"\bdynamical[\s-]+decoupling\b[^.\n]{0,60}?\b(heron|marrakesh|heavy[\s-]*hex)\b"),
testable="Scope: one device (ibm_marrakesh), one session, depths 1 and 3."),
Claim("XTOP005_ENCODING", "[[4,2,2]] error-detection encoding protects the register on heavy-hex "
"(XTOP-005 H1, H4)", "NULL",
"Pre-registered with H2 and H3 on the same job (dc0uhdts2omc7389tmt0). H1 is not supported at either "
"depth (+0.021, Holm p = 0.34; +0.043, Holm p = 0.031, above the registered threshold); H4 is not "
"supported (-0.054 at depth 1, CI entirely below zero; +0.015 at depth 3, Holm p = 0.34). On heavy-hex "
"the routing the code needs costs more than the detection gains.",
(("doi", "10.5281/zenodo.24425416", "XTOP-005 pre-registration"),
("doi", "10.5281/zenodo.24425627", "XTOP-005 paper"),
("file", "osiris-cli/docs/xtop005/qpu/results.json", "XTOP-005 hypothesis tests, job dc0uhdts2omc7389tmt0")),
(r"\[\[\s*4\s*,\s*2\s*,\s*2\s*\]\][^.\n]{0,60}?\b(heron|marrakesh|heavy[\s-]*hex|protect\w*)\b",),
testable="The H2-1 design (docs/xtop005/quantinuum) tests the same code with all-to-all connectivity; "
"not yet run."),
Claim("ADV0_PEAKED", "Twirled-mirror peaked circuits on a heavy-hex region (up to 56 qubits, depth 16) are "
"beyond classical simulation", "REFUTED",
"ADV-0 (offline, no QPU, not pre-registered) scanned 30 cells, n = 12-56, depth 2-16, on FakeMarrakesh "
"regions. In every cell at least one laptop-scale attack (Pauli propagation, exact light-cone "
"statevector, or MPS sampling) recovered the hidden string. At n = 56, depth 16 the predicted hardware "
"peak is 0.041; MPS at bond dimension 64 fails (0.005) but bond dimension 256 wins (0.165 in 1,274 s).",
(("file", "osiris-cli/docs/adv0/ADV0_REPORT.md", "ADV-0 report and 30-cell scan"),),
(r"\badv[\s-]*0\b", r"\bpeaked[\s-]+circuits?\b[^.\n]{0,60}?\b(advantage|classical(ly)?|simulat\w*)\b"),
testable="ADV-1 (looped regions, non-mirror construction, structure-aware attack) with the gate in the "
"ADV-0 report: MPS at bond dimension 1024, Pauli propagation and light-cone must all fail."),
Claim("RQC_ADVANTAGE", "Recursive Quantum Circuits with adaptive feedback outperform random circuit sampling "
"(p < 0.05); research-grade and ready for peer review", "UNTESTED",
"RQC_RESEARCH_METHODOLOGY.md is a proposal: its p-values (0.024, 0.018, 0.009) are listed under "
Expand Down
72 changes: 62 additions & 10 deletions osiris_cli/providers/nexus_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,18 @@ def _record(self, **kw: Any) -> Dict[str, Any]:

def preflight(self, circuits: Sequence[Any], target: str = "H2-1", shots: int = 500,
optimisation_level: int = 0, job_name: str = "osiris-preflight",
timeout: float = 900.0) -> PreflightResult:
"""Compile on Nexus for ``target`` (an H2 QPU name) and price it with that QPU's syntax checker."""
timeout: float = 900.0, approve_remote: bool = False) -> PreflightResult:
"""Compile on Nexus for ``target`` (an H2 QPU name) and price it with that QPU's syntax checker.

This uploads circuits and starts a compile job on Nexus, so it needs ``approve_remote=True``
(the CLI asks the operator, or takes ``--approve-remote``). Nothing is sent before that check.
"""
spec = resolve_quantinuum_target(target)
if spec.family != "H2" or spec.role != "qpu":
raise GovernanceError(f"preflight takes an H2 QPU name (H2-1, H2-2) to compile and price for; got {target}")
if not approve_remote:
raise GovernanceError("preflight uploads and compiles on Quantinuum Nexus: explicit operator approval "
"is required (approve_remote=True / --approve-remote)")
checker = f"{spec.name}SC"
proj = self.project()
src = [tket_sha256(c) for c in circuits]
Expand All @@ -184,15 +191,15 @@ def preflight(self, circuits: Sequence[Any], target: str = "H2-1", shots: int =
nexus_cost: List[Optional[float]] = []
for r in compiled_refs:
v = self._call("circuits.cost", circuit_ref=r, n_shots=shots,
backend_config=self._config(spec.name), syntax_checker=checker)
backend_config=self._config(spec.name), syntax_checker=checker, project=proj)
nexus_cost.append(None if v is None else float(v))
local = [str(local_hqc(c, shots)) for c in compiled]
job_id = str(getattr(job, "id", ""))
res = PreflightResult(target=spec.name, shots=shots, project_id=str(getattr(proj, "id", "")),
compile_job_id=job_id, compiled_refs=compiled_refs, compiled_sha256=comp_sha,
source_sha256=src, nexus_hqc=nexus_cost, local_hqc=local)
res.receipt = self._record(
target=checker, tier=1, disposition="SIMULATED", hardware=False, status="COMPLETED",
target=checker, tier=1, disposition="PREFLIGHT_CHECKED", hardware=False, status="COMPLETED",
job_id=job_id, shots=shots,
estimated_hqc=float(res.total_nexus_hqc if res.total_nexus_hqc is not None else res.total_local_hqc),
source_sha256=batch_sha256(src), compiled_sha256=batch_sha256(comp_sha), compiler_backend="nexus-sdk",
Expand All @@ -205,11 +212,19 @@ def preflight(self, circuits: Sequence[Any], target: str = "H2-1", shots: int =
def run(self, pre: PreflightResult, target: str, shots: Optional[int] = None,
approval_token: Optional[str] = None, max_emulator_hqc: float = 200.0,
job_name: str = "osiris-run", timeout: float = 3600.0,
verify_token: Optional[Callable[..., Any]] = None) -> Dict[str, Any]:
"""Execute the pre-flighted circuits on ``target`` (H2-1E/H2-2E emulator, or H2-1/H2-2 hardware)."""
verify_token: Optional[Callable[..., Any]] = None, approve_remote: bool = False) -> Dict[str, Any]:
"""Execute the pre-flighted circuits on ``target`` (H2-1E/H2-2E emulator, or H2-1/H2-2 hardware).

Emulator jobs need ``approve_remote=True``; hardware jobs need a signed Tier 3 token, which is
itself the operator's approval. ``HARDWARE_ATTESTED`` is written only after Nexus confirms the job
completed on the requested QPU (see ``_attest_hardware``).
"""
spec = resolve_quantinuum_target(target)
if spec.tier == 1:
raise GovernanceError("run needs an emulator or QPU target; the syntax checker ran in preflight")
if spec.tier == 2 and not approve_remote:
raise GovernanceError(f"{spec.name} jobs use the Nexus emulator quota: explicit operator approval is "
"required (approve_remote=True / --approve-remote)")
shots = int(shots or pre.shots)
if shots == pre.shots and pre.total_nexus_hqc is not None:
per_circ = [Decimal(str(v)) for v in pre.nexus_hqc]
Expand Down Expand Up @@ -238,13 +253,50 @@ def run(self, pre: PreflightResult, target: str, shots: Optional[int] = None,
c = br.get_counts()
counts.append({"".join(str(b) for b in k): int(v) for k, v in sorted(c.items())})
job_id = str(getattr(job, "id", ""))
hw = spec.tier == 3
metrics: Dict[str, Any] = {"circuits": len(counts), "max_cost_per_circuit": caps}
diagnostics: List[str] = []
if spec.tier == 3:
attestation, problems = self._attest_hardware(job, spec, results)
metrics["attestation"] = attestation
diagnostics.extend(problems)
disposition, hw = ("HARDWARE_ATTESTED", True) if not problems else ("HARDWARE_UNVERIFIED", False)
else:
disposition, hw = "SIMULATED", False
receipt = self._record(
target=spec.name, tier=spec.tier, disposition="HARDWARE_ATTESTED" if hw else "SIMULATED",
target=spec.name, tier=spec.tier, disposition=disposition,
hardware=hw, status="COMPLETED", job_id=job_id, shots=shots, estimated_hqc=float(total),
source_sha256=batch_sha256(pre.source_sha256), compiled_sha256=compiled_batch,
compiler_backend="nexus-sdk", preflight_target=f"{pre.target}SC", preflight_job_id=pre.compile_job_id,
preflight_passed=True, metrics={"circuits": len(counts), "max_cost_per_circuit": caps},
preflight_passed=True, metrics=metrics, diagnostics=diagnostics,
compiler_options={"qnexus": QNEXUS_VERSION})
return {"target": spec.name, "job_id": job_id, "shots": shots, "hqc_estimate": str(total),
"counts": counts, "receipt": receipt}
"disposition": disposition, "diagnostics": diagnostics, "counts": counts, "receipt": receipt}

def _attest_hardware(self, job: Any, spec: Any, results: Sequence[Any]) -> Tuple[Dict[str, Any], List[str]]:
"""Ask Nexus, independently of the submit call, where and how the job ran.

Checks: the job status is COMPLETED; the job record fetched again by id names ``spec.name`` as its
device; every result's backend info names the same device. Any failure is returned as a problem and
the run is recorded as HARDWARE_UNVERIFIED, never HARDWARE_ATTESTED.
"""
problems: List[str] = []
st = self._call("jobs.status", job=job)
status = str(getattr(getattr(st, "status", None), "value", getattr(st, "status", "")))
if status != "COMPLETED":
problems.append(f"Nexus job status is {status or 'unknown'}, not COMPLETED")
fresh = self._call("jobs.get", id=getattr(job, "id", None))
cfg = getattr(fresh, "backend_config_store", None)
job_device = getattr(cfg, "device_name", None)
if job_device != spec.name:
problems.append(f"Nexus job record names device {job_device!r}, expected {spec.name!r}")
result_devices = []
for r in results:
bi = r.download_backend_info()
result_devices.append(getattr(bi, "device_name", None))
if not result_devices or any(d != spec.name for d in result_devices):
problems.append(f"result backend devices {sorted(set(map(str, result_devices)))} != {spec.name!r}")
completed = getattr(st, "completed_time", None)
evidence = {"job_status": status, "job_device": job_device, "result_devices": result_devices,
"completed_time": completed.isoformat() if hasattr(completed, "isoformat") else completed,
"nexus_cost": getattr(st, "cost", None)}
return evidence, problems
Loading
Loading