spatial-computing 0.5.0__tar.gz → 0.6.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. {spatial_computing-0.5.0/spatial_computing.egg-info → spatial_computing-0.6.0}/PKG-INFO +14 -5
  2. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/README.md +10 -4
  3. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/pyproject.toml +2 -1
  4. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/__init__.py +1 -1
  5. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/q/backends/__init__.py +53 -5
  6. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/q/runtime.py +2 -1
  7. {spatial_computing-0.5.0 → spatial_computing-0.6.0/spatial_computing.egg-info}/PKG-INFO +14 -5
  8. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial_computing.egg-info/requires.txt +4 -0
  9. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/tests/test_q.py +4 -2
  10. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/LICENSE +0 -0
  11. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/setup.cfg +0 -0
  12. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/ai/__init__.py +0 -0
  13. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/ai/kvcache.py +0 -0
  14. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/cli.py +0 -0
  15. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/compute/__init__.py +0 -0
  16. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/compute/cost.py +0 -0
  17. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/compute/detect.py +0 -0
  18. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/compute/monitor.py +0 -0
  19. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/compute/scheduler.py +0 -0
  20. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/compute/taskqueue.py +0 -0
  21. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/compute/worker.py +0 -0
  22. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/compute/workloads.py +0 -0
  23. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/core/__init__.py +0 -0
  24. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/core/energy.py +0 -0
  25. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/core/ledger.py +0 -0
  26. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/core/model.py +0 -0
  27. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/core/protocol.py +0 -0
  28. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/core/registry.py +0 -0
  29. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/holographic/__init__.py +0 -0
  30. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/holographic/cgh.py +0 -0
  31. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/holographic/model.py +0 -0
  32. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/intelligence/__init__.py +0 -0
  33. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/intelligence/predictor.py +0 -0
  34. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/memory/__init__.py +0 -0
  35. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/memory/fararray.py +0 -0
  36. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/memory/pageserver.py +0 -0
  37. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/memory/secure.py +0 -0
  38. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/memory/shared.py +0 -0
  39. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/memory/tiered.py +0 -0
  40. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/q/__init__.py +0 -0
  41. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/q/__main__.py +0 -0
  42. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/q/codegen.py +0 -0
  43. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/q/compiler.py +0 -0
  44. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/q/ir.py +0 -0
  45. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/q/lexer.py +0 -0
  46. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/q/parser.py +0 -0
  47. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/q/qir.py +0 -0
  48. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/q/sim.py +0 -0
  49. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/runtime/__init__.py +0 -0
  50. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/runtime/envs.py +0 -0
  51. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/runtime/inspect.py +0 -0
  52. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/runtime/microvm.py +0 -0
  53. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/runtime/planner.py +0 -0
  54. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/runtime/runner.py +0 -0
  55. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/runtime/toolchain.py +0 -0
  56. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/scientific/__init__.py +0 -0
  57. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/scientific/jobs.py +0 -0
  58. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/simulation/__init__.py +0 -0
  59. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/simulation/heat.py +0 -0
  60. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial/simulation/nbody.py +0 -0
  61. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial_computing.egg-info/SOURCES.txt +0 -0
  62. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial_computing.egg-info/dependency_links.txt +0 -0
  63. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial_computing.egg-info/entry_points.txt +0 -0
  64. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/spatial_computing.egg-info/top_level.txt +0 -0
  65. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/tests/test_compute.py +0 -0
  66. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/tests/test_core.py +0 -0
  67. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/tests/test_domains.py +0 -0
  68. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/tests/test_engines.py +0 -0
  69. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/tests/test_memory.py +0 -0
  70. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/tests/test_runtime.py +0 -0
  71. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/tests/test_v02.py +0 -0
  72. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/tests/test_v03.py +0 -0
  73. {spatial_computing-0.5.0 → spatial_computing-0.6.0}/tests/test_v05.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: spatial-computing
3
- Version: 0.5.0
3
+ Version: 0.6.0
4
4
  Summary: Spatial Computing: open-source infrastructure efficiency toolkit. Measure, decide, prove (compute, tiered memory, runtime routing, hybrid quantum language)
5
5
  Author: Spatial Computing contributors
6
6
  License-Expression: Apache-2.0
@@ -24,6 +24,9 @@ Requires-Dist: qiskit-qasm3-import>=0.5; extra == "quantum"
24
24
  Requires-Dist: pyqir>=0.10; extra == "quantum"
25
25
  Provides-Extra: build
26
26
  Requires-Dist: ziglang>=0.13; extra == "build"
27
+ Provides-Extra: qpu
28
+ Requires-Dist: qiskit>=2.0; extra == "qpu"
29
+ Requires-Dist: qiskit-ibm-runtime>=0.40; extra == "qpu"
27
30
  Provides-Extra: dev
28
31
  Requires-Dist: pytest>=8; extra == "dev"
29
32
  Dynamic: license-file
@@ -34,19 +37,25 @@ Dynamic: license-file
34
37
 
35
38
  Spatial Computing chooses where and how a workload should run from measurements, and claims a gain only when it is measured. It does not add RAM, cores or GPUs: it compares execution strategies on the hardware you have, trades one resource for another in numbers, and says plainly what it cannot do.
36
39
 
37
- > **Status: v0.5.0, early-stage open-source toolkit.** Everything here was built and measured on a single 2017 MacBook Pro (Intel i7-7660U, 2 cores, 16 GB). Nothing has been proven on a second machine, a data-center GPU or a real quantum computer. See [Limitations](docs/LIMITATIONS.md) and the [site](https://spatial-computing-ecru.vercel.app).
40
+ > **Status: v0.6.0, early-stage open-source toolkit.** Everything here was built and measured on a single 2017 MacBook Pro (Intel i7-7660U, 2 cores, 16 GB). Nothing has been proven on a second machine, a data-center GPU or a real quantum computer. See [Limitations](docs/LIMITATIONS.md) and the [site](https://spatial-computing-ecru.vercel.app).
38
41
 
39
42
  [Français](README.fr.md)
40
43
 
41
44
  ## Install
42
45
 
43
- Python 3.10 or newer. Not on PyPI yet: install from source.
46
+ Python 3.10 or newer.
44
47
 
45
48
  ```bash
46
- git clone https://github.com/abraham1116/spatial-computing && cd spatial-computing
47
49
  python3 -m venv .venv && source .venv/bin/activate
48
- pip install -e ".[quantum,dev]"
50
+ pip install "spatial-computing[quantum]"
49
51
  spatial audit
52
+ ```
53
+
54
+ From source, to develop:
55
+
56
+ ```bash
57
+ git clone https://github.com/abraham1116/spatial-computing && cd spatial-computing
58
+ pip install -e ".[quantum,dev]"
50
59
  pytest
51
60
  ```
52
61
 
@@ -4,19 +4,25 @@
4
4
 
5
5
  Spatial Computing chooses where and how a workload should run from measurements, and claims a gain only when it is measured. It does not add RAM, cores or GPUs: it compares execution strategies on the hardware you have, trades one resource for another in numbers, and says plainly what it cannot do.
6
6
 
7
- > **Status: v0.5.0, early-stage open-source toolkit.** Everything here was built and measured on a single 2017 MacBook Pro (Intel i7-7660U, 2 cores, 16 GB). Nothing has been proven on a second machine, a data-center GPU or a real quantum computer. See [Limitations](docs/LIMITATIONS.md) and the [site](https://spatial-computing-ecru.vercel.app).
7
+ > **Status: v0.6.0, early-stage open-source toolkit.** Everything here was built and measured on a single 2017 MacBook Pro (Intel i7-7660U, 2 cores, 16 GB). Nothing has been proven on a second machine, a data-center GPU or a real quantum computer. See [Limitations](docs/LIMITATIONS.md) and the [site](https://spatial-computing-ecru.vercel.app).
8
8
 
9
9
  [Français](README.fr.md)
10
10
 
11
11
  ## Install
12
12
 
13
- Python 3.10 or newer. Not on PyPI yet: install from source.
13
+ Python 3.10 or newer.
14
14
 
15
15
  ```bash
16
- git clone https://github.com/abraham1116/spatial-computing && cd spatial-computing
17
16
  python3 -m venv .venv && source .venv/bin/activate
18
- pip install -e ".[quantum,dev]"
17
+ pip install "spatial-computing[quantum]"
19
18
  spatial audit
19
+ ```
20
+
21
+ From source, to develop:
22
+
23
+ ```bash
24
+ git clone https://github.com/abraham1116/spatial-computing && cd spatial-computing
25
+ pip install -e ".[quantum,dev]"
20
26
  pytest
21
27
  ```
22
28
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "spatial-computing"
7
- version = "0.5.0"
7
+ version = "0.6.0"
8
8
  description = "Spatial Computing: open-source infrastructure efficiency toolkit. Measure, decide, prove (compute, tiered memory, runtime routing, hybrid quantum language)"
9
9
  readme = "README.md"
10
10
  license = "Apache-2.0"
@@ -17,6 +17,7 @@ dependencies = ["numpy>=1.26,<2.2", "psutil>=5.9", "numba>=0.59,<0.62", "lz4>=4.
17
17
  [project.optional-dependencies]
18
18
  quantum = ["qiskit>=2.0", "qiskit-aer>=0.17", "qiskit-qasm3-import>=0.5", "pyqir>=0.10"]
19
19
  build = ["ziglang>=0.13"]
20
+ qpu = ["qiskit>=2.0", "qiskit-ibm-runtime>=0.40"]
20
21
  dev = ["pytest>=8"]
21
22
 
22
23
  [project.urls]
@@ -3,4 +3,4 @@
3
3
  Status of every engine is declared in spatial.core.registry and must be backed
4
4
  by a test or benchmark before being set to OPERATIONAL.
5
5
  """
6
- __version__ = "0.5.0"
6
+ __version__ = "0.6.0"
@@ -103,16 +103,64 @@ class Qasm3Export(Backend):
103
103
  raise BackendUnavailable("qasm3 is an export target; use Circuit.to_qasm3()")
104
104
 
105
105
 
106
+ def _ibm_token() -> str | None:
107
+ import os
108
+ from pathlib import Path
109
+ tok = os.environ.get("IBM_QUANTUM_TOKEN")
110
+ if tok:
111
+ return tok
112
+ f = Path.home() / ".spatial" / "secrets.env"
113
+ if f.exists():
114
+ for line in f.read_text().splitlines():
115
+ if line.startswith("IBM_QUANTUM_TOKEN="):
116
+ return line.split("=", 1)[1].strip() or None
117
+ return None
118
+
119
+
106
120
  class QpuBackend(Backend):
107
- """Real quantum hardware. No provider credentials are configured in this prototype, so
108
- this backend refuses to run instead of silently falling back to a simulator."""
121
+ """Real quantum hardware through IBM Quantum (qiskit-ibm-runtime, SamplerV2).
122
+
123
+ Needs: the `qiskit-ibm-runtime` package, a token in IBM_QUANTUM_TOKEN (or
124
+ ~/.spatial/secrets.env) and an IBM Quantum instance on the account. When any of these is
125
+ missing it raises BackendUnavailable with the real reason; it never falls back to a
126
+ simulator. Jobs wait in the provider's queue: a call can block for a long time.
127
+ """
109
128
  name = "qpu"
110
129
  kind = "qpu"
111
130
 
131
+ def __init__(self):
132
+ self.last_job: dict | None = None
133
+
134
+ def _service(self):
135
+ try:
136
+ from qiskit_ibm_runtime import QiskitRuntimeService
137
+ except ImportError:
138
+ raise BackendUnavailable("qiskit-ibm-runtime is not installed (pip install qiskit-ibm-runtime)")
139
+ tok = _ibm_token()
140
+ if not tok:
141
+ raise BackendUnavailable(
142
+ "no QPU provider configured: set IBM_QUANTUM_TOKEN or add it to ~/.spatial/secrets.env. "
143
+ "The circuit can be exported with to_qasm3() or to_qir().")
144
+ try:
145
+ return QiskitRuntimeService(channel="ibm_quantum_platform", token=tok)
146
+ except Exception as e:
147
+ raise BackendUnavailable(f"IBM Quantum refused the account: {type(e).__name__}: {str(e)[:200]}")
148
+
112
149
  def sample(self, c, shots, seed=None):
113
- raise BackendUnavailable(
114
- "no QPU provider configured (needs an account/API token with IBM Quantum, IonQ, "
115
- "Quantinuum, AWS Braket...). The circuit can be exported with to_qasm3().")
150
+ from qiskit import transpile
151
+ from qiskit_ibm_runtime import SamplerV2
152
+ svc = self._service()
153
+ try:
154
+ backend = svc.least_busy(operational=True, simulator=False, min_num_qubits=c.n_qubits)
155
+ except Exception as e:
156
+ raise BackendUnavailable(f"no real backend available for {c.n_qubits} qubits: {str(e)[:200]}")
157
+ qc = transpile(to_qiskit(c), backend, optimization_level=1)
158
+ job = SamplerV2(mode=backend).run([qc], shots=shots)
159
+ res = job.result()[0]
160
+ counts = res.data.c.get_counts()
161
+ self.last_job = {"backend": backend.name, "job_id": job.job_id(), "shots": shots,
162
+ "physical_qubits": backend.num_qubits}
163
+ return {k: int(v) for k, v in counts.items()}
116
164
 
117
165
 
118
166
  def get(name: str) -> Backend:
@@ -82,7 +82,8 @@ class Runtime:
82
82
  counts = b.sample(c, shots, self.seed, noise=self.noise) if self.noise else b.sample(c, shots, self.seed)
83
83
  self.trace.append({"op": "sample", "kernel": name, "backend": b.name, "why": self._last_reason,
84
84
  "shots": shots, "wall_s": time.perf_counter() - t0, "resources": est.to_dict(),
85
- "optimizer": info, **({"noise": self.noise} if self.noise else {})})
85
+ "optimizer": info, **({"noise": self.noise} if self.noise else {}),
86
+ **({"qpu_job": b.last_job} if getattr(b, "last_job", None) else {})})
86
87
  return counts
87
88
 
88
89
  def _expect(self, pauli, name, args, backend):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: spatial-computing
3
- Version: 0.5.0
3
+ Version: 0.6.0
4
4
  Summary: Spatial Computing: open-source infrastructure efficiency toolkit. Measure, decide, prove (compute, tiered memory, runtime routing, hybrid quantum language)
5
5
  Author: Spatial Computing contributors
6
6
  License-Expression: Apache-2.0
@@ -24,6 +24,9 @@ Requires-Dist: qiskit-qasm3-import>=0.5; extra == "quantum"
24
24
  Requires-Dist: pyqir>=0.10; extra == "quantum"
25
25
  Provides-Extra: build
26
26
  Requires-Dist: ziglang>=0.13; extra == "build"
27
+ Provides-Extra: qpu
28
+ Requires-Dist: qiskit>=2.0; extra == "qpu"
29
+ Requires-Dist: qiskit-ibm-runtime>=0.40; extra == "qpu"
27
30
  Provides-Extra: dev
28
31
  Requires-Dist: pytest>=8; extra == "dev"
29
32
  Dynamic: license-file
@@ -34,19 +37,25 @@ Dynamic: license-file
34
37
 
35
38
  Spatial Computing chooses where and how a workload should run from measurements, and claims a gain only when it is measured. It does not add RAM, cores or GPUs: it compares execution strategies on the hardware you have, trades one resource for another in numbers, and says plainly what it cannot do.
36
39
 
37
- > **Status: v0.5.0, early-stage open-source toolkit.** Everything here was built and measured on a single 2017 MacBook Pro (Intel i7-7660U, 2 cores, 16 GB). Nothing has been proven on a second machine, a data-center GPU or a real quantum computer. See [Limitations](docs/LIMITATIONS.md) and the [site](https://spatial-computing-ecru.vercel.app).
40
+ > **Status: v0.6.0, early-stage open-source toolkit.** Everything here was built and measured on a single 2017 MacBook Pro (Intel i7-7660U, 2 cores, 16 GB). Nothing has been proven on a second machine, a data-center GPU or a real quantum computer. See [Limitations](docs/LIMITATIONS.md) and the [site](https://spatial-computing-ecru.vercel.app).
38
41
 
39
42
  [Français](README.fr.md)
40
43
 
41
44
  ## Install
42
45
 
43
- Python 3.10 or newer. Not on PyPI yet: install from source.
46
+ Python 3.10 or newer.
44
47
 
45
48
  ```bash
46
- git clone https://github.com/abraham1116/spatial-computing && cd spatial-computing
47
49
  python3 -m venv .venv && source .venv/bin/activate
48
- pip install -e ".[quantum,dev]"
50
+ pip install "spatial-computing[quantum]"
49
51
  spatial audit
52
+ ```
53
+
54
+ From source, to develop:
55
+
56
+ ```bash
57
+ git clone https://github.com/abraham1116/spatial-computing && cd spatial-computing
58
+ pip install -e ".[quantum,dev]"
50
59
  pytest
51
60
  ```
52
61
 
@@ -10,6 +10,10 @@ ziglang>=0.13
10
10
  [dev]
11
11
  pytest>=8
12
12
 
13
+ [qpu]
14
+ qiskit>=2.0
15
+ qiskit-ibm-runtime>=0.40
16
+
13
17
  [quantum]
14
18
  qiskit>=2.0
15
19
  qiskit-aer>=0.17
@@ -169,8 +169,10 @@ def test_classical_distributed_example_uses_worker_when_told():
169
169
  assert {t["where"] for t in rt.trace if t["op"] == "workload"} == {"cpu", "worker"}
170
170
 
171
171
 
172
- def test_qpu_backend_refuses_instead_of_faking():
173
- with pytest.raises(BackendUnavailable, match="no QPU provider"):
172
+ def test_qpu_backend_refuses_instead_of_faking(monkeypatch, tmp_path):
173
+ monkeypatch.delenv("IBM_QUANTUM_TOKEN", raising=False)
174
+ monkeypatch.setattr("pathlib.Path.home", lambda: tmp_path) # no secrets file either
175
+ with pytest.raises(BackendUnavailable, match="no QPU provider|not installed"):
174
176
  _run("quantum k() { qubit q[1]; h q[0]; } main { let c = sample k() shots 10 on qpu; }")
175
177
 
176
178