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
Verify saved quantum adapter and intended inference helper reproduce fixed validation generations exactly
Browse files
helper_verification/train_quantum_helper_pilot.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Reload exact saved quantum weights through the intended inference helper."""
|
| 2 |
+
import importlib.util
|
| 3 |
+
import json
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
from huggingface_hub import HfApi,hf_hub_download
|
| 6 |
+
|
| 7 |
+
REPO="itsalissonsilva/QuantumCoder-9B"
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def main():
|
| 11 |
+
api=HfApi();revision=api.model_info(REPO).sha
|
| 12 |
+
assert api.model_info(REPO).private
|
| 13 |
+
def get(path):
|
| 14 |
+
return Path(hf_hub_download(REPO,path,revision=revision))
|
| 15 |
+
report=json.loads(get("curriculum_v2_run/generation_report.json").read_text())
|
| 16 |
+
expected=report["conditions"]["adapted"][:8]
|
| 17 |
+
assert len(expected)==8
|
| 18 |
+
rows={r["id"]:r for r in json.loads(get("curriculum_v2/rows.json").read_text())}
|
| 19 |
+
source=get("release_candidate/quantum.py")
|
| 20 |
+
spec=importlib.util.spec_from_file_location("quantum_release_helper",source)
|
| 21 |
+
helper=importlib.util.module_from_spec(spec);spec.loader.exec_module(helper)
|
| 22 |
+
assert helper.BASE_REVISION==report["base_revision"]
|
| 23 |
+
coder=helper.QuantumCoder(adapter=REPO,revision=revision,subfolder="curriculum_v2_run/adapter")
|
| 24 |
+
circuits=[dict(framework=rows[r["id"]]["framework"],qubits=rows[r["id"]]["qubits"],
|
| 25 |
+
operations=json.loads(rows[r["id"]]["operations_json"])) for r in expected]
|
| 26 |
+
actual=coder.generate(circuits)
|
| 27 |
+
records=[]
|
| 28 |
+
for old,new in zip(expected,actual,strict=True):
|
| 29 |
+
fields=["program","generated_tokens","eos_observed","at_token_cap"]
|
| 30 |
+
records.append(dict(id=old["id"],exact_match=all(old[k]==new[k] for k in fields),
|
| 31 |
+
field_matches={k:old[k]==new[k] for k in fields}))
|
| 32 |
+
result=dict(source_revision=revision,base_revision=helper.BASE_REVISION,checks=records,
|
| 33 |
+
all_passed=all(r["exact_match"] for r in records),batch_size=8,
|
| 34 |
+
scope="Reload/helper parity on first eight fixed validation generations; independent full held-out execution is separate")
|
| 35 |
+
output=Path("helper_verification");output.mkdir(exist_ok=True)
|
| 36 |
+
(output/"verification.json").write_text(json.dumps(result,indent=2))
|
| 37 |
+
(output/"train_quantum_helper_pilot.py").write_bytes(Path(__file__).read_bytes())
|
| 38 |
+
api.upload_folder(repo_id=REPO,folder_path=str(output),path_in_repo="helper_verification",
|
| 39 |
+
commit_message="Verify saved quantum adapter and intended inference helper reproduce fixed validation generations exactly")
|
| 40 |
+
print(json.dumps(result),flush=True)
|
| 41 |
+
assert result["all_passed"], "Helper/reload mismatch; keep release gate closed"
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
if __name__=="__main__":
|
| 45 |
+
main()
|
helper_verification/verification.json
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"source_revision": "6fbf1f1b961cb02897ed9fd96f2602bbc6d3f405",
|
| 3 |
+
"base_revision": "c202236235762e1c871ad0ccb60c8ee5ba337b9a",
|
| 4 |
+
"checks": [
|
| 5 |
+
{
|
| 6 |
+
"id": "v2-f7cd461a7d0b643d3bcb6643-qiskit",
|
| 7 |
+
"exact_match": true,
|
| 8 |
+
"field_matches": {
|
| 9 |
+
"program": true,
|
| 10 |
+
"generated_tokens": true,
|
| 11 |
+
"eos_observed": true,
|
| 12 |
+
"at_token_cap": true
|
| 13 |
+
}
|
| 14 |
+
},
|
| 15 |
+
{
|
| 16 |
+
"id": "v2-f7cd461a7d0b643d3bcb6643-pennylane",
|
| 17 |
+
"exact_match": true,
|
| 18 |
+
"field_matches": {
|
| 19 |
+
"program": true,
|
| 20 |
+
"generated_tokens": true,
|
| 21 |
+
"eos_observed": true,
|
| 22 |
+
"at_token_cap": true
|
| 23 |
+
}
|
| 24 |
+
},
|
| 25 |
+
{
|
| 26 |
+
"id": "v2-f7cd461a7d0b643d3bcb6643-cirq",
|
| 27 |
+
"exact_match": true,
|
| 28 |
+
"field_matches": {
|
| 29 |
+
"program": true,
|
| 30 |
+
"generated_tokens": true,
|
| 31 |
+
"eos_observed": true,
|
| 32 |
+
"at_token_cap": true
|
| 33 |
+
}
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"id": "v2-3ef05edd57d886e02a04c3e3-qiskit",
|
| 37 |
+
"exact_match": true,
|
| 38 |
+
"field_matches": {
|
| 39 |
+
"program": true,
|
| 40 |
+
"generated_tokens": true,
|
| 41 |
+
"eos_observed": true,
|
| 42 |
+
"at_token_cap": true
|
| 43 |
+
}
|
| 44 |
+
},
|
| 45 |
+
{
|
| 46 |
+
"id": "v2-3ef05edd57d886e02a04c3e3-pennylane",
|
| 47 |
+
"exact_match": true,
|
| 48 |
+
"field_matches": {
|
| 49 |
+
"program": true,
|
| 50 |
+
"generated_tokens": true,
|
| 51 |
+
"eos_observed": true,
|
| 52 |
+
"at_token_cap": true
|
| 53 |
+
}
|
| 54 |
+
},
|
| 55 |
+
{
|
| 56 |
+
"id": "v2-3ef05edd57d886e02a04c3e3-cirq",
|
| 57 |
+
"exact_match": true,
|
| 58 |
+
"field_matches": {
|
| 59 |
+
"program": true,
|
| 60 |
+
"generated_tokens": true,
|
| 61 |
+
"eos_observed": true,
|
| 62 |
+
"at_token_cap": true
|
| 63 |
+
}
|
| 64 |
+
},
|
| 65 |
+
{
|
| 66 |
+
"id": "v2-5c8f56fe37ae555f98c27c34-qiskit",
|
| 67 |
+
"exact_match": true,
|
| 68 |
+
"field_matches": {
|
| 69 |
+
"program": true,
|
| 70 |
+
"generated_tokens": true,
|
| 71 |
+
"eos_observed": true,
|
| 72 |
+
"at_token_cap": true
|
| 73 |
+
}
|
| 74 |
+
},
|
| 75 |
+
{
|
| 76 |
+
"id": "v2-5c8f56fe37ae555f98c27c34-pennylane",
|
| 77 |
+
"exact_match": true,
|
| 78 |
+
"field_matches": {
|
| 79 |
+
"program": true,
|
| 80 |
+
"generated_tokens": true,
|
| 81 |
+
"eos_observed": true,
|
| 82 |
+
"at_token_cap": true
|
| 83 |
+
}
|
| 84 |
+
}
|
| 85 |
+
],
|
| 86 |
+
"all_passed": true,
|
| 87 |
+
"batch_size": 8,
|
| 88 |
+
"scope": "Reload/helper parity on first eight fixed validation generations; independent full held-out execution is separate"
|
| 89 |
+
}
|