Run this model with HF Jobs

Run itsalissonsilva/QuantumCoder-9B on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs to fine-tune https://huggingface.co/itsalissonsilva/QuantumCoder-9B. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/itsalissonsilva/QuantumCoder-9B on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.

Evaluate on a benchmark

Use HF Jobs to evaluate https://huggingface.co/itsalissonsilva/QuantumCoder-9B. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.

Quantize for lower memory use

Use HF Jobs to create a 4-bit version of https://huggingface.co/itsalissonsilva/QuantumCoder-9B. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
File size: 3,781 Bytes
e0897b0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
"""Verify executor isolation and exact reference programs before model code."""

import hashlib
import json
from pathlib import Path
import numpy as np
import pyarrow.parquet as pq
from huggingface_hub import HfApi, hf_hub_download
import quantum_sandbox as sandbox

REPO = "itsalissonsilva/QuantumCoder-9B"
DATA = "itsalissonsilva/quantum-circuit-specs-synthetic"


def main():
    api = HfApi()
    revision = api.dataset_info(DATA).sha
    rows = []
    for split in ["train", "validation", "test"]:
        rows.extend(
            pq.read_table(
                hf_hub_download(
                    DATA, f"data/{split}.parquet", repo_type="dataset", revision=revision
                )
            ).to_pylist()
        )
    versions = sandbox.initialize()
    isolation = sandbox.run("", 1, mode="isolation_check")
    assert isolation == dict(
        file_opens_blocked=True, network_blocked=True, uid=65534, environment_empty=True
    ), isolation
    for program in [
        "open('/etc/hostname').read()",
        "import os",
        "import numpy as np\nstate=np.load('/etc/passwd')",
        "x=().__class__",
        "eval('1+1')",
    ]:
        try:
            sandbox.screen(program)
        except (ValueError, SyntaxError):
            continue
        raise AssertionError("Forbidden AST fixture passed screening")
    records = []
    for framework in ["qiskit", "pennylane", "cirq"]:
        chosen = sorted(
            [r for r in rows if r["framework"] == framework],
            key=lambda r: hashlib.sha256(r["id"].encode()).hexdigest(),
        )[:30]
        for row in chosen:
            result = sandbox.run(row["program"], row["qubits"])
            if result.get("status") == "executed":
                state = np.array(result["real"]) + 1j * np.array(result["imag"])
                target = np.array(row["state_real"]) + 1j * np.array(row["state_imag"])
                fidelity = float(abs(np.vdot(target, state)) ** 2)
                passed = abs(result["norm"] - 1) < 1e-6 and fidelity > 1 - 1e-6
            else:
                fidelity = None
                passed = False
            records.append(
                dict(
                    id=row["id"],
                    framework=framework,
                    passed=passed,
                    fidelity=fidelity,
                    execution=result,
                )
            )
        print(
            json.dumps(
                dict(
                    stage="references",
                    framework=framework,
                    passed=sum(r["passed"] for r in records if r["framework"] == framework),
                    total=len(chosen),
                )
            ),
            flush=True,
        )
    report = dict(
        data_revision=revision,
        versions=versions,
        isolation=isolation,
        reference_checks=records,
        all_passed=all(r["passed"] for r in records),
        scope="Restricted supported-Python executor, fail-closed; not an arbitrary-code sandbox service.",
    )
    folder = Path("quantum_executor_preflight")
    folder.mkdir(exist_ok=True)
    (folder / "preflight.json").write_text(json.dumps(report, indent=2))
    (folder / "quantum_sandbox.py").write_bytes(Path(sandbox.__file__).read_bytes())
    (folder / "train_quantum_exec_preflight_pilot.py").write_bytes(Path(__file__).read_bytes())
    api.upload_folder(
        repo_id=REPO,
        folder_path=str(folder),
        path_in_repo="executor_preflight",
        commit_message="Audit nobody/seccomp execution isolation and exact-state reference parity before evaluating generated programs",
    )
    assert report["all_passed"], "Reference failures; inspect report and keep execution gate closed"


if __name__ == "__main__":
    main()