spatial-computing 0.6.1__tar.gz → 0.7.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.
- {spatial_computing-0.6.1/spatial_computing.egg-info → spatial_computing-0.7.0}/PKG-INFO +2 -2
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/README.md +1 -1
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/pyproject.toml +1 -1
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/__init__.py +1 -1
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/q/backends/__init__.py +2 -2
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/q/sim.py +24 -1
- {spatial_computing-0.6.1 → spatial_computing-0.7.0/spatial_computing.egg-info}/PKG-INFO +2 -2
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial_computing.egg-info/SOURCES.txt +2 -1
- spatial_computing-0.7.0/tests/test_v07.py +35 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/LICENSE +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/setup.cfg +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/ai/__init__.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/ai/kvcache.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/cli.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/compute/__init__.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/compute/cost.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/compute/detect.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/compute/monitor.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/compute/scheduler.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/compute/taskqueue.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/compute/worker.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/compute/workloads.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/core/__init__.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/core/energy.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/core/ledger.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/core/model.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/core/protocol.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/core/registry.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/holographic/__init__.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/holographic/cgh.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/holographic/model.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/intelligence/__init__.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/intelligence/predictor.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/memory/__init__.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/memory/fararray.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/memory/pageserver.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/memory/secure.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/memory/shared.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/memory/tiered.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/q/__init__.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/q/__main__.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/q/codegen.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/q/compiler.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/q/ir.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/q/lexer.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/q/parser.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/q/qir.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/q/runtime.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/runtime/__init__.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/runtime/envs.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/runtime/inspect.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/runtime/microvm.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/runtime/planner.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/runtime/runner.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/runtime/toolchain.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/scientific/__init__.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/scientific/jobs.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/simulation/__init__.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/simulation/heat.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial/simulation/nbody.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial_computing.egg-info/dependency_links.txt +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial_computing.egg-info/entry_points.txt +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial_computing.egg-info/requires.txt +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial_computing.egg-info/top_level.txt +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/tests/test_compute.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/tests/test_core.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/tests/test_domains.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/tests/test_engines.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/tests/test_memory.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/tests/test_q.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/tests/test_runtime.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/tests/test_v02.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.0}/tests/test_v03.py +0 -0
- {spatial_computing-0.6.1 → spatial_computing-0.7.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.
|
|
3
|
+
Version: 0.7.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
|
|
@@ -37,7 +37,7 @@ Dynamic: license-file
|
|
|
37
37
|
|
|
38
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.
|
|
39
39
|
|
|
40
|
-
> **Status: v0.
|
|
40
|
+
> **Status: v0.7.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).
|
|
41
41
|
|
|
42
42
|
[Français](README.fr.md)
|
|
43
43
|
|
|
@@ -4,7 +4,7 @@
|
|
|
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.
|
|
7
|
+
> **Status: v0.7.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
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "spatial-computing"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.7.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"
|
|
@@ -25,8 +25,8 @@ class StateVectorBackend(Backend):
|
|
|
25
25
|
"""Built-in NumPy simulator."""
|
|
26
26
|
name = "statevector"
|
|
27
27
|
|
|
28
|
-
def sample(self, c, shots, seed=None, noise: float = 0.0):
|
|
29
|
-
return sim.sample(c, shots, seed, noise=noise)
|
|
28
|
+
def sample(self, c, shots, seed=None, noise: float = 0.0, readout=None):
|
|
29
|
+
return sim.sample(c, shots, seed, noise=noise, readout=readout)
|
|
30
30
|
|
|
31
31
|
def expectation(self, c, pauli):
|
|
32
32
|
return sim.expectation(c, pauli)
|
|
@@ -105,6 +105,19 @@ def is_static(c: Circuit) -> bool:
|
|
|
105
105
|
return all(o.name not in ("measure", "reset") and not o.cond for o in c.ops)
|
|
106
106
|
|
|
107
107
|
|
|
108
|
+
def apply_readout(v: np.ndarray, n: int, p01: float, p10: float) -> np.ndarray:
|
|
109
|
+
"""Readout (measurement) error on an outcome distribution `v` of length 2^n.
|
|
110
|
+
p01 = P(read 1 | qubit was 0), p10 = P(read 0 | qubit was 1), independent per qubit.
|
|
111
|
+
Superconducting devices typically have p10 > p01 (the excited state decays while being read)."""
|
|
112
|
+
if not (0 <= p01 <= 1 and 0 <= p10 <= 1):
|
|
113
|
+
raise ValueError("readout probabilities must be in [0, 1]")
|
|
114
|
+
M = np.array([[1 - p01, p10], [p01, 1 - p10]])
|
|
115
|
+
t = v.reshape((2,) * n)
|
|
116
|
+
for ax in range(n):
|
|
117
|
+
t = np.moveaxis(np.tensordot(M, t, axes=(1, ax)), 0, ax)
|
|
118
|
+
return t.reshape(-1)
|
|
119
|
+
|
|
120
|
+
|
|
108
121
|
_NOISE_PAULIS = ("x", "y", "z")
|
|
109
122
|
|
|
110
123
|
|
|
@@ -174,7 +187,7 @@ def branch_distribution(c: Circuit, max_branches: int = 4096) -> np.ndarray | No
|
|
|
174
187
|
|
|
175
188
|
|
|
176
189
|
def sample(c: Circuit, shots: int, seed: int | None = None, dynamic: str = "branch",
|
|
177
|
-
noise: float = 0.0) -> dict[str, int]:
|
|
190
|
+
noise: float = 0.0, readout: tuple[float, float] | None = None) -> dict[str, int]:
|
|
178
191
|
"""dynamic="branch": exact branch enumeration then one multinomial draw (fast);
|
|
179
192
|
dynamic="shots" : one full simulation per shot (reference implementation)."""
|
|
180
193
|
rng = np.random.default_rng(seed)
|
|
@@ -190,6 +203,8 @@ def sample(c: Circuit, shots: int, seed: int | None = None, dynamic: str = "bran
|
|
|
190
203
|
p = branch_distribution(c)
|
|
191
204
|
if p is not None:
|
|
192
205
|
p = p / p.sum()
|
|
206
|
+
if readout: # the readout channel acts on the outcome distribution
|
|
207
|
+
p = apply_readout(p, n, *readout)
|
|
193
208
|
draws = rng.multinomial(shots, p)
|
|
194
209
|
return {format(i, f"0{n}b"): int(k) for i, k in enumerate(draws) if k}
|
|
195
210
|
counts: dict[str, int] = {}
|
|
@@ -198,6 +213,14 @@ def sample(c: Circuit, shots: int, seed: int | None = None, dynamic: str = "bran
|
|
|
198
213
|
i = int(rng.choice(len(p), p=p / p.sum()))
|
|
199
214
|
key = format(i, f"0{n}b")
|
|
200
215
|
counts[key] = counts.get(key, 0) + 1
|
|
216
|
+
if readout: # trajectory path: flip bits of each recorded shot
|
|
217
|
+
flipped: dict[str, int] = {}
|
|
218
|
+
for key, k in counts.items():
|
|
219
|
+
for _ in range(k):
|
|
220
|
+
bits = "".join(("1" if rng.random() < readout[0] else "0") if b == "0" else
|
|
221
|
+
("0" if rng.random() < readout[1] else "1") for b in key)
|
|
222
|
+
flipped[bits] = flipped.get(bits, 0) + 1
|
|
223
|
+
counts = flipped
|
|
201
224
|
return counts
|
|
202
225
|
|
|
203
226
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: spatial-computing
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.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
|
|
@@ -37,7 +37,7 @@ Dynamic: license-file
|
|
|
37
37
|
|
|
38
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.
|
|
39
39
|
|
|
40
|
-
> **Status: v0.
|
|
40
|
+
> **Status: v0.7.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).
|
|
41
41
|
|
|
42
42
|
[Français](README.fr.md)
|
|
43
43
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""v0.7: asymmetric readout error in the SPATIAL Q simulator."""
|
|
2
|
+
import numpy as np
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
from spatial.q import compile_kernel, parse, sim
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def test_readout_channel_is_exact_and_conserves_probability():
|
|
9
|
+
v = np.array([0.0, 0.0, 0.0, 1.0]) # |11> on 2 qubits
|
|
10
|
+
out = sim.apply_readout(v, 2, p01=0.0, p10=0.1)
|
|
11
|
+
assert out.sum() == pytest.approx(1.0)
|
|
12
|
+
assert out[3] == pytest.approx(0.81) and out[1] == pytest.approx(0.09) and out[2] == pytest.approx(0.09)
|
|
13
|
+
assert out[0] == pytest.approx(0.01)
|
|
14
|
+
z = sim.apply_readout(np.array([1.0, 0, 0, 0]), 2, p01=0.2, p10=0.5) # |00>: only p01 matters
|
|
15
|
+
assert z[0] == pytest.approx(0.64) and z.sum() == pytest.approx(1.0)
|
|
16
|
+
assert np.array_equal(sim.apply_readout(v, 2, 0.0, 0.0), v)
|
|
17
|
+
with pytest.raises(ValueError):
|
|
18
|
+
sim.apply_readout(v, 2, 1.5, 0.0)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def test_sampling_with_readout_matches_the_channel_and_is_asymmetric():
|
|
22
|
+
k = parse("quantum k() { qubit q[1]; x q[0]; } main { }").kernels["k"]
|
|
23
|
+
c, _ = compile_kernel(k, [])
|
|
24
|
+
shots = 40000
|
|
25
|
+
counts = sim.sample(c, shots, seed=3, readout=(0.0, 0.07))
|
|
26
|
+
assert counts["0"] / shots == pytest.approx(0.07, abs=0.006) # |1> decays toward 0 when read
|
|
27
|
+
zero, _ = compile_kernel(parse("quantum z() { qubit q[1]; h q[0]; h q[0]; } main { }").kernels["z"], [], opt=False)
|
|
28
|
+
assert sim.sample(zero, shots, seed=3, readout=(0.0, 0.07)) == {"0": shots} # |0> is untouched when p01 = 0
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def test_trajectory_path_applies_readout_too():
|
|
32
|
+
k = parse("quantum k() { qubit q[1]; x q[0]; } main { }").kernels["k"]
|
|
33
|
+
c, _ = compile_kernel(k, [])
|
|
34
|
+
counts = sim.sample(c, 6000, seed=4, noise=0.0001, readout=(0.0, 0.2))
|
|
35
|
+
assert counts.get("0", 0) / 6000 == pytest.approx(0.2, abs=0.02)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial_computing.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial_computing.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
{spatial_computing-0.6.1 → spatial_computing-0.7.0}/spatial_computing.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|