spatial-computing 0.23.0__tar.gz → 0.25.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.25.0}/PKG-INFO +2 -1
  2. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/README.md +1 -0
  3. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/pyproject.toml +1 -1
  4. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/__init__.py +1 -1
  5. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/cli.py +42 -0
  6. spatial_computing-0.25.0/spatial/market/__init__.py +15 -0
  7. spatial_computing-0.25.0/spatial/market/vast.py +124 -0
  8. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial_computing.egg-info/PKG-INFO +2 -1
  9. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial_computing.egg-info/SOURCES.txt +3 -0
  10. spatial_computing-0.25.0/tests/test_market.py +108 -0
  11. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/LICENSE +0 -0
  12. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/setup.cfg +0 -0
  13. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/ai/__init__.py +0 -0
  14. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/ai/kvcache.py +0 -0
  15. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/ai/llm.py +0 -0
  16. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/compute/__init__.py +0 -0
  17. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/compute/cost.py +0 -0
  18. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/compute/detect.py +0 -0
  19. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/compute/monitor.py +0 -0
  20. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/compute/scheduler.py +0 -0
  21. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/compute/taskqueue.py +0 -0
  22. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/compute/worker.py +0 -0
  23. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/compute/workloads.py +0 -0
  24. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/core/__init__.py +0 -0
  25. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/core/auth.py +0 -0
  26. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/core/energy.py +0 -0
  27. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/core/ledger.py +0 -0
  28. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/core/model.py +0 -0
  29. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/core/protocol.py +0 -0
  30. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/core/registry.py +0 -0
  31. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/fabric/__init__.py +0 -0
  32. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/fabric/cuda.py +0 -0
  33. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/fabric/devices.py +0 -0
  34. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/fabric/metal.py +0 -0
  35. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/fabric/metal_mandel.swift +0 -0
  36. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/fabric/metal_run.swift +0 -0
  37. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/fleet/__init__.py +0 -0
  38. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/fleet/agent.py +0 -0
  39. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/fleet/alerts.py +0 -0
  40. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/fleet/dashboard.py +0 -0
  41. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/fleet/ha.py +0 -0
  42. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/fleet/hub.py +0 -0
  43. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/intelligence/__init__.py +0 -0
  44. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/intelligence/predictor.py +0 -0
  45. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/interconnect/__init__.py +0 -0
  46. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/interconnect/collectives.py +0 -0
  47. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/interconnect/comm.py +0 -0
  48. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/interconnect/model.py +0 -0
  49. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/interconnect/tasks.py +0 -0
  50. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/kernel/__init__.py +0 -0
  51. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/kernel/dsl.py +0 -0
  52. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/kernel/library.py +0 -0
  53. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/memory/__init__.py +0 -0
  54. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/memory/fararray.py +0 -0
  55. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/memory/pageserver.py +0 -0
  56. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/memory/secure.py +0 -0
  57. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/memory/shared.py +0 -0
  58. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/memory/tiered.py +0 -0
  59. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/platform/__init__.py +0 -0
  60. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/platform/billing.py +0 -0
  61. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/platform/db.py +0 -0
  62. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/platform/invoice_rules.py +0 -0
  63. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/platform/mailer.py +0 -0
  64. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/platform/oidc.py +0 -0
  65. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/platform/pdf.py +0 -0
  66. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/platform/qr.py +0 -0
  67. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/platform/security.py +0 -0
  68. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/platform/server.py +0 -0
  69. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/platform/service.py +0 -0
  70. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/platform/static/app.js +0 -0
  71. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/platform/static/fonts/DMMono-normal-400.woff2 +0 -0
  72. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/platform/static/fonts/DMMono-normal-500.woff2 +0 -0
  73. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/platform/static/fonts/InstrumentSerif-italic-400.woff2 +0 -0
  74. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/platform/static/fonts/InstrumentSerif-normal-400.woff2 +0 -0
  75. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/platform/static/fonts/Inter-normal-400.woff2 +0 -0
  76. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/platform/static/fonts/Inter-normal-500.woff2 +0 -0
  77. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/platform/static/fonts/Inter-normal-600.woff2 +0 -0
  78. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/platform/static/fonts.css +0 -0
  79. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/platform/static/index.html +0 -0
  80. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/platform/static/logo.svg +0 -0
  81. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/platform/static/style.css +0 -0
  82. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/platform/totp.py +0 -0
  83. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/platform/ubl.py +0 -0
  84. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/platform/vat.py +0 -0
  85. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/runtime/__init__.py +0 -0
  86. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/runtime/arch.py +0 -0
  87. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/runtime/desktop/Dockerfile +0 -0
  88. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/runtime/desktop/__init__.py +0 -0
  89. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/runtime/desktop/start.sh +0 -0
  90. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/runtime/envs.py +0 -0
  91. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/runtime/inspect.py +0 -0
  92. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/runtime/microvm.py +0 -0
  93. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/runtime/planner.py +0 -0
  94. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/runtime/runner.py +0 -0
  95. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/runtime/toolchain.py +0 -0
  96. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/unified/__init__.py +0 -0
  97. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/unified/model.py +0 -0
  98. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/unified/planner.py +0 -0
  99. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial/unified/providers.py +0 -0
  100. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial_computing.egg-info/dependency_links.txt +0 -0
  101. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial_computing.egg-info/entry_points.txt +0 -0
  102. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial_computing.egg-info/requires.txt +0 -0
  103. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/spatial_computing.egg-info/top_level.txt +0 -0
  104. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/tests/test_auth.py +0 -0
  105. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/tests/test_compute.py +0 -0
  106. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/tests/test_core.py +0 -0
  107. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/tests/test_dashboard.py +0 -0
  108. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/tests/test_domains.py +0 -0
  109. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/tests/test_engines.py +0 -0
  110. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/tests/test_fabric.py +0 -0
  111. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/tests/test_fleet.py +0 -0
  112. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/tests/test_ha.py +0 -0
  113. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/tests/test_hardening.py +0 -0
  114. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/tests/test_interconnect.py +0 -0
  115. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/tests/test_kernel.py +0 -0
  116. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/tests/test_memory.py +0 -0
  117. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/tests/test_platform.py +0 -0
  118. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/tests/test_platform2.py +0 -0
  119. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/tests/test_qr.py +0 -0
  120. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/tests/test_quorum.py +0 -0
  121. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/tests/test_real_servers.py +0 -0
  122. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/tests/test_runtime.py +0 -0
  123. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/tests/test_sso.py +0 -0
  124. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/tests/test_unified.py +0 -0
  125. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/tests/test_v02.py +0 -0
  126. {spatial_computing-0.23.0 → spatial_computing-0.25.0}/tests/test_v03.py +0 -0
  127. {spatial_computing-0.23.0 → spatial_computing-0.25.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.25.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.25.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.25.0"
@@ -239,6 +239,42 @@ def cmd_devices(a):
239
239
  return 0
240
240
 
241
241
 
242
+ def cmd_market(a):
243
+ from .market import MarketError, cheapest, cheapest_for, fetch_offers, spread_for, 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
+ label = f"vertical {a.vertical!r}" if a.vertical else a.gpu
250
+ try:
251
+ if a.neocloud_usd_per_hour is not None:
252
+ r = spread_for(offers, a.vertical, a.neocloud_usd_per_hour, a.min_reliability) if a.vertical else \
253
+ spread_vs(offers, a.gpu, a.neocloud_usd_per_hour, a.min_reliability)
254
+ else:
255
+ r = None
256
+ c = cheapest_for(offers, a.vertical, a.min_reliability) if a.vertical else cheapest(offers, a.gpu, a.min_reliability)
257
+ except MarketError as e:
258
+ print(f"spatial: {e}", file=sys.stderr)
259
+ return 1
260
+ if a.neocloud_usd_per_hour is not None:
261
+ if r is None:
262
+ print(f"spatial: no Vast.ai offer for {label} at reliability >= {a.min_reliability} right now", file=sys.stderr)
263
+ return 1
264
+ o = r["offer"]
265
+ print(f"cheapest {label} on Vast.ai right now: {r['market_usd_h']:.3f} $/h ({o.gpu_name}, reliability {o.reliability:.3f}, {o.geolocation})")
266
+ print(f"your neocloud reference: {r['neocloud_usd_h']:.3f} $/h")
267
+ print(f"spread: {r['spread_usd_h']:+.3f} $/h ({r['spread_pct']:+.1f} %)")
268
+ return 0
269
+ if c is None:
270
+ print(f"spatial: no Vast.ai offer for {label} at reliability >= {a.min_reliability} right now", file=sys.stderr)
271
+ return 1
272
+ 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}), "
273
+ f"reliability {c.reliability:.3f}, {c.geolocation}")
274
+ print(f"({len(offers)} live offers read from Vast.ai's public marketplace just now; no account, no money spent)")
275
+ return 0
276
+
277
+
242
278
  def cmd_token(a):
243
279
  from .core import auth
244
280
  if a.action == "init":
@@ -313,6 +349,12 @@ def main(argv=None):
313
349
  p.add_argument("--execute", action="store_true", help="run the chosen option and compare with the estimate")
314
350
  p.set_defaults(fn=cmd_optimize)
315
351
  sub.add_parser("devices", help="compute devices the planner can use on this machine (CPU, Metal GPU, NVIDIA GPU)").set_defaults(fn=cmd_devices)
352
+ p = sub.add_parser("market", help="live GPU prices from Vast.ai's public marketplace (read-only, no account, no money spent)")
353
+ p.add_argument("--gpu", default="H100", help="substring to match in the GPU name, e.g. H100, RTX 4090, A100 (ignored if --vertical is given)")
354
+ p.add_argument("--vertical", choices=["render"], help="a preset list of interchangeable GPUs for a market instead of one chip (currently: render = 3D rendering/VFX render-farm cards)")
355
+ 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")
356
+ 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")
357
+ p.set_defaults(fn=cmd_market)
316
358
  p = sub.add_parser("agent", help="run a fleet agent: measure this machine, report to a hub, run allow-listed tasks")
317
359
  p.add_argument("--hub", required=True, help="host:port of the hub")
318
360
  p.add_argument("--token-file", required=True, help="shared secret file, or a scoped token with fleet:report,fleet:work")
@@ -0,0 +1,15 @@
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 ( # noqa: F401
13
+ VERTICALS, MarketError, Offer, cheapest, cheapest_among, cheapest_for, fetch_offers,
14
+ parse_offers, spread_among, spread_for, spread_vs,
15
+ )
@@ -0,0 +1,124 @@
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
+ return cheapest_among(offers, (gpu_name_contains,), min_reliability)
71
+
72
+
73
+ def cheapest_among(offers: list[Offer], gpu_names: tuple[str, ...], min_reliability: float = 0.5) -> Offer | None:
74
+ """Like `cheapest()`, but matches ANY of several GPU names (case-insensitive substring): for a
75
+ market made of several interchangeable models — e.g. render/VFX render-farm cards — rather
76
+ than one specific chip. None if nothing matches."""
77
+ cand = [o for o in offers if any(n.lower() in o.gpu_name.lower() for n in gpu_names) and o.reliability >= min_reliability]
78
+ return min(cand, key=lambda o: o.usd_per_hour_per_gpu) if cand else None
79
+
80
+
81
+ def _spread(c: Offer | None, neocloud_usd_per_hour: float) -> dict | None:
82
+ if c is None:
83
+ return None
84
+ spread = neocloud_usd_per_hour - c.usd_per_hour_per_gpu
85
+ return {"market_usd_h": c.usd_per_hour_per_gpu, "neocloud_usd_h": neocloud_usd_per_hour,
86
+ "spread_usd_h": spread, "spread_pct": (spread / neocloud_usd_per_hour * 100) if neocloud_usd_per_hour else None,
87
+ "offer": c}
88
+
89
+
90
+ def spread_vs(offers: list[Offer], gpu_name_contains: str, neocloud_usd_per_hour: float,
91
+ min_reliability: float = 0.5) -> dict | None:
92
+ """The arbitrage spread: the gap between the cheapest sufficiently-reliable marketplace price
93
+ for this GPU and a 'neocloud'/list price the CALLER supplies (never invented here). None if no
94
+ offer matches. `min_reliability` defaults to 0.5: an unreliable host is not a fair price to quote."""
95
+ return _spread(cheapest(offers, gpu_name_contains, min_reliability), neocloud_usd_per_hour)
96
+
97
+
98
+ def spread_among(offers: list[Offer], gpu_names: tuple[str, ...], neocloud_usd_per_hour: float,
99
+ min_reliability: float = 0.5) -> dict | None:
100
+ """The arbitrage spread over `cheapest_among()` instead of one specific chip."""
101
+ return _spread(cheapest_among(offers, gpu_names, min_reliability), neocloud_usd_per_hour)
102
+
103
+
104
+ # Presentation presets, same pattern as pk_rtb/pk_credit/... over batch_score (spatial.kernel):
105
+ # a name over the SAME mechanism (cheapest_among/spread_among), not a different one. No code is
106
+ # duplicated per vertical; only the list of GPU names differs.
107
+ VERTICALS: dict[str, tuple[str, ...]] = {
108
+ # 3D rendering / VFX render farms: the cards render engines (Octane, Redshift, V-Ray) are
109
+ # commonly benchmarked and sold against. Not the datacenter chips (H100/A100/B200).
110
+ "render": ("RTX 4090", "RTX 5090", "RTX 4080", "RTX 5080", "RTX PRO 6000", "RTX PRO 5000", "RTX A6000", "RTX 6000 Ada"),
111
+ }
112
+
113
+
114
+ def cheapest_for(offers: list[Offer], vertical: str, min_reliability: float = 0.5) -> Offer | None:
115
+ """`vertical` is a key of VERTICALS (currently: "render")."""
116
+ if vertical not in VERTICALS:
117
+ raise MarketError(f"unknown vertical {vertical!r}; known: {', '.join(VERTICALS)}")
118
+ return cheapest_among(offers, VERTICALS[vertical], min_reliability)
119
+
120
+
121
+ def spread_for(offers: list[Offer], vertical: str, neocloud_usd_per_hour: float, min_reliability: float = 0.5) -> dict | None:
122
+ if vertical not in VERTICALS:
123
+ raise MarketError(f"unknown vertical {vertical!r}; known: {', '.join(VERTICALS)}")
124
+ return spread_among(offers, VERTICALS[vertical], neocloud_usd_per_hour, min_reliability)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: spatial-computing
3
- Version: 0.23.0
3
+ Version: 0.25.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,108 @@
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 VERTICALS, MarketError, cheapest, cheapest_among, cheapest_for, fetch_offers, parse_offers, spread_among, spread_for, 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 test_cheapest_among_matches_any_of_several_gpu_names():
59
+ offers = parse_offers(FIXTURE)
60
+ c = cheapest_among(offers, ("RTX 4090", "RTX 5090"))
61
+ assert c is not None and c.gpu_name in ("RTX 4090", "RTX 5090", "RTX 4090D") # substring match: "RTX 4090" also matches "RTX 4090D"
62
+ assert cheapest_among(offers, ("no such gpu",)) is None
63
+
64
+
65
+ def test_render_vertical_is_the_same_mechanism_as_cheapest_among():
66
+ offers = parse_offers(FIXTURE)
67
+ assert "render" in VERTICALS and len(VERTICALS["render"]) > 1
68
+ direct = cheapest_among(offers, VERTICALS["render"])
69
+ via_name = cheapest_for(offers, "render")
70
+ assert direct == via_name # cheapest_for("render") is NOT a different algorithm, just this preset
71
+ with pytest.raises(MarketError, match="unknown vertical"):
72
+ cheapest_for(offers, "no-such-vertical")
73
+
74
+
75
+ def test_spread_for_render_matches_spread_among_the_same_preset():
76
+ offers = parse_offers(FIXTURE)
77
+ a = spread_among(offers, VERTICALS["render"], neocloud_usd_per_hour=1.5)
78
+ b = spread_for(offers, "render", neocloud_usd_per_hour=1.5)
79
+ assert a == b
80
+ with pytest.raises(MarketError, match="unknown vertical"):
81
+ spread_for(offers, "no-such-vertical", 1.5)
82
+
83
+
84
+ # One real network call for the whole module (not one per test): avoids the flakiness of hitting
85
+ # a live third-party endpoint twice in quick succession, which happened in practice (TLS handshake
86
+ # timeouts under load). Every "live" assertion below reuses this single fetch.
87
+ try:
88
+ _LIVE_OFFERS = fetch_offers(timeout_s=20.0)
89
+ except MarketError:
90
+ _LIVE_OFFERS = None
91
+
92
+ needs_live_market = pytest.mark.skipif(_LIVE_OFFERS is None, reason="Vast.ai's public marketplace is not reachable from here right now")
93
+
94
+
95
+ @needs_live_market
96
+ def test_fetch_offers_is_a_real_live_call_with_plausible_prices():
97
+ offers = _LIVE_OFFERS
98
+ assert len(offers) > 0
99
+ assert all(o.usd_per_hour >= 0 and 0.0 <= o.reliability <= 1.0 for o in offers)
100
+ gpu_names = {o.gpu_name for o in offers}
101
+ 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
102
+
103
+
104
+ @needs_live_market
105
+ def test_render_vertical_finds_a_real_live_offer():
106
+ c = cheapest_for(_LIVE_OFFERS, "render")
107
+ if c is not None: # a real marketplace can genuinely have none in stock right now
108
+ assert c.usd_per_hour_per_gpu > 0 and c.reliability >= 0.5