spatial-computing 0.29.0__tar.gz → 0.30.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 (137) hide show
  1. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/PKG-INFO +2 -2
  2. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/README.md +1 -1
  3. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/pyproject.toml +1 -1
  4. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/__init__.py +1 -1
  5. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/cli.py +39 -0
  6. spatial_computing-0.30.0/spatial/verify/__init__.py +7 -0
  7. spatial_computing-0.30.0/spatial/verify/screen.py +136 -0
  8. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial_computing.egg-info/PKG-INFO +2 -2
  9. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial_computing.egg-info/SOURCES.txt +3 -0
  10. spatial_computing-0.30.0/tests/test_screen.py +149 -0
  11. spatial_computing-0.30.0/tests/test_site_claims.py +26 -0
  12. spatial_computing-0.29.0/spatial/verify/__init__.py +0 -5
  13. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/LICENSE +0 -0
  14. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/setup.cfg +0 -0
  15. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/ai/__init__.py +0 -0
  16. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/ai/kvcache.py +0 -0
  17. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/ai/llm.py +0 -0
  18. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/automotive/__init__.py +0 -0
  19. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/automotive/placement.py +0 -0
  20. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/compute/__init__.py +0 -0
  21. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/compute/cost.py +0 -0
  22. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/compute/detect.py +0 -0
  23. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/compute/monitor.py +0 -0
  24. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/compute/scheduler.py +0 -0
  25. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/compute/taskqueue.py +0 -0
  26. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/compute/worker.py +0 -0
  27. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/compute/workloads.py +0 -0
  28. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/core/__init__.py +0 -0
  29. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/core/auth.py +0 -0
  30. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/core/energy.py +0 -0
  31. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/core/ledger.py +0 -0
  32. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/core/model.py +0 -0
  33. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/core/protocol.py +0 -0
  34. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/core/registry.py +0 -0
  35. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/fabric/__init__.py +0 -0
  36. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/fabric/cuda.py +0 -0
  37. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/fabric/devices.py +0 -0
  38. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/fabric/metal.py +0 -0
  39. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/fabric/metal_mandel.swift +0 -0
  40. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/fabric/metal_run.swift +0 -0
  41. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/fleet/__init__.py +0 -0
  42. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/fleet/agent.py +0 -0
  43. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/fleet/alerts.py +0 -0
  44. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/fleet/dashboard.py +0 -0
  45. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/fleet/ha.py +0 -0
  46. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/fleet/hub.py +0 -0
  47. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/intelligence/__init__.py +0 -0
  48. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/intelligence/predictor.py +0 -0
  49. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/interconnect/__init__.py +0 -0
  50. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/interconnect/collectives.py +0 -0
  51. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/interconnect/comm.py +0 -0
  52. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/interconnect/model.py +0 -0
  53. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/interconnect/tasks.py +0 -0
  54. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/kernel/__init__.py +0 -0
  55. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/kernel/dsl.py +0 -0
  56. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/kernel/library.py +0 -0
  57. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/market/__init__.py +0 -0
  58. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/market/vast.py +0 -0
  59. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/memory/__init__.py +0 -0
  60. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/memory/fararray.py +0 -0
  61. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/memory/pageserver.py +0 -0
  62. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/memory/secure.py +0 -0
  63. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/memory/shared.py +0 -0
  64. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/memory/tiered.py +0 -0
  65. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/platform/__init__.py +0 -0
  66. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/platform/billing.py +0 -0
  67. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/platform/db.py +0 -0
  68. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/platform/invoice_rules.py +0 -0
  69. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/platform/mailer.py +0 -0
  70. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/platform/oidc.py +0 -0
  71. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/platform/pdf.py +0 -0
  72. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/platform/qr.py +0 -0
  73. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/platform/security.py +0 -0
  74. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/platform/server.py +0 -0
  75. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/platform/service.py +0 -0
  76. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/platform/static/app.js +0 -0
  77. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/platform/static/fonts/DMMono-normal-400.woff2 +0 -0
  78. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/platform/static/fonts/DMMono-normal-500.woff2 +0 -0
  79. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/platform/static/fonts/InstrumentSerif-italic-400.woff2 +0 -0
  80. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/platform/static/fonts/InstrumentSerif-normal-400.woff2 +0 -0
  81. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/platform/static/fonts/Inter-normal-400.woff2 +0 -0
  82. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/platform/static/fonts/Inter-normal-500.woff2 +0 -0
  83. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/platform/static/fonts/Inter-normal-600.woff2 +0 -0
  84. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/platform/static/fonts.css +0 -0
  85. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/platform/static/index.html +0 -0
  86. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/platform/static/logo.svg +0 -0
  87. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/platform/static/style.css +0 -0
  88. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/platform/totp.py +0 -0
  89. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/platform/ubl.py +0 -0
  90. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/platform/vat.py +0 -0
  91. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/runtime/__init__.py +0 -0
  92. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/runtime/arch.py +0 -0
  93. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/runtime/desktop/Dockerfile +0 -0
  94. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/runtime/desktop/__init__.py +0 -0
  95. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/runtime/desktop/start.sh +0 -0
  96. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/runtime/envs.py +0 -0
  97. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/runtime/inspect.py +0 -0
  98. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/runtime/microvm.py +0 -0
  99. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/runtime/planner.py +0 -0
  100. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/runtime/runner.py +0 -0
  101. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/runtime/toolchain.py +0 -0
  102. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/unified/__init__.py +0 -0
  103. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/unified/model.py +0 -0
  104. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/unified/planner.py +0 -0
  105. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/unified/providers.py +0 -0
  106. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial/verify/consensus.py +0 -0
  107. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial_computing.egg-info/dependency_links.txt +0 -0
  108. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial_computing.egg-info/entry_points.txt +0 -0
  109. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial_computing.egg-info/requires.txt +0 -0
  110. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/spatial_computing.egg-info/top_level.txt +0 -0
  111. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/tests/test_auth.py +0 -0
  112. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/tests/test_automotive.py +0 -0
  113. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/tests/test_compute.py +0 -0
  114. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/tests/test_core.py +0 -0
  115. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/tests/test_dashboard.py +0 -0
  116. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/tests/test_domains.py +0 -0
  117. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/tests/test_engines.py +0 -0
  118. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/tests/test_fabric.py +0 -0
  119. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/tests/test_fleet.py +0 -0
  120. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/tests/test_ha.py +0 -0
  121. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/tests/test_hardening.py +0 -0
  122. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/tests/test_interconnect.py +0 -0
  123. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/tests/test_kernel.py +0 -0
  124. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/tests/test_market.py +0 -0
  125. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/tests/test_memory.py +0 -0
  126. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/tests/test_platform.py +0 -0
  127. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/tests/test_platform2.py +0 -0
  128. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/tests/test_qr.py +0 -0
  129. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/tests/test_quorum.py +0 -0
  130. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/tests/test_real_servers.py +0 -0
  131. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/tests/test_runtime.py +0 -0
  132. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/tests/test_sso.py +0 -0
  133. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/tests/test_unified.py +0 -0
  134. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/tests/test_v02.py +0 -0
  135. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/tests/test_v03.py +0 -0
  136. {spatial_computing-0.29.0 → spatial_computing-0.30.0}/tests/test_v05.py +0 -0
  137. {spatial_computing-0.29.0 → spatial_computing-0.30.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.29.0
3
+ Version: 0.30.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 and fleet screening (`spatial verify`, `spatial screen`; faults injected in tests, not cryptographic, see limits) | first components | `tests/test_verify.py`, `tests/test_screen.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 and fleet screening (`spatial verify`, `spatial screen`; faults injected in tests, not cryptographic, see limits) | first components | `tests/test_verify.py`, `tests/test_screen.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.29.0"
7
+ version = "0.30.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"
@@ -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.29.0"
6
+ __version__ = "0.30.0"
@@ -312,6 +312,38 @@ def cmd_verify(a):
312
312
  return 0
313
313
 
314
314
 
315
+ def cmd_screen(a):
316
+ from .fabric import metal
317
+ from .kernel.library import LIBRARY
318
+ from .verify import VerificationError, kernel_executors, screen
319
+ kernel = LIBRARY[a.family]
320
+ if a.devices == "auto":
321
+ devices = ["cpu", "cpu", "metal" if metal.available() else "cpu"]
322
+ else:
323
+ devices = a.devices.split(",")
324
+ ex = kernel_executors(kernel, devices, a.n, **json.loads(a.params))
325
+ if a.simulate_fault is not None:
326
+ name = list(ex)[a.simulate_fault]
327
+ real = ex[name]
328
+
329
+ def faulty(real=real):
330
+ out = real().copy()
331
+ out.flat[0] ^= 1 # one flipped bit
332
+ return out
333
+ faulty.kind = getattr(real, "kind", None)
334
+ ex[name] = faulty
335
+ print(f"SIMULATED fault injected into '{name}' (a flipped bit; not a real hardware fault)")
336
+ try:
337
+ r = screen(ex)
338
+ except VerificationError as e:
339
+ print(f"spatial: {e}", file=sys.stderr)
340
+ return 1
341
+ for x in r.results:
342
+ print(f"{x.name:10s} {x.status:13s} {x.seconds * 1000:8.1f} ms {x.digest[:12] or x.error}")
343
+ print(("HEALTHY: " if r.healthy else "UNHEALTHY: ") + r.reason)
344
+ return 0 if r.healthy else 1
345
+
346
+
315
347
  def cmd_token(a):
316
348
  from .core import auth
317
349
  if a.action == "init":
@@ -403,6 +435,13 @@ def main(argv=None):
403
435
  p.add_argument("--tolerance", type=float, default=0.0, help="max absolute difference allowed (ignored if --exact)")
404
436
  p.add_argument("--exact", action="store_true", help="require a bit-exact match (integer kernels)")
405
437
  p.set_defaults(fn=cmd_verify)
438
+ 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)")
439
+ p.add_argument("--family", default="collatz", choices=["mandelbrot", "collatz", "waves", "batch_score"], help="collatz is integer and bit-exact: the best known-answer test")
440
+ p.add_argument("--n", type=int, default=64)
441
+ p.add_argument("--params", default='{"limit":300}', help="JSON kernel parameters")
442
+ p.add_argument("--devices", default="auto", help="comma list (e.g. cpu,cpu,metal), or auto")
443
+ 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")
444
+ p.set_defaults(fn=cmd_screen)
406
445
  p = sub.add_parser("agent", help="run a fleet agent: measure this machine, report to a hub, run allow-listed tasks")
407
446
  p.add_argument("--hub", required=True, help="host:port of the hub")
408
447
  p.add_argument("--token-file", required=True, help="shared secret file, or a scoped token with fleet:report,fleet:work")
@@ -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,136 @@
1
+ """Fleet screening: run the same known-answer job on every executor, vote, quarantine the odd one out.
2
+
3
+ The mechanism large GPU fleets use against silent data corruption (periodic known-answer screening, outlier
4
+ against the fleet baseline) and against stragglers (a node much slower than its peers on an identical probe),
5
+ reduced to a small, testable, vendor-neutral core. An executor is any callable returning an array: a local
6
+ device, a remote node, a rented GPU.
7
+
8
+ What it does not do: no real GPU fault was ever observed here. The tests inject faults. Real corruption is
9
+ data-, voltage- and temperature-dependent (NVIDIA/OCP white paper) and a few known-answer kernels will not
10
+ cover that test space; this finds gross or systematic miscomputation and gross slowness, not rare faults.
11
+ """
12
+
13
+ import hashlib
14
+ import statistics
15
+ import time
16
+ from dataclasses import dataclass
17
+
18
+ import numpy as np
19
+
20
+ from .consensus import VerificationError
21
+
22
+
23
+ @dataclass(frozen=True)
24
+ class ExecResult:
25
+ name: str
26
+ status: str # "ok" | "outlier" | "undetermined" | "error"
27
+ seconds: float
28
+ digest: str
29
+ error: str = ""
30
+
31
+
32
+ @dataclass(frozen=True)
33
+ class ScreenReport:
34
+ results: tuple
35
+ majority: str | None
36
+ outliers: tuple
37
+ errors: tuple
38
+ stragglers: tuple
39
+ reason: str
40
+
41
+ @property
42
+ def healthy(self) -> bool:
43
+ return self.majority is not None and not (self.outliers or self.errors or self.stragglers)
44
+
45
+
46
+ def _digest(arr) -> str:
47
+ a = np.ascontiguousarray(arr)
48
+ h = hashlib.sha256()
49
+ h.update(str((a.shape, a.dtype.str)).encode())
50
+ h.update(a.tobytes())
51
+ return h.hexdigest()
52
+
53
+
54
+ def screen(executors: dict, *, clock=time.perf_counter, straggler_factor: float = 2.0,
55
+ straggler_min_gap_s: float = 0.05) -> ScreenReport:
56
+ """Run every executor once and compare. Needs 2+ executors; 3+ to say WHICH one is wrong (with two that
57
+ disagree, nobody can tell). A majority must hold strictly more than half of the executors that ran.
58
+ Stragglers are judged within a group of 3+ executors sharing the same `.kind` attribute on their callable
59
+ (unset = one shared group)."""
60
+ if len(executors) < 2:
61
+ raise VerificationError("need at least 2 executors to screen")
62
+ raw = []
63
+ for name, fn in executors.items():
64
+ t0 = clock()
65
+ try:
66
+ digest, err = _digest(np.asarray(fn())), ""
67
+ except Exception as e: # a broken executor is a finding, not a crash
68
+ digest, err = "", f"{type(e).__name__}: {e}"
69
+ raw.append((name, digest, clock() - t0, err))
70
+ oks = [r for r in raw if not r[3]]
71
+ counts: dict = {}
72
+ for _, d, _, _ in oks:
73
+ counts[d] = counts.get(d, 0) + 1
74
+ majority = None
75
+ if counts:
76
+ top, c = max(counts.items(), key=lambda kv: kv[1])
77
+ if c >= 2 and c > len(oks) / 2:
78
+ majority = top
79
+ results, outliers, errors = [], [], []
80
+ for name, d, s, err in raw:
81
+ if err:
82
+ status = "error"
83
+ errors.append(name)
84
+ elif majority is None:
85
+ status = "ok" if len(counts) == 1 else "undetermined"
86
+ elif d == majority:
87
+ status = "ok"
88
+ else:
89
+ status = "outlier"
90
+ outliers.append(name)
91
+ results.append(ExecResult(name, status, s, d, err))
92
+ stragglers = []
93
+ groups: dict = {}
94
+ for n, _, s, _ in oks:
95
+ groups.setdefault(getattr(executors[n], "kind", None), []).append((n, s))
96
+ for g in groups.values(): # a CPU is not a straggler against GPUs: judge within a kind
97
+ if len(g) >= 3:
98
+ med = statistics.median(s for _, s in g)
99
+ stragglers += [n for n, s in g if s > straggler_factor * med and s - med >= straggler_min_gap_s]
100
+ if not oks:
101
+ reason = "every executor failed"
102
+ elif majority is None and len(counts) > 1:
103
+ reason = ("results disagree and no majority exists: with only two executors nobody can tell which is wrong"
104
+ if len(oks) == 2 else "results disagree and no majority exists")
105
+ elif outliers:
106
+ reason = f"outlier(s) against a {counts[majority]}-of-{len(oks)} majority: {', '.join(outliers)}"
107
+ elif errors:
108
+ reason = f"executor(s) failed: {', '.join(errors)}"
109
+ elif stragglers:
110
+ reason = f"all agree, but slow against the median: {', '.join(stragglers)}"
111
+ else:
112
+ reason = f"all {len(oks)} executors agree"
113
+ return ScreenReport(tuple(results), majority, tuple(outliers), tuple(errors), tuple(stragglers), reason)
114
+
115
+
116
+ def kernel_executors(kernel, devices, n: int, **params) -> dict:
117
+ """One executor per entry of `devices`; repeated names get a #index suffix. Kernel runs are warmed up once
118
+ (JIT/compile) so the straggler check does not measure compilation."""
119
+ for d in dict.fromkeys(devices):
120
+ try:
121
+ kernel.run(d, 8, **params)
122
+ except Exception:
123
+ pass # surfaces as an error result in the real run
124
+ def make(d):
125
+ def run():
126
+ return kernel.run(d, n, **params)
127
+ run.kind = d # screen() judges stragglers only among the same kind
128
+ return run
129
+ out = {}
130
+ for i, d in enumerate(devices):
131
+ out[d if list(devices).count(d) == 1 else f"{d}#{i}"] = make(d)
132
+ return out
133
+
134
+
135
+ def screen_kernel(kernel, devices, n: int, **params) -> ScreenReport:
136
+ return screen(kernel_executors(kernel, devices, n, **params))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: spatial-computing
3
- Version: 0.29.0
3
+ Version: 0.30.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 and fleet screening (`spatial verify`, `spatial screen`; faults injected in tests, not cryptographic, see limits) | first components | `tests/test_verify.py`, `tests/test_screen.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).
@@ -96,6 +96,7 @@ spatial/unified/planner.py
96
96
  spatial/unified/providers.py
97
97
  spatial/verify/__init__.py
98
98
  spatial/verify/consensus.py
99
+ spatial/verify/screen.py
99
100
  spatial_computing.egg-info/PKG-INFO
100
101
  spatial_computing.egg-info/SOURCES.txt
101
102
  spatial_computing.egg-info/dependency_links.txt
@@ -123,6 +124,8 @@ tests/test_qr.py
123
124
  tests/test_quorum.py
124
125
  tests/test_real_servers.py
125
126
  tests/test_runtime.py
127
+ tests/test_screen.py
128
+ tests/test_site_claims.py
126
129
  tests/test_sso.py
127
130
  tests/test_unified.py
128
131
  tests/test_v02.py
@@ -0,0 +1,149 @@
1
+ """Fleet screening: faults are INJECTED here; no real hardware fault was ever observed."""
2
+ import numpy as np
3
+ import pytest
4
+
5
+ from spatial.fabric import metal
6
+ from spatial.kernel.library import collatz
7
+ from spatial.verify import VerificationError, screen, screen_kernel
8
+
9
+ needs_metal = pytest.mark.skipif(not metal.available(), reason="no Metal")
10
+
11
+
12
+ def good():
13
+ return np.arange(16, dtype="uint32").reshape(4, 4)
14
+
15
+
16
+ def flipped():
17
+ a = good()
18
+ a[2, 1] ^= 1
19
+ return a
20
+
21
+
22
+ class FakeClock:
23
+ """Returns scripted instants, so timing tests do not depend on the machine."""
24
+ def __init__(self, *durations):
25
+ self.t, self.queue = 0.0, list(durations)
26
+ self.calls = 0
27
+
28
+ def __call__(self):
29
+ self.calls += 1
30
+ if self.calls % 2 == 0: # end of an executor: advance by its scripted duration
31
+ self.t += self.queue.pop(0)
32
+ return self.t
33
+
34
+
35
+ def test_all_agree_is_healthy():
36
+ r = screen({"a": good, "b": good, "c": good})
37
+ assert r.healthy and not r.outliers and r.majority is not None
38
+ assert [x.status for x in r.results] == ["ok", "ok", "ok"]
39
+
40
+
41
+ def test_one_corrupted_executor_among_three_is_named():
42
+ r = screen({"gpu0": good, "gpu1": flipped, "gpu2": good})
43
+ assert not r.healthy and r.outliers == ("gpu1",)
44
+ assert {x.name: x.status for x in r.results} == {"gpu0": "ok", "gpu1": "outlier", "gpu2": "ok"}
45
+ assert "gpu1" in r.reason
46
+
47
+
48
+ def test_two_that_disagree_cannot_name_the_culprit():
49
+ r = screen({"a": good, "b": flipped})
50
+ assert not r.healthy and r.outliers == () and r.majority is None
51
+ assert {x.status for x in r.results} == {"undetermined"}
52
+ assert "nobody can tell" in r.reason
53
+
54
+
55
+ def test_three_different_answers_have_no_majority():
56
+ def other():
57
+ return good() + 1
58
+ r = screen({"a": good, "b": flipped, "c": other})
59
+ assert not r.healthy and r.majority is None and r.outliers == ()
60
+
61
+
62
+ def test_a_tie_is_not_a_majority():
63
+ r = screen({"a": good, "b": good, "c": flipped, "d": flipped})
64
+ assert not r.healthy and r.majority is None
65
+
66
+
67
+ def test_a_crashing_executor_is_reported_not_raised():
68
+ def boom():
69
+ raise RuntimeError("ECC error")
70
+ r = screen({"a": good, "b": good, "c": boom})
71
+ assert not r.healthy and r.errors == ("c",)
72
+ assert "RuntimeError: ECC error" in r.results[2].error
73
+ assert r.majority is not None
74
+
75
+
76
+ def test_every_executor_failing():
77
+ def boom():
78
+ raise RuntimeError("x")
79
+ r = screen({"a": boom, "b": boom})
80
+ assert not r.healthy and r.majority is None and "every executor failed" in r.reason
81
+
82
+
83
+ def test_a_straggler_is_flagged_against_the_median():
84
+ r = screen({"a": good, "b": good, "c": good}, clock=FakeClock(1.0, 1.1, 5.0))
85
+ assert not r.healthy and r.stragglers == ("c",) and r.outliers == ()
86
+ assert "slow" in r.reason
87
+
88
+
89
+ def test_tiny_timing_differences_are_not_stragglers():
90
+ r = screen({"a": good, "b": good, "c": good}, clock=FakeClock(0.001, 0.001, 0.004))
91
+ assert r.healthy and r.stragglers == ()
92
+
93
+
94
+ def tagged(kind):
95
+ def run():
96
+ return good()
97
+ run.kind = kind
98
+ return run
99
+
100
+
101
+ def test_a_slow_gpu_is_not_a_straggler_against_fast_cpus():
102
+ """The CI failure on macOS: Metal slower than the median of two CPU runs is a different kind of device."""
103
+ r = screen({"cpu#0": tagged("cpu"), "cpu#1": tagged("cpu"), "metal": tagged("metal")}, clock=FakeClock(0.005, 0.005, 0.5))
104
+ assert r.healthy and r.stragglers == ()
105
+
106
+
107
+ def test_stragglers_are_judged_within_their_own_kind():
108
+ ex = {"c0": tagged("cpu"), "c1": tagged("cpu"), "c2": tagged("cpu"), "g0": tagged("gpu")}
109
+ r = screen(ex, clock=FakeClock(1.0, 1.1, 5.0, 9.0))
110
+ assert r.stragglers == ("c2",)
111
+
112
+
113
+ def test_stragglers_need_three_executors():
114
+ r = screen({"a": good, "b": good}, clock=FakeClock(1.0, 9.0))
115
+ assert r.healthy and r.stragglers == ()
116
+
117
+
118
+ def test_dtype_and_shape_matter_for_the_digest():
119
+ r = screen({"a": good, "b": lambda: good().astype("uint64"), "c": good})
120
+ assert r.outliers == ("b",)
121
+
122
+
123
+ def test_fewer_than_two_executors_raises():
124
+ with pytest.raises(VerificationError, match="at least 2"):
125
+ screen({"a": good})
126
+
127
+
128
+ def test_real_kernel_on_three_cpu_executors_is_healthy():
129
+ r = screen_kernel(collatz, ("cpu", "cpu", "cpu"), 32, limit=100)
130
+ assert r.healthy and [x.name for x in r.results] == ["cpu#0", "cpu#1", "cpu#2"]
131
+
132
+
133
+ @needs_metal
134
+ def test_real_kernel_cpu_cpu_metal_is_healthy_because_the_integer_kernel_is_bit_exact():
135
+ r = screen_kernel(collatz, ("cpu", "cpu", "metal"), 64, limit=300)
136
+ assert r.healthy and r.majority is not None
137
+
138
+
139
+ def test_cli_screen_healthy(capsys):
140
+ from spatial.cli import main
141
+ assert main(["screen", "--devices", "cpu,cpu,cpu", "--n", "16", "--params", '{"limit":100}']) == 0
142
+ assert "HEALTHY: all 3 executors agree" in capsys.readouterr().out
143
+
144
+
145
+ def test_cli_screen_with_a_simulated_fault_names_the_executor_and_exits_nonzero(capsys):
146
+ from spatial.cli import main
147
+ assert main(["screen", "--devices", "cpu,cpu,cpu", "--n", "16", "--params", '{"limit":100}', "--simulate-fault", "1"]) == 1
148
+ out = capsys.readouterr().out
149
+ assert "SIMULATED fault" in out and "outlier" in out and "UNHEALTHY" in out and "cpu#1" in out
@@ -0,0 +1,26 @@
1
+ """Numbers the site prints must match reality: a stale count was shipped twice."""
2
+ import re
3
+ import subprocess
4
+ import sys
5
+ from pathlib import Path
6
+
7
+ SITE = Path(__file__).resolve().parent.parent / "site"
8
+
9
+
10
+ def test_site_test_count_matches_the_collected_total():
11
+ out = subprocess.run([sys.executable, "-m", "pytest", "--collect-only", "-q", "-p", "no:cacheprovider", "tests"],
12
+ capture_output=True, text=True, cwd=SITE.parent).stdout
13
+ collected = int(re.search(r"(\d+) tests? collected", out).group(1))
14
+ sys.path.insert(0, str(SITE))
15
+ try:
16
+ import scaffold
17
+ finally:
18
+ sys.path.remove(str(SITE))
19
+ assert scaffold.TEST_COUNT == collected, f"site/scaffold.py says {scaffold.TEST_COUNT}, pytest collects {collected}: update TEST_COUNT"
20
+
21
+
22
+ def test_docs_index_has_no_hardcoded_version_or_count():
23
+ for f in ("content_en.py", "content_fr.py"):
24
+ src = (SITE / f).read_text()
25
+ assert "@@V@@" in src and "@@N@@" in src, f"{f}: status callout must use the placeholders"
26
+ assert not re.search(r"Version 0\.\d+\.\d+\.", src), f"{f}: hardcoded version in the status callout"
@@ -1,5 +0,0 @@
1
- """Redundant-execution verification. See spatial.verify.consensus."""
2
-
3
- from .consensus import Consensus, VerificationError, consensus, verify_kernel
4
-
5
- __all__ = ["Consensus", "VerificationError", "consensus", "verify_kernel"]