spatial-computing 0.29.0__tar.gz → 0.31.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.29.0 → spatial_computing-0.31.0}/PKG-INFO +2 -2
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/README.md +1 -1
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/pyproject.toml +1 -1
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/__init__.py +1 -1
- spatial_computing-0.31.0/spatial/attest.py +159 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/cli.py +105 -1
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/market/__init__.py +1 -0
- spatial_computing-0.31.0/spatial/market/history.py +64 -0
- spatial_computing-0.31.0/spatial/verify/__init__.py +7 -0
- spatial_computing-0.31.0/spatial/verify/screen.py +155 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial_computing.egg-info/PKG-INFO +2 -2
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial_computing.egg-info/SOURCES.txt +7 -0
- spatial_computing-0.31.0/tests/test_attest.py +144 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/tests/test_market.py +54 -0
- spatial_computing-0.31.0/tests/test_netfaults.py +192 -0
- spatial_computing-0.31.0/tests/test_screen.py +194 -0
- spatial_computing-0.31.0/tests/test_site_claims.py +46 -0
- spatial_computing-0.29.0/spatial/verify/__init__.py +0 -5
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/LICENSE +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/setup.cfg +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/ai/__init__.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/ai/kvcache.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/ai/llm.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/automotive/__init__.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/automotive/placement.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/compute/__init__.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/compute/cost.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/compute/detect.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/compute/monitor.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/compute/scheduler.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/compute/taskqueue.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/compute/worker.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/compute/workloads.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/core/__init__.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/core/auth.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/core/energy.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/core/ledger.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/core/model.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/core/protocol.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/core/registry.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/fabric/__init__.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/fabric/cuda.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/fabric/devices.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/fabric/metal.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/fabric/metal_mandel.swift +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/fabric/metal_run.swift +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/fleet/__init__.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/fleet/agent.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/fleet/alerts.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/fleet/dashboard.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/fleet/ha.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/fleet/hub.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/intelligence/__init__.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/intelligence/predictor.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/interconnect/__init__.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/interconnect/collectives.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/interconnect/comm.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/interconnect/model.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/interconnect/tasks.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/kernel/__init__.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/kernel/dsl.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/kernel/library.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/market/vast.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/memory/__init__.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/memory/fararray.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/memory/pageserver.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/memory/secure.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/memory/shared.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/memory/tiered.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/platform/__init__.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/platform/billing.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/platform/db.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/platform/invoice_rules.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/platform/mailer.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/platform/oidc.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/platform/pdf.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/platform/qr.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/platform/security.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/platform/server.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/platform/service.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/platform/static/app.js +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/platform/static/fonts/DMMono-normal-400.woff2 +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/platform/static/fonts/DMMono-normal-500.woff2 +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/platform/static/fonts/InstrumentSerif-italic-400.woff2 +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/platform/static/fonts/InstrumentSerif-normal-400.woff2 +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/platform/static/fonts/Inter-normal-400.woff2 +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/platform/static/fonts/Inter-normal-500.woff2 +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/platform/static/fonts/Inter-normal-600.woff2 +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/platform/static/fonts.css +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/platform/static/index.html +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/platform/static/logo.svg +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/platform/static/style.css +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/platform/totp.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/platform/ubl.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/platform/vat.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/runtime/__init__.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/runtime/arch.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/runtime/desktop/Dockerfile +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/runtime/desktop/__init__.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/runtime/desktop/start.sh +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/runtime/envs.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/runtime/inspect.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/runtime/microvm.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/runtime/planner.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/runtime/runner.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/runtime/toolchain.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/unified/__init__.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/unified/model.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/unified/planner.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/unified/providers.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial/verify/consensus.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial_computing.egg-info/dependency_links.txt +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial_computing.egg-info/entry_points.txt +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial_computing.egg-info/requires.txt +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial_computing.egg-info/top_level.txt +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/tests/test_auth.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/tests/test_automotive.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/tests/test_compute.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/tests/test_core.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/tests/test_dashboard.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/tests/test_domains.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/tests/test_engines.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/tests/test_fabric.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/tests/test_fleet.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/tests/test_ha.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/tests/test_hardening.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/tests/test_interconnect.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/tests/test_kernel.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/tests/test_memory.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/tests/test_platform.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/tests/test_platform2.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/tests/test_qr.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/tests/test_quorum.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/tests/test_real_servers.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/tests/test_runtime.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/tests/test_sso.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/tests/test_unified.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/tests/test_v02.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/tests/test_v03.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/tests/test_v05.py +0 -0
- {spatial_computing-0.29.0 → spatial_computing-0.31.0}/tests/test_verify.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: spatial-computing
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.31.0
|
|
4
4
|
Summary: Spatial Computing: open-source infrastructure efficiency toolkit. Measure, decide, prove (compute, tiered memory, runtime routing, fleet)
|
|
5
5
|
Author: Spatial Computing contributors
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -103,7 +103,7 @@ st.put(0, b"..." * 1000); st.get(0); print(st.stats())
|
|
|
103
103
|
| Portable kernels (one source, CPU/Metal/CUDA/HIP/Triton; market-vertical presets) | first components | `tests/test_kernel.py`, `benchmarks/bench_kernel.py` |
|
|
104
104
|
| Live GPU market prices (`spatial market`, read-only, no account) | first components | `tests/test_market.py`, [docs/MARKET.md](docs/MARKET.md) |
|
|
105
105
|
| In-vehicle multi-chip placement (`spatial automotive`, declared chip specs, no real silicon) | first components | `tests/test_automotive.py`, [docs/AUTOMOTIVE.md](docs/AUTOMOTIVE.md) |
|
|
106
|
-
| Redundant-execution verification (`spatial verify`, not cryptographic, see limits) | first components | `tests/test_verify.py`, [docs/VERIFY.md](docs/VERIFY.md) |
|
|
106
|
+
| Redundant-execution verification, fleet screening and signed attestations (`spatial verify`, `spatial screen`, `spatial attest`; faults injected in tests, not cryptographic proof, see limits) | first components | `tests/test_verify.py`, `tests/test_screen.py`, `tests/test_attest.py`, [docs/VERIFY.md](docs/VERIFY.md) |
|
|
107
107
|
| AI, Intelligence | first components (toy model) | `tests/test_engines.py`, `tests/test_domains.py` |
|
|
108
108
|
|
|
109
109
|
Measured on the reference machine (AC power): Numba JIT ×31.6 over pure Python with an identical result; 0.88 s to boot an isolated Linux micro-VM on macOS; −75 % local RAM for a skewed-access dataset at 107× the mean access latency. Full table and conditions: [docs/RESULTATS.fr.md](docs/RESULTATS.fr.md).
|
|
@@ -77,7 +77,7 @@ st.put(0, b"..." * 1000); st.get(0); print(st.stats())
|
|
|
77
77
|
| Portable kernels (one source, CPU/Metal/CUDA/HIP/Triton; market-vertical presets) | first components | `tests/test_kernel.py`, `benchmarks/bench_kernel.py` |
|
|
78
78
|
| Live GPU market prices (`spatial market`, read-only, no account) | first components | `tests/test_market.py`, [docs/MARKET.md](docs/MARKET.md) |
|
|
79
79
|
| In-vehicle multi-chip placement (`spatial automotive`, declared chip specs, no real silicon) | first components | `tests/test_automotive.py`, [docs/AUTOMOTIVE.md](docs/AUTOMOTIVE.md) |
|
|
80
|
-
| Redundant-execution verification (`spatial verify`, not cryptographic, see limits) | first components | `tests/test_verify.py`, [docs/VERIFY.md](docs/VERIFY.md) |
|
|
80
|
+
| Redundant-execution verification, fleet screening and signed attestations (`spatial verify`, `spatial screen`, `spatial attest`; faults injected in tests, not cryptographic proof, see limits) | first components | `tests/test_verify.py`, `tests/test_screen.py`, `tests/test_attest.py`, [docs/VERIFY.md](docs/VERIFY.md) |
|
|
81
81
|
| AI, Intelligence | first components (toy model) | `tests/test_engines.py`, `tests/test_domains.py` |
|
|
82
82
|
|
|
83
83
|
Measured on the reference machine (AC power): Numba JIT ×31.6 over pure Python with an identical result; 0.88 s to boot an isolated Linux micro-VM on macOS; −75 % local RAM for a skewed-access dataset at 107× the mean access latency. Full table and conditions: [docs/RESULTATS.fr.md](docs/RESULTATS.fr.md).
|
|
@@ -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.31.0"
|
|
8
8
|
description = "Spatial Computing: open-source infrastructure efficiency toolkit. Measure, decide, prove (compute, tiered memory, runtime routing, fleet)"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "Apache-2.0"
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"""Signed health attestations with a tamper-evident history.
|
|
2
|
+
|
|
3
|
+
Turns a `spatial screen` result into a small signed JSON document and chains the documents in an append-only file:
|
|
4
|
+
each report carries the hash of the previous one, so removing or editing an old report breaks every later link.
|
|
5
|
+
|
|
6
|
+
What a signature proves, and what it does not:
|
|
7
|
+
- It proves the document was not changed after signing and that whoever signed held the private key.
|
|
8
|
+
- It does NOT prove who that is. The public key travels inside the document, so anyone can sign a forged report with a
|
|
9
|
+
key of their own; a verifier must pin the expected public key (`expected_pubkey`) obtained another way.
|
|
10
|
+
- It does NOT make the test meaningful. The report says what was run; known-answer screening misses most
|
|
11
|
+
data-dependent silent corruption (ByteDance, OSDI 2026), and every report carries that limit in its own text.
|
|
12
|
+
"""
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import hashlib
|
|
16
|
+
import json
|
|
17
|
+
import os
|
|
18
|
+
import platform
|
|
19
|
+
import time
|
|
20
|
+
from dataclasses import dataclass
|
|
21
|
+
from pathlib import Path
|
|
22
|
+
|
|
23
|
+
from cryptography.exceptions import InvalidSignature
|
|
24
|
+
from cryptography.hazmat.primitives import serialization
|
|
25
|
+
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey, Ed25519PublicKey
|
|
26
|
+
|
|
27
|
+
SCHEMA = "spatial-attestation/1"
|
|
28
|
+
DEFAULT_KEY = Path.home() / ".spatial" / "attest.key"
|
|
29
|
+
LIMITS = (
|
|
30
|
+
"Known-answer screening is a first filter: silent data corruption is data- and unit-specific, and synthetic "
|
|
31
|
+
"microbenchmarks miss over 60% of defective GPUs in ByteDance's production study (OSDI 2026).",
|
|
32
|
+
"Executors that share one physical device are not independent: they can agree with each other and all be wrong.",
|
|
33
|
+
"A signature shows integrity, not identity: pin the expected public key.",
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class AttestError(Exception):
|
|
38
|
+
pass
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@dataclass(frozen=True)
|
|
42
|
+
class Verified:
|
|
43
|
+
ok: bool
|
|
44
|
+
key_pinned: bool
|
|
45
|
+
reason: str
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _canon(obj) -> bytes:
|
|
49
|
+
return json.dumps(obj, sort_keys=True, separators=(",", ":")).encode()
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def _sha(obj) -> str:
|
|
53
|
+
return hashlib.sha256(_canon(obj)).hexdigest()
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def init_key(path: str | Path = DEFAULT_KEY) -> str:
|
|
57
|
+
"""Create a private key file readable by its owner only; returns the PUBLIC key (hex). Never overwrites."""
|
|
58
|
+
p = Path(path)
|
|
59
|
+
if p.exists():
|
|
60
|
+
raise AttestError(f"{p} already exists; refusing to overwrite a key")
|
|
61
|
+
p.parent.mkdir(parents=True, exist_ok=True)
|
|
62
|
+
priv = Ed25519PrivateKey.generate()
|
|
63
|
+
raw = priv.private_bytes(serialization.Encoding.Raw, serialization.PrivateFormat.Raw, serialization.NoEncryption())
|
|
64
|
+
fd = os.open(p, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o600)
|
|
65
|
+
with os.fdopen(fd, "w") as f:
|
|
66
|
+
f.write(raw.hex())
|
|
67
|
+
return public_hex(priv)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def load_key(path: str | Path = DEFAULT_KEY) -> Ed25519PrivateKey:
|
|
71
|
+
p = Path(path)
|
|
72
|
+
if not p.exists():
|
|
73
|
+
raise AttestError(f"no key at {p}; run `spatial attest init` first")
|
|
74
|
+
if p.stat().st_mode & 0o077:
|
|
75
|
+
raise AttestError(f"{p} is readable by other users; chmod 600 it")
|
|
76
|
+
return Ed25519PrivateKey.from_private_bytes(bytes.fromhex(p.read_text().strip()))
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def public_hex(priv: Ed25519PrivateKey) -> str:
|
|
80
|
+
return priv.public_key().public_bytes(serialization.Encoding.Raw, serialization.PublicFormat.Raw).hex()
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def build_report(screen_report, *, scope: dict, prev_hash: str | None = None, now: float | None = None) -> dict:
|
|
84
|
+
from . import __version__
|
|
85
|
+
ts = time.time() if now is None else now
|
|
86
|
+
return {
|
|
87
|
+
"schema": SCHEMA, "created": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime(ts)), "spatial_version": __version__,
|
|
88
|
+
"host": {"machine": platform.machine(), "system": platform.system(), "python": platform.python_version()},
|
|
89
|
+
"scope": scope,
|
|
90
|
+
"result": {
|
|
91
|
+
"healthy": screen_report.healthy, "reason": screen_report.reason,
|
|
92
|
+
"majority": (screen_report.majority or "")[:16] or None,
|
|
93
|
+
"executors": [{"name": x.name, "status": x.status, "seconds": round(x.seconds, 6), "digest": x.digest[:16], "error": x.error}
|
|
94
|
+
for x in screen_report.results],
|
|
95
|
+
},
|
|
96
|
+
"limits": list(LIMITS), "prev_hash": prev_hash,
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def sign(report: dict, priv: Ed25519PrivateKey) -> dict:
|
|
101
|
+
return {"report": report, "report_sha256": _sha(report), "pubkey": public_hex(priv), "sig": priv.sign(_canon(report)).hex()}
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def verify(signed: dict, expected_pubkey: str | None = None) -> Verified:
|
|
105
|
+
try:
|
|
106
|
+
report, pub, sig = signed["report"], signed["pubkey"], signed["sig"]
|
|
107
|
+
except (KeyError, TypeError):
|
|
108
|
+
return Verified(False, False, "not a signed attestation")
|
|
109
|
+
if signed.get("report_sha256") != _sha(report):
|
|
110
|
+
return Verified(False, False, "report hash does not match the report")
|
|
111
|
+
pinned = expected_pubkey is not None
|
|
112
|
+
if pinned and pub != expected_pubkey:
|
|
113
|
+
return Verified(False, True, "signed by a different key than the expected one")
|
|
114
|
+
try:
|
|
115
|
+
Ed25519PublicKey.from_public_bytes(bytes.fromhex(pub)).verify(bytes.fromhex(sig), _canon(report))
|
|
116
|
+
except (InvalidSignature, ValueError):
|
|
117
|
+
return Verified(False, pinned, "signature does not match")
|
|
118
|
+
return Verified(True, pinned, "valid signature" + ("" if pinned else "; signer identity NOT established (pin the public key)"))
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def read_history(path: str | Path) -> list[dict]:
|
|
122
|
+
p = Path(path)
|
|
123
|
+
if not p.exists():
|
|
124
|
+
return []
|
|
125
|
+
out = []
|
|
126
|
+
for line in p.read_text().splitlines():
|
|
127
|
+
try:
|
|
128
|
+
out.append(json.loads(line))
|
|
129
|
+
except json.JSONDecodeError:
|
|
130
|
+
out.append({"corrupt_line": line[:80]})
|
|
131
|
+
return out
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def last_hash(path: str | Path) -> str | None:
|
|
135
|
+
h = read_history(path)
|
|
136
|
+
return h[-1].get("report_sha256") if h else None
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def append(path: str | Path, signed: dict) -> None:
|
|
140
|
+
p = Path(path)
|
|
141
|
+
p.parent.mkdir(parents=True, exist_ok=True)
|
|
142
|
+
with p.open("a") as f:
|
|
143
|
+
f.write(json.dumps(signed, sort_keys=True) + "\n")
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def verify_chain(path: str | Path, expected_pubkey: str | None = None) -> Verified:
|
|
147
|
+
"""Every entry validly signed, and each entry's prev_hash equal to the previous entry's hash."""
|
|
148
|
+
entries = read_history(path)
|
|
149
|
+
if not entries:
|
|
150
|
+
return Verified(False, expected_pubkey is not None, "empty or missing history")
|
|
151
|
+
prev = None
|
|
152
|
+
for i, e in enumerate(entries):
|
|
153
|
+
v = verify(e, expected_pubkey) if "report" in e else Verified(False, False, "corrupt line")
|
|
154
|
+
if not v.ok:
|
|
155
|
+
return Verified(False, v.key_pinned, f"entry {i}: {v.reason}")
|
|
156
|
+
if e["report"].get("prev_hash") != prev:
|
|
157
|
+
return Verified(False, v.key_pinned, f"entry {i}: chain broken (an earlier report was removed or edited)")
|
|
158
|
+
prev = e["report_sha256"]
|
|
159
|
+
return Verified(True, expected_pubkey is not None, f"{len(entries)} entries, chain intact")
|
|
@@ -240,12 +240,25 @@ def cmd_devices(a):
|
|
|
240
240
|
|
|
241
241
|
|
|
242
242
|
def cmd_market(a):
|
|
243
|
-
from .market import MarketError, cheapest, cheapest_for, fetch_offers, spread_for, spread_vs
|
|
243
|
+
from .market import MarketError, cheapest, cheapest_for, fetch_offers, history, spread_for, spread_vs
|
|
244
|
+
if a.history:
|
|
245
|
+
snaps = history.read(a.history)
|
|
246
|
+
if not snaps:
|
|
247
|
+
print(f"spatial: no snapshots in {a.history}", file=sys.stderr)
|
|
248
|
+
return 1
|
|
249
|
+
print(f"{len(snaps)} snapshots, {snaps[0]['iso']} .. {snaps[-1]['iso']}")
|
|
250
|
+
for g in history.TRACKED:
|
|
251
|
+
s = history.summarize(snaps, g)
|
|
252
|
+
print(f"{g:9s} " + (f"min {s['min']:.3f} max {s['max']:.3f} latest {s['latest']:.3f} $/h per GPU ({s['samples']} samples)" if s else "never seen"))
|
|
253
|
+
return 0
|
|
244
254
|
try:
|
|
245
255
|
offers = fetch_offers()
|
|
246
256
|
except MarketError as e:
|
|
247
257
|
print(f"spatial: {e}", file=sys.stderr)
|
|
248
258
|
return 1
|
|
259
|
+
if a.record:
|
|
260
|
+
history.record(a.record, offers, min_reliability=a.min_reliability)
|
|
261
|
+
print(f"snapshot of {len(offers)} offers appended to {a.record}")
|
|
249
262
|
label = f"vertical {a.vertical!r}" if a.vertical else a.gpu
|
|
250
263
|
try:
|
|
251
264
|
if a.neocloud_usd_per_hour is not None:
|
|
@@ -312,6 +325,74 @@ def cmd_verify(a):
|
|
|
312
325
|
return 0
|
|
313
326
|
|
|
314
327
|
|
|
328
|
+
def cmd_screen(a):
|
|
329
|
+
from .fabric import metal
|
|
330
|
+
from .kernel.library import LIBRARY
|
|
331
|
+
from .verify import VerificationError, kernel_executors, screen
|
|
332
|
+
kernel = LIBRARY[a.family]
|
|
333
|
+
if a.devices == "auto":
|
|
334
|
+
devices = ["cpu", "cpu", "metal" if metal.available() else "cpu"]
|
|
335
|
+
else:
|
|
336
|
+
devices = a.devices.split(",")
|
|
337
|
+
ex = kernel_executors(kernel, devices, a.n, **json.loads(a.params))
|
|
338
|
+
if a.simulate_fault is not None:
|
|
339
|
+
name = list(ex)[a.simulate_fault]
|
|
340
|
+
real = ex[name]
|
|
341
|
+
|
|
342
|
+
def faulty(real=real):
|
|
343
|
+
out = real().copy()
|
|
344
|
+
out.flat[0] ^= 1 # one flipped bit
|
|
345
|
+
return out
|
|
346
|
+
faulty.kind = getattr(real, "kind", None)
|
|
347
|
+
ex[name] = faulty
|
|
348
|
+
print(f"SIMULATED fault injected into '{name}' (a flipped bit; not a real hardware fault)")
|
|
349
|
+
try:
|
|
350
|
+
r = screen(ex, repeats=a.repeats)
|
|
351
|
+
except VerificationError as e:
|
|
352
|
+
print(f"spatial: {e}", file=sys.stderr)
|
|
353
|
+
return 1
|
|
354
|
+
for x in r.results:
|
|
355
|
+
print(f"{x.name:10s} {x.status:13s} {x.seconds * 1000:8.1f} ms {x.digest[:12] or x.error}")
|
|
356
|
+
print(("HEALTHY: " if r.healthy else "UNHEALTHY: ") + r.reason)
|
|
357
|
+
return 0 if r.healthy else 1
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
def cmd_attest(a):
|
|
361
|
+
from . import attest
|
|
362
|
+
from .fabric import metal
|
|
363
|
+
from .kernel.library import LIBRARY
|
|
364
|
+
from .verify import kernel_executors, screen
|
|
365
|
+
key = a.key or attest.DEFAULT_KEY
|
|
366
|
+
try:
|
|
367
|
+
if a.action == "init":
|
|
368
|
+
print(f"key written to {key} (mode 600). Public key (share this one): {attest.init_key(key)}")
|
|
369
|
+
return 0
|
|
370
|
+
if a.action in ("verify", "chain"):
|
|
371
|
+
if not a.file:
|
|
372
|
+
print("spatial: give the file to check", file=sys.stderr)
|
|
373
|
+
return 1
|
|
374
|
+
v = attest.verify(json.loads(Path(a.file).read_text()), a.pubkey) if a.action == "verify" else attest.verify_chain(a.file, a.pubkey)
|
|
375
|
+
print(("OK: " if v.ok else "INVALID: ") + v.reason)
|
|
376
|
+
return 0 if v.ok else 1
|
|
377
|
+
priv = attest.load_key(key) # action == "run"
|
|
378
|
+
devices = ["cpu", "cpu", "metal" if metal.available() else "cpu"] if a.devices == "auto" else a.devices.split(",")
|
|
379
|
+
params = json.loads(a.params)
|
|
380
|
+
rep = screen(kernel_executors(LIBRARY[a.family], devices, a.n, **params), repeats=a.repeats)
|
|
381
|
+
scope = {"test": "known-answer", "kernel": a.family, "n": a.n, "params": params, "devices": devices, "repeats": a.repeats}
|
|
382
|
+
signed = attest.sign(attest.build_report(rep, scope=scope, prev_hash=attest.last_hash(a.history) if a.history else None), priv)
|
|
383
|
+
except (attest.AttestError, ValueError, OSError) as e:
|
|
384
|
+
print(f"spatial: {e}", file=sys.stderr)
|
|
385
|
+
return 1
|
|
386
|
+
if a.out:
|
|
387
|
+
Path(a.out).write_text(json.dumps(signed, indent=1, sort_keys=True))
|
|
388
|
+
if a.history:
|
|
389
|
+
attest.append(a.history, signed)
|
|
390
|
+
print(("HEALTHY: " if rep.healthy else "UNHEALTHY: ") + rep.reason)
|
|
391
|
+
print(f"signed by public key {signed['pubkey']}; report {signed['report_sha256'][:16]}"
|
|
392
|
+
+ (f"; written to {a.out}" if a.out else "") + (f"; appended to {a.history}" if a.history else ""))
|
|
393
|
+
return 0 if rep.healthy else 1
|
|
394
|
+
|
|
395
|
+
|
|
315
396
|
def cmd_token(a):
|
|
316
397
|
from .core import auth
|
|
317
398
|
if a.action == "init":
|
|
@@ -391,6 +472,8 @@ def main(argv=None):
|
|
|
391
472
|
p.add_argument("--vertical", choices=["render", "cloud_gaming"], help="a preset list of interchangeable GPUs for a market instead of one chip (render = 3D rendering/VFX render-farm cards; cloud_gaming = game-streaming rig cards)")
|
|
392
473
|
p.add_argument("--min-reliability", type=float, default=0.5, help="Vast.ai's own 0..1 host score; a low-reliability offer is excluded by default")
|
|
393
474
|
p.add_argument("--neocloud-usd-per-hour", type=float, default=None, help="your reference 'neocloud' price for this GPU: if given, prints the arbitrage spread instead of just the price")
|
|
475
|
+
p.add_argument("--record", metavar="FILE", help="also append a timestamped snapshot (cheapest tracked GPUs and verticals) to this JSONL file")
|
|
476
|
+
p.add_argument("--history", metavar="FILE", help="print min/max/latest per tracked GPU from a recorded file instead of reading the market (no network)")
|
|
394
477
|
p.set_defaults(fn=cmd_market)
|
|
395
478
|
p = sub.add_parser("automotive", help="place a task graph on a declared in-vehicle chip catalogue (software only, no real automotive silicon here)")
|
|
396
479
|
p.add_argument("--file", required=True, help="JSON: {\"chips\":[{\"name\",\"flops_per_s\",\"power_w\",\"supports_npu\"}], \"tasks\":[{\"name\",\"flops\",\"needs_npu\",\"after\"}]}")
|
|
@@ -403,6 +486,27 @@ def main(argv=None):
|
|
|
403
486
|
p.add_argument("--tolerance", type=float, default=0.0, help="max absolute difference allowed (ignored if --exact)")
|
|
404
487
|
p.add_argument("--exact", action="store_true", help="require a bit-exact match (integer kernels)")
|
|
405
488
|
p.set_defaults(fn=cmd_verify)
|
|
489
|
+
p = sub.add_parser("screen", help="fleet screening: same known-answer kernel on every executor, majority vote, flag the outlier and the straggler (see docs/VERIFY.md)")
|
|
490
|
+
p.add_argument("--family", default="collatz", choices=["mandelbrot", "collatz", "waves", "batch_score"], help="collatz is integer and bit-exact: the best known-answer test")
|
|
491
|
+
p.add_argument("--n", type=int, default=64)
|
|
492
|
+
p.add_argument("--params", default='{"limit":300}', help="JSON kernel parameters")
|
|
493
|
+
p.add_argument("--devices", default="auto", help="comma list (e.g. cpu,cpu,metal), or auto")
|
|
494
|
+
p.add_argument("--repeats", type=int, default=1, help="run each executor this many times; one that contradicts itself is reported 'unstable' (intermittent faults)")
|
|
495
|
+
p.add_argument("--simulate-fault", type=int, default=None, metavar="INDEX", help="demo only: flip one bit in the output of the executor at INDEX")
|
|
496
|
+
p.set_defaults(fn=cmd_screen)
|
|
497
|
+
p = sub.add_parser("attest", help="signed health attestation of a screening run, with a hash-chained history (integrity, not identity: see spatial/attest.py)")
|
|
498
|
+
p.add_argument("action", choices=["init", "run", "verify", "chain"])
|
|
499
|
+
p.add_argument("file", nargs="?", help="verify/chain: the report or history file")
|
|
500
|
+
p.add_argument("--key", help="private key file (default ~/.spatial/attest.key, mode 600)")
|
|
501
|
+
p.add_argument("--pubkey", help="verify/chain: the public key you expect (hex); without it the signer's identity is not established")
|
|
502
|
+
p.add_argument("--out", help="run: write the signed report here")
|
|
503
|
+
p.add_argument("--history", help="run: append to this chained history file")
|
|
504
|
+
p.add_argument("--family", default="collatz", choices=["mandelbrot", "collatz", "waves", "batch_score"])
|
|
505
|
+
p.add_argument("--n", type=int, default=64)
|
|
506
|
+
p.add_argument("--params", default='{"limit":300}')
|
|
507
|
+
p.add_argument("--devices", default="auto")
|
|
508
|
+
p.add_argument("--repeats", type=int, default=2)
|
|
509
|
+
p.set_defaults(fn=cmd_attest)
|
|
406
510
|
p = sub.add_parser("agent", help="run a fleet agent: measure this machine, report to a hub, run allow-listed tasks")
|
|
407
511
|
p.add_argument("--hub", required=True, help="host:port of the hub")
|
|
408
512
|
p.add_argument("--token-file", required=True, help="shared secret file, or a scoped token with fleet:report,fleet:work")
|
|
@@ -9,6 +9,7 @@ What this module does NOT do: rent a GPU, run a job, or spend any money. Renting
|
|
|
9
9
|
running a real job on it is a separate, later step that needs an account on the marketplace and
|
|
10
10
|
the user's explicit go-ahead each time, since it spends real money.
|
|
11
11
|
"""
|
|
12
|
+
from . import history # noqa: F401
|
|
12
13
|
from .vast import ( # noqa: F401
|
|
13
14
|
VERTICALS, MarketError, Offer, cheapest, cheapest_among, cheapest_for, fetch_offers,
|
|
14
15
|
parse_offers, spread_among, spread_for, spread_vs,
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"""Price history for the live GPU market: one timestamped snapshot per call, appended to a JSONL file.
|
|
2
|
+
|
|
3
|
+
Each snapshot records, for a fixed list of tracked GPU names and for each vertical, the cheapest sufficiently
|
|
4
|
+
reliable per-GPU price at that moment, plus how many offers were read. Nothing is inferred between snapshots and
|
|
5
|
+
nothing is invented: a gap in the file is a gap in the data. A real quality-adjusted index needs months of these
|
|
6
|
+
(see docs/MARKET.md); this module only starts the record.
|
|
7
|
+
"""
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import json
|
|
11
|
+
import time
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
|
|
14
|
+
from .vast import VERTICALS, Offer, cheapest, cheapest_for
|
|
15
|
+
|
|
16
|
+
TRACKED = ("H100", "A100", "RTX 4090", "RTX 5090")
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _row(o: Offer | None) -> dict | None:
|
|
20
|
+
if o is None:
|
|
21
|
+
return None
|
|
22
|
+
return {"gpu": o.gpu_name, "usd_h_per_gpu": round(o.usd_per_hour_per_gpu, 4), "reliability": o.reliability, "geo": o.geolocation}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def snapshot(offers: list[Offer], now: float | None = None, min_reliability: float = 0.5) -> dict:
|
|
26
|
+
ts = time.time() if now is None else now
|
|
27
|
+
return {
|
|
28
|
+
"ts": ts, "iso": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime(ts)), "n_offers": len(offers),
|
|
29
|
+
"min_reliability": min_reliability,
|
|
30
|
+
"gpus": {n: _row(cheapest(offers, n, min_reliability)) for n in TRACKED},
|
|
31
|
+
"verticals": {v: _row(cheapest_for(offers, v, min_reliability)) for v in VERTICALS},
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def record(path: str | Path, offers: list[Offer], now: float | None = None, min_reliability: float = 0.5) -> dict:
|
|
36
|
+
snap = snapshot(offers, now, min_reliability)
|
|
37
|
+
p = Path(path)
|
|
38
|
+
p.parent.mkdir(parents=True, exist_ok=True)
|
|
39
|
+
with p.open("a") as f:
|
|
40
|
+
f.write(json.dumps(snap, sort_keys=True) + "\n")
|
|
41
|
+
return snap
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def read(path: str | Path) -> list[dict]:
|
|
45
|
+
p = Path(path)
|
|
46
|
+
if not p.exists():
|
|
47
|
+
return []
|
|
48
|
+
out = []
|
|
49
|
+
for line in p.read_text().splitlines():
|
|
50
|
+
try:
|
|
51
|
+
out.append(json.loads(line))
|
|
52
|
+
except json.JSONDecodeError:
|
|
53
|
+
continue # a torn last line (killed mid-write) is skipped, never repaired
|
|
54
|
+
return out
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def summarize(snaps: list[dict], gpu: str) -> dict | None:
|
|
58
|
+
"""min / max / latest of one tracked GPU's cheapest price across snapshots; None if never seen."""
|
|
59
|
+
vals = [(s["ts"], s["gpus"][gpu]["usd_h_per_gpu"]) for s in snaps if s.get("gpus", {}).get(gpu)]
|
|
60
|
+
if not vals:
|
|
61
|
+
return None
|
|
62
|
+
prices = [v for _, v in vals]
|
|
63
|
+
return {"gpu": gpu, "samples": len(vals), "min": min(prices), "max": max(prices), "latest": vals[-1][1],
|
|
64
|
+
"first_ts": vals[0][0], "last_ts": vals[-1][0]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"""Redundant-execution verification and fleet screening. See spatial.verify.consensus and spatial.verify.screen."""
|
|
2
|
+
|
|
3
|
+
from .consensus import Consensus, VerificationError, consensus, verify_kernel
|
|
4
|
+
from .screen import ExecResult, ScreenReport, kernel_executors, screen, screen_kernel
|
|
5
|
+
|
|
6
|
+
__all__ = ["Consensus", "ExecResult", "ScreenReport", "VerificationError", "consensus", "kernel_executors",
|
|
7
|
+
"screen", "screen_kernel", "verify_kernel"]
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"""Fleet screening: run the same job on every executor, vote, quarantine the odd one out.
|
|
2
|
+
|
|
3
|
+
The mechanism large GPU fleets use against silent data corruption (periodic screening, outlier against the fleet
|
|
4
|
+
baseline) and against stragglers (a node much slower than its peers on an identical probe), reduced to a small,
|
|
5
|
+
testable, vendor-neutral core. An executor is any callable returning an array: a local device, a remote node, a
|
|
6
|
+
rented GPU. Run each executor `repeats` times to also catch a device that contradicts itself (intermittent faults).
|
|
7
|
+
|
|
8
|
+
Feed it a known-answer kernel (cheap, the default of `spatial screen`) or, much better, the REAL workload and its
|
|
9
|
+
real input data (replay). ByteDance's OSDI 2026 paper on 23 SDC-defective production GPUs found that synthetic
|
|
10
|
+
microbenchmarks, the usual practice, miss over 60 % of defective devices because SDCs are data- and unit-specific,
|
|
11
|
+
and that replaying the exact failing workload is what finds them. A known-answer kernel is a first filter, not a
|
|
12
|
+
clean bill of health.
|
|
13
|
+
|
|
14
|
+
What it does not do: no real GPU fault was ever observed here. The tests inject faults.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
import hashlib
|
|
18
|
+
import statistics
|
|
19
|
+
import time
|
|
20
|
+
from dataclasses import dataclass
|
|
21
|
+
|
|
22
|
+
import numpy as np
|
|
23
|
+
|
|
24
|
+
from .consensus import VerificationError
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@dataclass(frozen=True)
|
|
28
|
+
class ExecResult:
|
|
29
|
+
name: str
|
|
30
|
+
status: str # "ok" | "outlier" | "undetermined" | "unstable" | "error"
|
|
31
|
+
seconds: float
|
|
32
|
+
digest: str
|
|
33
|
+
error: str = ""
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@dataclass(frozen=True)
|
|
37
|
+
class ScreenReport:
|
|
38
|
+
results: tuple
|
|
39
|
+
majority: str | None
|
|
40
|
+
outliers: tuple
|
|
41
|
+
errors: tuple
|
|
42
|
+
stragglers: tuple
|
|
43
|
+
reason: str
|
|
44
|
+
unstable: tuple = ()
|
|
45
|
+
|
|
46
|
+
@property
|
|
47
|
+
def healthy(self) -> bool:
|
|
48
|
+
return self.majority is not None and not (self.outliers or self.errors or self.stragglers or self.unstable)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def _digest(arr) -> str:
|
|
52
|
+
a = np.ascontiguousarray(arr)
|
|
53
|
+
h = hashlib.sha256()
|
|
54
|
+
h.update(str((a.shape, a.dtype.str)).encode())
|
|
55
|
+
h.update(a.tobytes())
|
|
56
|
+
return h.hexdigest()
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def screen(executors: dict, *, clock=time.perf_counter, straggler_factor: float = 2.0,
|
|
60
|
+
straggler_min_gap_s: float = 0.05, repeats: int = 1) -> ScreenReport:
|
|
61
|
+
"""Run every executor `repeats` times and compare. Needs 2+ executors; 3+ to say WHICH one is wrong (with two
|
|
62
|
+
that disagree, nobody can tell). A majority must hold strictly more than half of the executors that ran. An
|
|
63
|
+
executor whose own repeated runs disagree is 'unstable' and left out of the vote. Timing is the median of the
|
|
64
|
+
repeats. Stragglers are judged within a group of 3+ executors sharing the same `.kind` attribute on their
|
|
65
|
+
callable (unset = one shared group)."""
|
|
66
|
+
if len(executors) < 2:
|
|
67
|
+
raise VerificationError("need at least 2 executors to screen")
|
|
68
|
+
if repeats < 1:
|
|
69
|
+
raise VerificationError("repeats must be at least 1")
|
|
70
|
+
raw = []
|
|
71
|
+
for name, fn in executors.items():
|
|
72
|
+
digests, times, err = [], [], ""
|
|
73
|
+
for _ in range(repeats):
|
|
74
|
+
t0 = clock()
|
|
75
|
+
try:
|
|
76
|
+
digests.append(_digest(np.asarray(fn())))
|
|
77
|
+
except Exception as e: # a broken executor is a finding, not a crash
|
|
78
|
+
err = f"{type(e).__name__}: {e}"
|
|
79
|
+
times.append(clock() - t0)
|
|
80
|
+
if err:
|
|
81
|
+
break
|
|
82
|
+
flaky = len(set(digests)) > 1
|
|
83
|
+
raw.append((name, "" if (err or flaky) else digests[0], statistics.median(times), err, flaky))
|
|
84
|
+
oks = [r for r in raw if not r[3] and not r[4]]
|
|
85
|
+
counts: dict = {}
|
|
86
|
+
for _, d, _, _, _ in oks:
|
|
87
|
+
counts[d] = counts.get(d, 0) + 1
|
|
88
|
+
majority = None
|
|
89
|
+
if counts:
|
|
90
|
+
top, c = max(counts.items(), key=lambda kv: kv[1])
|
|
91
|
+
if c >= 2 and c > len(oks) / 2:
|
|
92
|
+
majority = top
|
|
93
|
+
results, outliers, errors, unstable = [], [], [], []
|
|
94
|
+
for name, d, s, err, flaky in raw:
|
|
95
|
+
if err:
|
|
96
|
+
status = "error"
|
|
97
|
+
errors.append(name)
|
|
98
|
+
elif flaky:
|
|
99
|
+
status = "unstable"
|
|
100
|
+
unstable.append(name)
|
|
101
|
+
elif majority is None:
|
|
102
|
+
status = "ok" if len(counts) == 1 else "undetermined"
|
|
103
|
+
elif d == majority:
|
|
104
|
+
status = "ok"
|
|
105
|
+
else:
|
|
106
|
+
status = "outlier"
|
|
107
|
+
outliers.append(name)
|
|
108
|
+
results.append(ExecResult(name, status, s, d, err))
|
|
109
|
+
stragglers = []
|
|
110
|
+
groups: dict = {}
|
|
111
|
+
for n, _, s, _, _ in oks:
|
|
112
|
+
groups.setdefault(getattr(executors[n], "kind", None), []).append((n, s))
|
|
113
|
+
for g in groups.values(): # a CPU is not a straggler against GPUs: judge within a kind
|
|
114
|
+
if len(g) >= 3:
|
|
115
|
+
med = statistics.median(s for _, s in g)
|
|
116
|
+
stragglers += [n for n, s in g if s > straggler_factor * med and s - med >= straggler_min_gap_s]
|
|
117
|
+
if not oks:
|
|
118
|
+
reason = "every executor failed" if len(errors) == len(raw) else "no executor gave a stable result"
|
|
119
|
+
elif majority is None and len(counts) > 1:
|
|
120
|
+
reason = ("results disagree and no majority exists: with only two executors nobody can tell which is wrong"
|
|
121
|
+
if len(oks) == 2 else "results disagree and no majority exists")
|
|
122
|
+
elif outliers:
|
|
123
|
+
reason = f"outlier(s) against a {counts[majority]}-of-{len(oks)} majority: {', '.join(outliers)}"
|
|
124
|
+
elif unstable:
|
|
125
|
+
reason = f"unstable executor(s), two runs of the same job disagreed: {', '.join(unstable)}"
|
|
126
|
+
elif errors:
|
|
127
|
+
reason = f"executor(s) failed: {', '.join(errors)}"
|
|
128
|
+
elif stragglers:
|
|
129
|
+
reason = f"all agree, but slow against the median: {', '.join(stragglers)}"
|
|
130
|
+
else:
|
|
131
|
+
reason = f"all {len(oks)} executors agree"
|
|
132
|
+
return ScreenReport(tuple(results), majority, tuple(outliers), tuple(errors), tuple(stragglers), reason, tuple(unstable))
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def kernel_executors(kernel, devices, n: int, **params) -> dict:
|
|
136
|
+
"""One executor per entry of `devices`; repeated names get a #index suffix. Kernel runs are warmed up once
|
|
137
|
+
(JIT/compile) so the straggler check does not measure compilation."""
|
|
138
|
+
for d in dict.fromkeys(devices):
|
|
139
|
+
try:
|
|
140
|
+
kernel.run(d, 8, **params)
|
|
141
|
+
except Exception:
|
|
142
|
+
pass # surfaces as an error result in the real run
|
|
143
|
+
def make(d):
|
|
144
|
+
def run():
|
|
145
|
+
return kernel.run(d, n, **params)
|
|
146
|
+
run.kind = d # screen() judges stragglers only among the same kind
|
|
147
|
+
return run
|
|
148
|
+
out = {}
|
|
149
|
+
for i, d in enumerate(devices):
|
|
150
|
+
out[d if list(devices).count(d) == 1 else f"{d}#{i}"] = make(d)
|
|
151
|
+
return out
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def screen_kernel(kernel, devices, n: int, *, repeats: int = 1, **params) -> ScreenReport:
|
|
155
|
+
return screen(kernel_executors(kernel, devices, n, **params), repeats=repeats)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: spatial-computing
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.31.0
|
|
4
4
|
Summary: Spatial Computing: open-source infrastructure efficiency toolkit. Measure, decide, prove (compute, tiered memory, runtime routing, fleet)
|
|
5
5
|
Author: Spatial Computing contributors
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -103,7 +103,7 @@ st.put(0, b"..." * 1000); st.get(0); print(st.stats())
|
|
|
103
103
|
| Portable kernels (one source, CPU/Metal/CUDA/HIP/Triton; market-vertical presets) | first components | `tests/test_kernel.py`, `benchmarks/bench_kernel.py` |
|
|
104
104
|
| Live GPU market prices (`spatial market`, read-only, no account) | first components | `tests/test_market.py`, [docs/MARKET.md](docs/MARKET.md) |
|
|
105
105
|
| In-vehicle multi-chip placement (`spatial automotive`, declared chip specs, no real silicon) | first components | `tests/test_automotive.py`, [docs/AUTOMOTIVE.md](docs/AUTOMOTIVE.md) |
|
|
106
|
-
| Redundant-execution verification (`spatial verify`, not cryptographic, see limits) | first components | `tests/test_verify.py`, [docs/VERIFY.md](docs/VERIFY.md) |
|
|
106
|
+
| Redundant-execution verification, fleet screening and signed attestations (`spatial verify`, `spatial screen`, `spatial attest`; faults injected in tests, not cryptographic proof, see limits) | first components | `tests/test_verify.py`, `tests/test_screen.py`, `tests/test_attest.py`, [docs/VERIFY.md](docs/VERIFY.md) |
|
|
107
107
|
| AI, Intelligence | first components (toy model) | `tests/test_engines.py`, `tests/test_domains.py` |
|
|
108
108
|
|
|
109
109
|
Measured on the reference machine (AC power): Numba JIT ×31.6 over pure Python with an identical result; 0.88 s to boot an isolated Linux micro-VM on macOS; −75 % local RAM for a skewed-access dataset at 107× the mean access latency. Full table and conditions: [docs/RESULTATS.fr.md](docs/RESULTATS.fr.md).
|
{spatial_computing-0.29.0 → spatial_computing-0.31.0}/spatial_computing.egg-info/SOURCES.txt
RENAMED
|
@@ -2,6 +2,7 @@ LICENSE
|
|
|
2
2
|
README.md
|
|
3
3
|
pyproject.toml
|
|
4
4
|
spatial/__init__.py
|
|
5
|
+
spatial/attest.py
|
|
5
6
|
spatial/cli.py
|
|
6
7
|
spatial/ai/__init__.py
|
|
7
8
|
spatial/ai/kvcache.py
|
|
@@ -46,6 +47,7 @@ spatial/kernel/__init__.py
|
|
|
46
47
|
spatial/kernel/dsl.py
|
|
47
48
|
spatial/kernel/library.py
|
|
48
49
|
spatial/market/__init__.py
|
|
50
|
+
spatial/market/history.py
|
|
49
51
|
spatial/market/vast.py
|
|
50
52
|
spatial/memory/__init__.py
|
|
51
53
|
spatial/memory/fararray.py
|
|
@@ -96,12 +98,14 @@ spatial/unified/planner.py
|
|
|
96
98
|
spatial/unified/providers.py
|
|
97
99
|
spatial/verify/__init__.py
|
|
98
100
|
spatial/verify/consensus.py
|
|
101
|
+
spatial/verify/screen.py
|
|
99
102
|
spatial_computing.egg-info/PKG-INFO
|
|
100
103
|
spatial_computing.egg-info/SOURCES.txt
|
|
101
104
|
spatial_computing.egg-info/dependency_links.txt
|
|
102
105
|
spatial_computing.egg-info/entry_points.txt
|
|
103
106
|
spatial_computing.egg-info/requires.txt
|
|
104
107
|
spatial_computing.egg-info/top_level.txt
|
|
108
|
+
tests/test_attest.py
|
|
105
109
|
tests/test_auth.py
|
|
106
110
|
tests/test_automotive.py
|
|
107
111
|
tests/test_compute.py
|
|
@@ -117,12 +121,15 @@ tests/test_interconnect.py
|
|
|
117
121
|
tests/test_kernel.py
|
|
118
122
|
tests/test_market.py
|
|
119
123
|
tests/test_memory.py
|
|
124
|
+
tests/test_netfaults.py
|
|
120
125
|
tests/test_platform.py
|
|
121
126
|
tests/test_platform2.py
|
|
122
127
|
tests/test_qr.py
|
|
123
128
|
tests/test_quorum.py
|
|
124
129
|
tests/test_real_servers.py
|
|
125
130
|
tests/test_runtime.py
|
|
131
|
+
tests/test_screen.py
|
|
132
|
+
tests/test_site_claims.py
|
|
126
133
|
tests/test_sso.py
|
|
127
134
|
tests/test_unified.py
|
|
128
135
|
tests/test_v02.py
|