Instructions to use itsalissonsilva/QuantumCoder-9B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use itsalissonsilva/QuantumCoder-9B with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3.5-9B") model = PeftModel.from_pretrained(base_model, "itsalissonsilva/QuantumCoder-9B") - Notebooks
- Google Colab
- Kaggle
Audit nobody/seccomp execution isolation and exact-state reference parity before evaluating generated programs
e0897b0 verified Download executor_preflight/train_quantum_exec_preflight_pilot.py from itsalissonsilva/QuantumCoder-9B: direct link, hf CLI and curl.
- Browser
- Download file 3.78 kB
-
https://huggingface.co/itsalissonsilva/QuantumCoder-9B/resolve/97bf11cde2ef2aeb43345a0da7eab3d8ea27993a/executor_preflight/train_quantum_exec_preflight_pilot.py
- Command line
-
hf download hf://itsalissonsilva/QuantumCoder-9B@97bf11cde2ef2aeb43345a0da7eab3d8ea27993a/executor_preflight/train_quantum_exec_preflight_pilot.py
-
curl -L -o train_quantum_exec_preflight_pilot.py https://huggingface.co/itsalissonsilva/QuantumCoder-9B/resolve/97bf11cde2ef2aeb43345a0da7eab3d8ea27993a/executor_preflight/train_quantum_exec_preflight_pilot.py
3.78 kB
| """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() | |