spatial-computing 0.23.0__tar.gz → 0.24.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 (127) hide show
  1. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/PKG-INFO +2 -1
  2. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/README.md +1 -0
  3. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/pyproject.toml +1 -1
  4. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/__init__.py +1 -1
  5. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/cli.py +32 -0
  6. spatial_computing-0.24.0/spatial/market/__init__.py +12 -0
  7. spatial_computing-0.24.0/spatial/market/vast.py +85 -0
  8. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial_computing.egg-info/PKG-INFO +2 -1
  9. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial_computing.egg-info/SOURCES.txt +3 -0
  10. spatial_computing-0.24.0/tests/test_market.py +72 -0
  11. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/LICENSE +0 -0
  12. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/setup.cfg +0 -0
  13. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/ai/__init__.py +0 -0
  14. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/ai/kvcache.py +0 -0
  15. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/ai/llm.py +0 -0
  16. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/compute/__init__.py +0 -0
  17. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/compute/cost.py +0 -0
  18. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/compute/detect.py +0 -0
  19. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/compute/monitor.py +0 -0
  20. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/compute/scheduler.py +0 -0
  21. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/compute/taskqueue.py +0 -0
  22. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/compute/worker.py +0 -0
  23. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/compute/workloads.py +0 -0
  24. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/core/__init__.py +0 -0
  25. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/core/auth.py +0 -0
  26. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/core/energy.py +0 -0
  27. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/core/ledger.py +0 -0
  28. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/core/model.py +0 -0
  29. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/core/protocol.py +0 -0
  30. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/core/registry.py +0 -0
  31. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/fabric/__init__.py +0 -0
  32. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/fabric/cuda.py +0 -0
  33. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/fabric/devices.py +0 -0
  34. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/fabric/metal.py +0 -0
  35. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/fabric/metal_mandel.swift +0 -0
  36. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/fabric/metal_run.swift +0 -0
  37. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/fleet/__init__.py +0 -0
  38. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/fleet/agent.py +0 -0
  39. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/fleet/alerts.py +0 -0
  40. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/fleet/dashboard.py +0 -0
  41. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/fleet/ha.py +0 -0
  42. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/fleet/hub.py +0 -0
  43. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/intelligence/__init__.py +0 -0
  44. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/intelligence/predictor.py +0 -0
  45. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/interconnect/__init__.py +0 -0
  46. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/interconnect/collectives.py +0 -0
  47. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/interconnect/comm.py +0 -0
  48. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/interconnect/model.py +0 -0
  49. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/interconnect/tasks.py +0 -0
  50. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/kernel/__init__.py +0 -0
  51. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/kernel/dsl.py +0 -0
  52. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/kernel/library.py +0 -0
  53. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/memory/__init__.py +0 -0
  54. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/memory/fararray.py +0 -0
  55. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/memory/pageserver.py +0 -0
  56. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/memory/secure.py +0 -0
  57. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/memory/shared.py +0 -0
  58. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/memory/tiered.py +0 -0
  59. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/platform/__init__.py +0 -0
  60. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/platform/billing.py +0 -0
  61. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/platform/db.py +0 -0
  62. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/platform/invoice_rules.py +0 -0
  63. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/platform/mailer.py +0 -0
  64. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/platform/oidc.py +0 -0
  65. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/platform/pdf.py +0 -0
  66. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/platform/qr.py +0 -0
  67. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/platform/security.py +0 -0
  68. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/platform/server.py +0 -0
  69. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/platform/service.py +0 -0
  70. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/platform/static/app.js +0 -0
  71. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/platform/static/fonts/DMMono-normal-400.woff2 +0 -0
  72. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/platform/static/fonts/DMMono-normal-500.woff2 +0 -0
  73. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/platform/static/fonts/InstrumentSerif-italic-400.woff2 +0 -0
  74. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/platform/static/fonts/InstrumentSerif-normal-400.woff2 +0 -0
  75. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/platform/static/fonts/Inter-normal-400.woff2 +0 -0
  76. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/platform/static/fonts/Inter-normal-500.woff2 +0 -0
  77. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/platform/static/fonts/Inter-normal-600.woff2 +0 -0
  78. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/platform/static/fonts.css +0 -0
  79. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/platform/static/index.html +0 -0
  80. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/platform/static/logo.svg +0 -0
  81. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/platform/static/style.css +0 -0
  82. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/platform/totp.py +0 -0
  83. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/platform/ubl.py +0 -0
  84. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/platform/vat.py +0 -0
  85. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/runtime/__init__.py +0 -0
  86. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/runtime/arch.py +0 -0
  87. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/runtime/desktop/Dockerfile +0 -0
  88. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/runtime/desktop/__init__.py +0 -0
  89. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/runtime/desktop/start.sh +0 -0
  90. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/runtime/envs.py +0 -0
  91. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/runtime/inspect.py +0 -0
  92. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/runtime/microvm.py +0 -0
  93. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/runtime/planner.py +0 -0
  94. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/runtime/runner.py +0 -0
  95. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/runtime/toolchain.py +0 -0
  96. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/unified/__init__.py +0 -0
  97. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/unified/model.py +0 -0
  98. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/unified/planner.py +0 -0
  99. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial/unified/providers.py +0 -0
  100. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial_computing.egg-info/dependency_links.txt +0 -0
  101. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial_computing.egg-info/entry_points.txt +0 -0
  102. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial_computing.egg-info/requires.txt +0 -0
  103. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/spatial_computing.egg-info/top_level.txt +0 -0
  104. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/tests/test_auth.py +0 -0
  105. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/tests/test_compute.py +0 -0
  106. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/tests/test_core.py +0 -0
  107. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/tests/test_dashboard.py +0 -0
  108. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/tests/test_domains.py +0 -0
  109. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/tests/test_engines.py +0 -0
  110. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/tests/test_fabric.py +0 -0
  111. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/tests/test_fleet.py +0 -0
  112. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/tests/test_ha.py +0 -0
  113. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/tests/test_hardening.py +0 -0
  114. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/tests/test_interconnect.py +0 -0
  115. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/tests/test_kernel.py +0 -0
  116. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/tests/test_memory.py +0 -0
  117. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/tests/test_platform.py +0 -0
  118. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/tests/test_platform2.py +0 -0
  119. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/tests/test_qr.py +0 -0
  120. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/tests/test_quorum.py +0 -0
  121. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/tests/test_real_servers.py +0 -0
  122. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/tests/test_runtime.py +0 -0
  123. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/tests/test_sso.py +0 -0
  124. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/tests/test_unified.py +0 -0
  125. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/tests/test_v02.py +0 -0
  126. {spatial_computing-0.23.0 → spatial_computing-0.24.0}/tests/test_v03.py +0 -0
  127. {spatial_computing-0.23.0 → spatial_computing-0.24.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.23.0
3
+ Version: 0.24.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
@@ -101,6 +101,7 @@ st.put(0, b"..." * 1000); st.get(0); print(st.stats())
101
101
  | Tiered memory (hot / compressed / far) | operational prototype | `tests/test_memory.py`, `benchmarks/bench_memory.py` |
102
102
  | Runtime Engine (inspect binaries, route, micro-VM, WASI, containers incl. ARM64 via emulation) | operational prototype | `tests/test_runtime.py`, `benchmarks/bench_runtime.py` |
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
+ | Live GPU market prices (`spatial market`, read-only, no account) | first components | `tests/test_market.py`, [docs/MARKET.md](docs/MARKET.md) |
104
105
  | AI, Intelligence | first components (toy model) | `tests/test_engines.py`, `tests/test_domains.py` |
105
106
 
106
107
  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).
@@ -75,6 +75,7 @@ st.put(0, b"..." * 1000); st.get(0); print(st.stats())
75
75
  | Tiered memory (hot / compressed / far) | operational prototype | `tests/test_memory.py`, `benchmarks/bench_memory.py` |
76
76
  | Runtime Engine (inspect binaries, route, micro-VM, WASI, containers incl. ARM64 via emulation) | operational prototype | `tests/test_runtime.py`, `benchmarks/bench_runtime.py` |
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
+ | Live GPU market prices (`spatial market`, read-only, no account) | first components | `tests/test_market.py`, [docs/MARKET.md](docs/MARKET.md) |
78
79
  | AI, Intelligence | first components (toy model) | `tests/test_engines.py`, `tests/test_domains.py` |
79
80
 
80
81
  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.23.0"
7
+ version = "0.24.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.23.0"
6
+ __version__ = "0.24.0"
@@ -239,6 +239,33 @@ def cmd_devices(a):
239
239
  return 0
240
240
 
241
241
 
242
+ def cmd_market(a):
243
+ from .market import MarketError, cheapest, fetch_offers, spread_vs
244
+ try:
245
+ offers = fetch_offers()
246
+ except MarketError as e:
247
+ print(f"spatial: {e}", file=sys.stderr)
248
+ return 1
249
+ if a.neocloud_usd_per_hour is not None:
250
+ r = spread_vs(offers, a.gpu, a.neocloud_usd_per_hour, a.min_reliability)
251
+ if r is None:
252
+ print(f"spatial: no Vast.ai offer for {a.gpu!r} at reliability >= {a.min_reliability} right now", file=sys.stderr)
253
+ return 1
254
+ o = r["offer"]
255
+ print(f"cheapest {a.gpu} on Vast.ai right now: {r['market_usd_h']:.3f} $/h (reliability {o.reliability:.3f}, {o.geolocation})")
256
+ print(f"your neocloud reference: {r['neocloud_usd_h']:.3f} $/h")
257
+ print(f"spread: {r['spread_usd_h']:+.3f} $/h ({r['spread_pct']:+.1f} %)")
258
+ return 0
259
+ c = cheapest(offers, a.gpu, a.min_reliability)
260
+ if c is None:
261
+ print(f"spatial: no Vast.ai offer for {a.gpu!r} at reliability >= {a.min_reliability} right now", file=sys.stderr)
262
+ return 1
263
+ print(f"{c.gpu_name}: {c.usd_per_hour_per_gpu:.3f} $/h per whole GPU (listing {c.usd_per_hour:.3f} $/h at frac {c.gpu_frac:g}), "
264
+ f"reliability {c.reliability:.3f}, {c.geolocation}")
265
+ print(f"({len(offers)} live offers read from Vast.ai's public marketplace just now; no account, no money spent)")
266
+ return 0
267
+
268
+
242
269
  def cmd_token(a):
243
270
  from .core import auth
244
271
  if a.action == "init":
@@ -313,6 +340,11 @@ def main(argv=None):
313
340
  p.add_argument("--execute", action="store_true", help="run the chosen option and compare with the estimate")
314
341
  p.set_defaults(fn=cmd_optimize)
315
342
  sub.add_parser("devices", help="compute devices the planner can use on this machine (CPU, Metal GPU, NVIDIA GPU)").set_defaults(fn=cmd_devices)
343
+ p = sub.add_parser("market", help="live GPU prices from Vast.ai's public marketplace (read-only, no account, no money spent)")
344
+ p.add_argument("--gpu", default="H100", help="substring to match in the GPU name, e.g. H100, RTX 4090, A100")
345
+ 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")
346
+ 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")
347
+ p.set_defaults(fn=cmd_market)
316
348
  p = sub.add_parser("agent", help="run a fleet agent: measure this machine, report to a hub, run allow-listed tasks")
317
349
  p.add_argument("--hub", required=True, help="host:port of the hub")
318
350
  p.add_argument("--token-file", required=True, help="shared secret file, or a scoped token with fleet:report,fleet:work")
@@ -0,0 +1,12 @@
1
+ """Live GPU market prices, read-only, no account and no money spent.
2
+
3
+ This reads REAL current prices from a real commercial marketplace (Vast.ai's public bundle
4
+ listing, the same data their own search page shows a logged-out visitor). It makes the GPU
5
+ arbitrage pricing idea (see the private business notes) checkable against live numbers instead
6
+ of a hypothesis on paper.
7
+
8
+ What this module does NOT do: rent a GPU, run a job, or spend any money. Renting hardware and
9
+ running a real job on it is a separate, later step that needs an account on the marketplace and
10
+ the user's explicit go-ahead each time, since it spends real money.
11
+ """
12
+ from .vast import MarketError, Offer, cheapest, fetch_offers, parse_offers, spread_vs # noqa: F401
@@ -0,0 +1,85 @@
1
+ """Vast.ai's public GPU marketplace: a real, live, read-only price feed. No API key is used or
2
+ needed for this endpoint (it is the same data their own search page shows a logged-out visitor);
3
+ we never authenticate, never bid, never rent. One real network call per `fetch_offers()`."""
4
+ from __future__ import annotations
5
+
6
+ import json
7
+ import urllib.error
8
+ import urllib.request
9
+ from dataclasses import dataclass
10
+
11
+ BUNDLES_URL = "https://console.vast.ai/api/v0/bundles/"
12
+
13
+
14
+ class MarketError(Exception):
15
+ """The marketplace could not be reached or its response could not be understood. Never
16
+ silently replaced by a stale or made-up price: callers see this and decide what to do."""
17
+
18
+
19
+ @dataclass(frozen=True)
20
+ class Offer:
21
+ gpu_name: str
22
+ num_gpus: int
23
+ gpu_frac: float # fraction of ONE physical GPU this listing gives you (1.0 = a whole GPU)
24
+ usd_per_hour: float # dph_total: Vast.ai's own all-in price for this listing (their fee included)
25
+ reliability: float # Vast.ai's own 0..1 host score; not independently verified here
26
+ geolocation: str
27
+
28
+ @property
29
+ def usd_per_hour_per_gpu(self) -> float:
30
+ """Normalised to one whole GPU, so a fractional/shared listing compares fairly with a
31
+ dedicated one (a listing with gpu_frac 0.25 at $0.21/h is $0.86/h for a whole GPU)."""
32
+ return self.usd_per_hour / self.gpu_frac if self.gpu_frac else self.usd_per_hour
33
+
34
+
35
+ def parse_offers(data: dict) -> list[Offer]:
36
+ """`data` is the parsed JSON body of a GET to BUNDLES_URL (or a fixture of the same shape,
37
+ for tests: no network, no live prices, see tests/data/vast_bundles_sample.json)."""
38
+ out = []
39
+ for o in data.get("offers") or []:
40
+ try:
41
+ out.append(Offer(
42
+ gpu_name=str(o["gpu_name"]), num_gpus=int(o["num_gpus"]), gpu_frac=float(o.get("gpu_frac") or 1.0),
43
+ usd_per_hour=float(o["dph_total"]), reliability=float(o.get("reliability") or 0.0),
44
+ geolocation=str(o.get("geolocation") or "?")))
45
+ except (KeyError, TypeError, ValueError):
46
+ continue # one malformed listing is skipped, not a reason to fail the whole fetch
47
+ return out
48
+
49
+
50
+ def fetch_offers(timeout_s: float = 15.0) -> list[Offer]:
51
+ """A real network call to Vast.ai's public marketplace endpoint. Raises MarketError on any
52
+ failure (network, non-200, malformed JSON) instead of returning stale or fabricated data."""
53
+ req = urllib.request.Request(BUNDLES_URL, headers={"Accept": "application/json", "User-Agent": "spatial-computing-market/1"})
54
+ try:
55
+ with urllib.request.urlopen(req, timeout=timeout_s) as r:
56
+ if r.status != 200:
57
+ raise MarketError(f"Vast.ai returned HTTP {r.status}")
58
+ data = json.loads(r.read())
59
+ except MarketError:
60
+ raise
61
+ except (urllib.error.URLError, TimeoutError, json.JSONDecodeError, OSError) as e:
62
+ raise MarketError(f"could not reach or parse Vast.ai's marketplace ({type(e).__name__}: {e})") from e
63
+ return parse_offers(data)
64
+
65
+
66
+ def cheapest(offers: list[Offer], gpu_name_contains: str, min_reliability: float = 0.5) -> Offer | None:
67
+ """The lowest per-whole-GPU price among offers whose name contains `gpu_name_contains`
68
+ (case-insensitive) and whose reliability is at least `min_reliability` (default 0.5: an
69
+ unreliable host is not a fair price to quote as THE price). None if nothing matches."""
70
+ cand = [o for o in offers if gpu_name_contains.lower() in o.gpu_name.lower() and o.reliability >= min_reliability]
71
+ return min(cand, key=lambda o: o.usd_per_hour_per_gpu) if cand else None
72
+
73
+
74
+ def spread_vs(offers: list[Offer], gpu_name_contains: str, neocloud_usd_per_hour: float,
75
+ min_reliability: float = 0.5) -> dict | None:
76
+ """The arbitrage spread: the gap between the cheapest sufficiently-reliable marketplace price
77
+ for this GPU and a 'neocloud'/list price the CALLER supplies (never invented here). None if no
78
+ offer matches. `min_reliability` defaults to 0.5: an unreliable host is not a fair price to quote."""
79
+ c = cheapest(offers, gpu_name_contains, min_reliability)
80
+ if c is None:
81
+ return None
82
+ spread = neocloud_usd_per_hour - c.usd_per_hour_per_gpu
83
+ return {"market_usd_h": c.usd_per_hour_per_gpu, "neocloud_usd_h": neocloud_usd_per_hour,
84
+ "spread_usd_h": spread, "spread_pct": (spread / neocloud_usd_per_hour * 100) if neocloud_usd_per_hour else None,
85
+ "offer": c}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: spatial-computing
3
- Version: 0.23.0
3
+ Version: 0.24.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
@@ -101,6 +101,7 @@ st.put(0, b"..." * 1000); st.get(0); print(st.stats())
101
101
  | Tiered memory (hot / compressed / far) | operational prototype | `tests/test_memory.py`, `benchmarks/bench_memory.py` |
102
102
  | Runtime Engine (inspect binaries, route, micro-VM, WASI, containers incl. ARM64 via emulation) | operational prototype | `tests/test_runtime.py`, `benchmarks/bench_runtime.py` |
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
+ | Live GPU market prices (`spatial market`, read-only, no account) | first components | `tests/test_market.py`, [docs/MARKET.md](docs/MARKET.md) |
104
105
  | AI, Intelligence | first components (toy model) | `tests/test_engines.py`, `tests/test_domains.py` |
105
106
 
106
107
  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).
@@ -43,6 +43,8 @@ spatial/interconnect/tasks.py
43
43
  spatial/kernel/__init__.py
44
44
  spatial/kernel/dsl.py
45
45
  spatial/kernel/library.py
46
+ spatial/market/__init__.py
47
+ spatial/market/vast.py
46
48
  spatial/memory/__init__.py
47
49
  spatial/memory/fararray.py
48
50
  spatial/memory/pageserver.py
@@ -108,6 +110,7 @@ tests/test_ha.py
108
110
  tests/test_hardening.py
109
111
  tests/test_interconnect.py
110
112
  tests/test_kernel.py
113
+ tests/test_market.py
111
114
  tests/test_memory.py
112
115
  tests/test_platform.py
113
116
  tests/test_platform2.py
@@ -0,0 +1,72 @@
1
+ """Live GPU market prices (spatial.market): parsing tested against a frozen real sample, no
2
+ network; one test makes a REAL call to Vast.ai's public marketplace and skips gracefully if it
3
+ cannot be reached (CI network policy, outage, or the endpoint changing shape)."""
4
+ import json
5
+ from pathlib import Path
6
+
7
+ import pytest
8
+
9
+ from spatial.market import MarketError, cheapest, fetch_offers, parse_offers, spread_vs
10
+
11
+ FIXTURE = json.loads((Path(__file__).parent / "data" / "vast_bundles_sample.json").read_text())
12
+
13
+
14
+ def test_parse_offers_reads_a_real_sample_shape():
15
+ offers = parse_offers(FIXTURE)
16
+ assert len(offers) == 10
17
+ names = {o.gpu_name for o in offers}
18
+ assert "H100 NVL" in names and "RTX 4090" in names
19
+ h100 = [o for o in offers if o.gpu_name == "H100 NVL"]
20
+ assert len(h100) == 2 and {round(o.reliability, 3) for o in h100} == {0.998, 0.2}
21
+
22
+
23
+ def test_parse_offers_skips_a_malformed_listing_instead_of_failing():
24
+ bad = {"offers": [{"gpu_name": "X"}, {"gpu_name": "RTX 4090", "num_gpus": 1, "dph_total": 0.5, "gpu_frac": 1.0, "reliability": 0.9, "geolocation": "?"}]}
25
+ offers = parse_offers(bad)
26
+ assert len(offers) == 1 and offers[0].gpu_name == "RTX 4090"
27
+ assert parse_offers({}) == [] and parse_offers({"offers": None}) == []
28
+
29
+
30
+ def test_usd_per_hour_per_gpu_normalises_a_fractional_listing():
31
+ offers = parse_offers(FIXTURE)
32
+ frac = next(o for o in offers if o.gpu_frac == 0.25)
33
+ assert frac.usd_per_hour_per_gpu == pytest.approx(frac.usd_per_hour / 0.25)
34
+ whole = next(o for o in offers if o.gpu_frac == 1.0)
35
+ assert whole.usd_per_hour_per_gpu == whole.usd_per_hour
36
+
37
+
38
+ def test_cheapest_excludes_low_reliability_offers_by_default():
39
+ offers = parse_offers(FIXTURE)
40
+ c = cheapest(offers, "H100")
41
+ assert c is not None and c.reliability == pytest.approx(0.998) # the $1.50/h, reliability-0.2 listing is excluded
42
+ c_any = cheapest(offers, "H100", min_reliability=0.0)
43
+ assert c_any.reliability == pytest.approx(0.2) # with the filter open, the cheaper-but-unreliable one wins
44
+ assert cheapest(offers, "no such gpu") is None
45
+
46
+
47
+ def test_spread_vs_computes_the_arbitrage_gap_against_a_caller_supplied_price():
48
+ offers = parse_offers(FIXTURE)
49
+ r = spread_vs(offers, "H100", neocloud_usd_per_hour=4.0)
50
+ assert r["market_usd_h"] == pytest.approx(2.336)
51
+ assert r["spread_usd_h"] == pytest.approx(4.0 - 2.336)
52
+ assert r["spread_pct"] == pytest.approx((4.0 - 2.336) / 4.0 * 100)
53
+ assert r["offer"].gpu_name == "H100 NVL"
54
+ assert spread_vs(offers, "no such gpu", 4.0) is None
55
+ assert spread_vs(offers, "H100", 0.0) is not None and spread_vs(offers, "H100", 0.0)["spread_pct"] is None # no division by zero
56
+
57
+
58
+ def _vast_reachable():
59
+ try:
60
+ fetch_offers(timeout_s=5.0)
61
+ return True
62
+ except MarketError:
63
+ return False
64
+
65
+
66
+ @pytest.mark.skipif(not _vast_reachable(), reason="Vast.ai's public marketplace is not reachable from here right now")
67
+ def test_fetch_offers_is_a_real_live_call_with_plausible_prices():
68
+ offers = fetch_offers()
69
+ assert len(offers) > 0
70
+ assert all(o.usd_per_hour >= 0 and 0.0 <= o.reliability <= 1.0 for o in offers)
71
+ gpu_names = {o.gpu_name for o in offers}
72
+ assert any("RTX" in n or "A100" in n or "H100" in n or "L4" in n or "4090" in n for n in gpu_names) # a real marketplace, not an empty shell