gpuhedge 0.1.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.
- gpuhedge-0.1.0/LICENSE +179 -0
- gpuhedge-0.1.0/MANIFEST.in +3 -0
- gpuhedge-0.1.0/PKG-INFO +275 -0
- gpuhedge-0.1.0/README.md +225 -0
- gpuhedge-0.1.0/pyproject.toml +83 -0
- gpuhedge-0.1.0/setup.cfg +4 -0
- gpuhedge-0.1.0/src/gpuhedge/__init__.py +32 -0
- gpuhedge-0.1.0/src/gpuhedge/__main__.py +8 -0
- gpuhedge-0.1.0/src/gpuhedge/auth.py +100 -0
- gpuhedge-0.1.0/src/gpuhedge/backends/__init__.py +66 -0
- gpuhedge-0.1.0/src/gpuhedge/backends/base.py +183 -0
- gpuhedge-0.1.0/src/gpuhedge/backends/cerebrium_backend.py +415 -0
- gpuhedge-0.1.0/src/gpuhedge/backends/http_backend.py +284 -0
- gpuhedge-0.1.0/src/gpuhedge/backends/modal_backend.py +168 -0
- gpuhedge-0.1.0/src/gpuhedge/backends/runpod_backend.py +281 -0
- gpuhedge-0.1.0/src/gpuhedge/backends/sim_backend.py +197 -0
- gpuhedge-0.1.0/src/gpuhedge/benchmark/__init__.py +7 -0
- gpuhedge-0.1.0/src/gpuhedge/benchmark/cancel_audit.py +156 -0
- gpuhedge-0.1.0/src/gpuhedge/benchmark/cascade.py +263 -0
- gpuhedge-0.1.0/src/gpuhedge/benchmark/controller.py +145 -0
- gpuhedge-0.1.0/src/gpuhedge/benchmark/demo.py +216 -0
- gpuhedge-0.1.0/src/gpuhedge/benchmark/live_hedge.py +154 -0
- gpuhedge-0.1.0/src/gpuhedge/benchmark/live_stage.py +148 -0
- gpuhedge-0.1.0/src/gpuhedge/benchmark/qualify.py +164 -0
- gpuhedge-0.1.0/src/gpuhedge/benchmark/replay.py +382 -0
- gpuhedge-0.1.0/src/gpuhedge/benchmark/report.py +170 -0
- gpuhedge-0.1.0/src/gpuhedge/benchmark/round.py +169 -0
- gpuhedge-0.1.0/src/gpuhedge/benchmark/state_aware.py +240 -0
- gpuhedge-0.1.0/src/gpuhedge/benchmark/validation.py +199 -0
- gpuhedge-0.1.0/src/gpuhedge/cli.py +466 -0
- gpuhedge-0.1.0/src/gpuhedge/config/benchmark.example.yaml +157 -0
- gpuhedge-0.1.0/src/gpuhedge/config/benchmark.yaml +153 -0
- gpuhedge-0.1.0/src/gpuhedge/config/demo.yaml +99 -0
- gpuhedge-0.1.0/src/gpuhedge/config.py +154 -0
- gpuhedge-0.1.0/src/gpuhedge/policies/__init__.py +153 -0
- gpuhedge-0.1.0/src/gpuhedge/router.py +112 -0
- gpuhedge-0.1.0/src/gpuhedge/telemetry/__init__.py +18 -0
- gpuhedge-0.1.0/src/gpuhedge/telemetry/costs.py +205 -0
- gpuhedge-0.1.0/src/gpuhedge/telemetry/ledger.py +191 -0
- gpuhedge-0.1.0/src/gpuhedge/telemetry/trace.py +55 -0
- gpuhedge-0.1.0/src/gpuhedge/validators/__init__.py +21 -0
- gpuhedge-0.1.0/src/gpuhedge/validators/audio.py +87 -0
- gpuhedge-0.1.0/src/gpuhedge/validators/registry.py +90 -0
- gpuhedge-0.1.0/src/gpuhedge.egg-info/PKG-INFO +275 -0
- gpuhedge-0.1.0/src/gpuhedge.egg-info/SOURCES.txt +49 -0
- gpuhedge-0.1.0/src/gpuhedge.egg-info/dependency_links.txt +1 -0
- gpuhedge-0.1.0/src/gpuhedge.egg-info/entry_points.txt +2 -0
- gpuhedge-0.1.0/src/gpuhedge.egg-info/requires.txt +32 -0
- gpuhedge-0.1.0/src/gpuhedge.egg-info/top_level.txt +1 -0
- gpuhedge-0.1.0/tests/test_gpuhedge.py +182 -0
- gpuhedge-0.1.0/tests/test_policies_sim.py +446 -0
gpuhedge-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
95
|
+
Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work, excluding
|
|
103
|
+
those notices that do not pertain to any part of the Derivative
|
|
104
|
+
Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works.
|
|
111
|
+
|
|
112
|
+
You may add Your own copyright statement to Your modifications and
|
|
113
|
+
may provide additional or different license terms and conditions
|
|
114
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
115
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
116
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
117
|
+
the conditions stated in this License.
|
|
118
|
+
|
|
119
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
120
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
121
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
122
|
+
this License, without any additional terms or conditions.
|
|
123
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
124
|
+
the terms of any separate license agreement you may have executed
|
|
125
|
+
with Licensor regarding such Contributions.
|
|
126
|
+
|
|
127
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
128
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
129
|
+
except as required for reasonable and customary use in describing the
|
|
130
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
131
|
+
|
|
132
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
133
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
134
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
135
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
136
|
+
implied, including, without limitation, any warranties or conditions
|
|
137
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
138
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
139
|
+
appropriateness of using or redistributing the Work and assume any
|
|
140
|
+
risks associated with Your exercise of permissions under this License.
|
|
141
|
+
|
|
142
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
143
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
144
|
+
unless required by applicable law (such as deliberate and grossly
|
|
145
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
146
|
+
liable to You for damages, including any direct, indirect, special,
|
|
147
|
+
incidental, or consequential damages of any character arising as a
|
|
148
|
+
result of this License or out of the use or inability to use the
|
|
149
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
150
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
151
|
+
other commercial damages or losses), even if such Contributor
|
|
152
|
+
has been advised of the possibility of such damages.
|
|
153
|
+
|
|
154
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
155
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
156
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
157
|
+
or other liability obligations and/or rights consistent with this
|
|
158
|
+
License. However, in accepting such obligations, You may act only
|
|
159
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
160
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
161
|
+
defend, and hold each Contributor harmless for any liability
|
|
162
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
163
|
+
of your accepting any such warranty or additional liability.
|
|
164
|
+
|
|
165
|
+
END OF TERMS AND CONDITIONS
|
|
166
|
+
|
|
167
|
+
Copyright 2026 Miroslav Lzicar
|
|
168
|
+
|
|
169
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
170
|
+
you may not use this file except in compliance with the License.
|
|
171
|
+
You may obtain a copy of the License at
|
|
172
|
+
|
|
173
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
174
|
+
|
|
175
|
+
Unless required by applicable law or agreed to in writing, software
|
|
176
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
177
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
178
|
+
See the License for the specific language governing permissions and
|
|
179
|
+
limitations under the License.
|
gpuhedge-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: gpuhedge
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Speculative execution across serverless GPU clouds: race providers, return the first valid result, cancel the loser.
|
|
5
|
+
Author-email: Miroslav Lzicar <miroslav.lzicar@deepmedchem.com>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/mireklzicar/gpuhedge
|
|
8
|
+
Project-URL: Documentation, https://github.com/mireklzicar/gpuhedge#readme
|
|
9
|
+
Project-URL: Repository, https://github.com/mireklzicar/gpuhedge
|
|
10
|
+
Project-URL: Issues, https://github.com/mireklzicar/gpuhedge/issues
|
|
11
|
+
Keywords: serverless-gpu,hedged-requests,speculative-execution,modal,runpod,cerebrium,cold-start,tts
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering
|
|
19
|
+
Classifier: Topic :: System :: Distributed Computing
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: numpy>=1.24
|
|
24
|
+
Requires-Dist: requests>=2.31
|
|
25
|
+
Requires-Dist: PyYAML>=6.0
|
|
26
|
+
Requires-Dist: soundfile>=0.13
|
|
27
|
+
Requires-Dist: rich>=13.7
|
|
28
|
+
Provides-Extra: modal
|
|
29
|
+
Requires-Dist: modal>=1.5; extra == "modal"
|
|
30
|
+
Provides-Extra: runpod
|
|
31
|
+
Requires-Dist: runpod>=1.10; extra == "runpod"
|
|
32
|
+
Requires-Dist: runpod-flash>=1.18; extra == "runpod"
|
|
33
|
+
Provides-Extra: cerebrium
|
|
34
|
+
Requires-Dist: cerebrium>=2.5; extra == "cerebrium"
|
|
35
|
+
Provides-Extra: providers
|
|
36
|
+
Requires-Dist: modal>=1.5; extra == "providers"
|
|
37
|
+
Requires-Dist: runpod>=1.10; extra == "providers"
|
|
38
|
+
Requires-Dist: runpod-flash>=1.18; extra == "providers"
|
|
39
|
+
Requires-Dist: cerebrium>=2.5; extra == "providers"
|
|
40
|
+
Provides-Extra: analysis
|
|
41
|
+
Requires-Dist: matplotlib>=3.8; extra == "analysis"
|
|
42
|
+
Requires-Dist: numpy>=1.26; extra == "analysis"
|
|
43
|
+
Provides-Extra: dev
|
|
44
|
+
Requires-Dist: build>=1.2; extra == "dev"
|
|
45
|
+
Requires-Dist: bump2version>=1.0; extra == "dev"
|
|
46
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
47
|
+
Requires-Dist: ruff>=0.4; extra == "dev"
|
|
48
|
+
Requires-Dist: twine>=5.0; extra == "dev"
|
|
49
|
+
Dynamic: license-file
|
|
50
|
+
|
|
51
|
+
# GPUHedge
|
|
52
|
+
|
|
53
|
+
**State-aware speculative execution for serverless GPUs.**
|
|
54
|
+
|
|
55
|
+
> First valid result wins. Loser cancellation is audited — and the receipt
|
|
56
|
+
> says when the cloud didn't stop.
|
|
57
|
+
|
|
58
|
+
Serverless GPU cold starts are wildly bimodal: the same 17 GB TTS model
|
|
59
|
+
returns complete audio in ~6 s on a warm-path hit but 89–122 s on a miss —
|
|
60
|
+
with nothing in between. In 36 evaluation rounds across three real providers,
|
|
61
|
+
a delayed hedge cut p95 cold-start latency from **116.6 s to 29.4 s**, cut
|
|
62
|
+
60-second deadline misses from **11/36 to 0/36**, and launched a second job on
|
|
63
|
+
only **11/36** requests.
|
|
64
|
+
|
|
65
|
+
The sharper discovery: the primary provider's **queue state at 2.5 seconds**
|
|
66
|
+
predicted every 90–122 s tail with zero overlap in 54 rounds — early enough
|
|
67
|
+
to cancel the queued job *before its worker starts* and reroute. A
|
|
68
|
+
pre-registered live validation found the cutover reduced median latency from
|
|
69
|
+
29.8 s to 22.6 s and cut RunPod-side billed cost from $0.01475 to
|
|
70
|
+
$0.00532/request — but one 104.2 s *hedge-provider* tail made its p95
|
|
71
|
+
advantage estimator-sensitive at n=20 (28.2 s vs 31.0 s under nearest-rank,
|
|
72
|
+
32.0 s vs 31.0 s under linear interpolation), so we don't claim that
|
|
73
|
+
hypothesis. The outlier motivated the **cascaded policy** below. Full
|
|
74
|
+
results are under
|
|
75
|
+
[`benchmarks/2026-07-queue-cutover/`](benchmarks/2026-07-queue-cutover/).
|
|
76
|
+
|
|
77
|
+

|
|
78
|
+
|
|
79
|
+
## What it does
|
|
80
|
+
|
|
81
|
+
GPUHedge races your *own* deployments (containers, weights, custom code)
|
|
82
|
+
across serverless GPU clouds under an SLO policy:
|
|
83
|
+
|
|
84
|
+
1. submit the request to the cheap/fast **primary**;
|
|
85
|
+
2. watch the primary's **lifecycle state** (queue vs running), not just a timer;
|
|
86
|
+
3. launch a **hedge** only when the primary is entering its tail — and
|
|
87
|
+
**escalate to a third provider** when the hedge enters its own
|
|
88
|
+
(`CascadePolicy`, at most two live jobs);
|
|
89
|
+
4. return the **first result that passes validation** (a fast HTTP 200 with
|
|
90
|
+
malformed output does not win);
|
|
91
|
+
5. **cancel every loser** through its provider-native job API and record a
|
|
92
|
+
structured `CancellationReceipt` with an explicit **evidence level**
|
|
93
|
+
(`confirmed_terminal` > `provider_ack` > `request_channel_closed` >
|
|
94
|
+
`no_evidence`), cancellation scope, ack latency, estimated wasted GPU-$,
|
|
95
|
+
and a leak flag that defaults to *leaked* until proof arrives.
|
|
96
|
+
|
|
97
|
+
## Try it in 60 seconds — no accounts, no spend
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
pip install -e .
|
|
101
|
+
gpuhedge demo # simulated providers, real policy engines
|
|
102
|
+
gpuhedge replay traces/moss_rounds.jsonl # reproduce the benchmark tables
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
The demo races a bimodal primary against a steady hedge through the exact
|
|
106
|
+
code paths used against real clouds — including a malformed-result round the
|
|
107
|
+
validator catches and a queued-cancel cutover.
|
|
108
|
+
|
|
109
|
+
## The public API
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
from gpuhedge import Router
|
|
113
|
+
from gpuhedge.policies import StateAwarePolicy
|
|
114
|
+
|
|
115
|
+
router = Router(
|
|
116
|
+
primary="runpod", hedge="cerebrium",
|
|
117
|
+
policy=StateAwarePolicy(queue_cutover_ms=2_500, safety_hedge_ms=8_500),
|
|
118
|
+
)
|
|
119
|
+
outcome = await router.run()
|
|
120
|
+
outcome.winner # "runpod" | "cerebrium"
|
|
121
|
+
outcome.total_ms # end-to-end latency from request start
|
|
122
|
+
outcome.cancellation # the loser's receipt (or None if no hedge launched)
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Policies: `SingleProvider()`, `FixedHedgePolicy(hedge_after_ms)`,
|
|
126
|
+
`StateAwarePolicy(queue_cutover_ms, safety_hedge_ms)`, and
|
|
127
|
+
`CascadePolicy(queue_cutover_ms, safety_hedge_ms, escalate_after_ms)` (pass
|
|
128
|
+
`fallback="modal"` to the Router). Policies are dispatched through one
|
|
129
|
+
protocol method — implement `async def execute(self, ctx)` plus
|
|
130
|
+
`min_providers` and your own policy runs exactly like the built-ins.
|
|
131
|
+
Validators are pluggable (`wav`, `json`, `nonempty`, or
|
|
132
|
+
`register_validator("mine")(...)`).
|
|
133
|
+
|
|
134
|
+
Providers are YAML: built-in adapters for **RunPod** (Flash queue SDK +
|
|
135
|
+
REST), **Modal** (`FunctionCall.spawn`/`cancel`), **Cerebrium** (sync-first
|
|
136
|
+
REST), a **simulator** (`adapter: sim`), and a **generic HTTP adapter**
|
|
137
|
+
(`adapter: http`) that turns any submit/status/result/cancel service into a
|
|
138
|
+
raceable backend without writing Python — see
|
|
139
|
+
[`docs/adding-a-provider.md`](docs/adding-a-provider.md).
|
|
140
|
+
|
|
141
|
+
## The benchmark (2026-07, MOSS-TTS-v1.5, three providers)
|
|
142
|
+
|
|
143
|
+
Same 17 GB model, same commit, same request, pre-seeded weights, identical
|
|
144
|
+
WAV validation on every arm. 54 paired cold-start rounds + warm companions,
|
|
145
|
+
18 live hedged requests, ~$7 of GPU spend, every trace committed under
|
|
146
|
+
[`traces/`](traces/) (sanitized: job ids remapped, account balances withheld,
|
|
147
|
+
deployment identifiers replaced — every latency, receipt, and cost delta is
|
|
148
|
+
untouched, so all tables and figures reproduce identically). Full method and
|
|
149
|
+
results: [`benchmarks/2026-07-moss/`](benchmarks/2026-07-moss/). Regenerate
|
|
150
|
+
the figures with `pip install -e ".[analysis]" && python
|
|
151
|
+
benchmarks/2026-07-moss/analysis.py` (CI does this on every push).
|
|
152
|
+
|
|
153
|
+
| Policy (36 evaluation rounds) | p50 | p95 | miss>60 s | active $/req | hedge rate |
|
|
154
|
+
| --- | ---: | ---: | ---: | ---: | ---: |
|
|
155
|
+
| single: primary (RTX 4090) | 6.0 s | 116.6 s | 11/36 | $0.0114 | — |
|
|
156
|
+
| fixed hedge @10 s | 6.0 s | 29.4 s | 0/36 | $0.0083 | 11/36 |
|
|
157
|
+
| queue cutover @2.5 s (replay*) | 6.0 s | 21.9 s | 0/36 | $0.0056 | 11/36 |
|
|
158
|
+
| cascade →modal @25 s (replay*) | 6.0 s | 21.9 s | 0/36 | $0.0056 | 11/36 |
|
|
159
|
+
|
|
160
|
+
\* the cutover and cascade rows are post-hoc replays on data that informed
|
|
161
|
+
them; the cutover's own pre-registered, randomized 60-request live validation
|
|
162
|
+
(with account-level billing deltas and forced loser-cancels on all three
|
|
163
|
+
providers) is in
|
|
164
|
+
[`benchmarks/2026-07-queue-cutover/`](benchmarks/2026-07-queue-cutover/). In
|
|
165
|
+
this replay the hedge never stalled, so the cascade's escalation never fired
|
|
166
|
+
— identical numbers, tail protection for free.
|
|
167
|
+
|
|
168
|
+
| Pre-registered live validation (20/arm) | p50 | p90 | max | miss>60 s | RunPod billed $/req |
|
|
169
|
+
| --- | ---: | ---: | ---: | ---: | ---: |
|
|
170
|
+
| single RunPod | 6.5 s | 175.6 s | 200.8 s | 7/20 | $0.01475 |
|
|
171
|
+
| fixed hedge @10 s | 29.8 s | 30.8 s | 31.2 s | 0/20 | $0.00649 |
|
|
172
|
+
| **queue cutover @2.5 s** | **22.6 s** | **25.8 s** | 104.2 s | **1/20** | **$0.00532** |
|
|
173
|
+
|
|
174
|
+
The cutover passed the RunPod-billing and queued-cancel-unbilled hypotheses
|
|
175
|
+
and clearly improved typical latency, but its registered p95 hypothesis is
|
|
176
|
+
**inconclusive** — at n=20 the verdict flips with the quantile estimator
|
|
177
|
+
(28.2 s vs 31.0 s nearest-rank, 32.0 s vs 31.0 s linear) — and it failed the
|
|
178
|
+
zero-miss and active-cost-order hypotheses: one correctly-switched request
|
|
179
|
+
spent 104.2 s on the hedge provider's own tail. See the
|
|
180
|
+
[validation results](benchmarks/2026-07-queue-cutover/results.md).
|
|
181
|
+
|
|
182
|
+
**That 104.2 s outlier is why the cascade exists**: the primary can have a
|
|
183
|
+
tail, but so can the hedge. `CascadePolicy` escalates to a third provider
|
|
184
|
+
when the sole surviving attempt has produced nothing by `escalate_after_ms`
|
|
185
|
+
(never more than two live jobs). Its live validation is pre-registered — with
|
|
186
|
+
the quantile estimator fixed and request-level interleaving this time — in
|
|
187
|
+
[`benchmarks/2026-08-cascade/`](benchmarks/2026-08-cascade/preregistration.yaml)
|
|
188
|
+
and has not run yet; `gpuhedge demo` shows the mechanism on simulated
|
|
189
|
+
providers today.
|
|
190
|
+
|
|
191
|
+
**Cost honesty**: "active $" is modeled execution-seconds × rate. Real bills
|
|
192
|
+
also include idle windows (one provider's balance delta ran ~3× its summed
|
|
193
|
+
per-job execution time at a 60 s idle timeout) — both models are reported,
|
|
194
|
+
and the validation measures actual balance deltas per policy arm. See
|
|
195
|
+
[`docs/cost-accounting.md`](docs/cost-accounting.md).
|
|
196
|
+
|
|
197
|
+
**Cancellation honesty**: every receipt carries an explicit evidence level —
|
|
198
|
+
RunPod cancels are polled to a `confirmed_terminal` state with billing
|
|
199
|
+
reconciled; Modal cancels are `provider_ack` only (input-granular: the
|
|
200
|
+
container idles to its scaledown window and keeps billing); Cerebrium's
|
|
201
|
+
strongest proof is `request_channel_closed`. Anything less is recorded as a
|
|
202
|
+
leak, never assumed stopped. The capability matrix in
|
|
203
|
+
[`docs/provider-capabilities.md`](docs/provider-capabilities.md) states
|
|
204
|
+
exactly which cancel paths have been exercised live on which provider —
|
|
205
|
+
including the forced audit that caught our own Modal adapter silently
|
|
206
|
+
failing before the fix.
|
|
207
|
+
|
|
208
|
+
## Run it against real clouds
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
pip install -e ".[providers]" # or a subset: .[runpod], .[modal], .[cerebrium]
|
|
212
|
+
mkdir -p config
|
|
213
|
+
cp src/gpuhedge/config/benchmark.example.yaml config/benchmark.yaml
|
|
214
|
+
# fill in your endpoint ids / app names, set deployed: true
|
|
215
|
+
gpuhedge login-check # verifies auth, spends nothing
|
|
216
|
+
gpuhedge plan # what the config encodes, incl. budget gates
|
|
217
|
+
gpuhedge bench --dry-run # inspect before spending
|
|
218
|
+
gpuhedge bench --go # Stage 2 paired cold-start rounds
|
|
219
|
+
gpuhedge cutover --go # one live state-aware request
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Nothing submits a GPU job without `--go`. A projected-cost ledger enforces
|
|
223
|
+
hard budget gates (`BudgetExceeded` halts submission), and `gpuhedge costs`
|
|
224
|
+
reconciles projections against provider-reported billing.
|
|
225
|
+
|
|
226
|
+
Deployment recipes for the benchmark model on all three providers are under
|
|
227
|
+
[`deploy/`](deploy/) — self-contained, with the provider gotchas we hit
|
|
228
|
+
documented in [`docs/provider-capabilities.md`](docs/provider-capabilities.md).
|
|
229
|
+
|
|
230
|
+
## Repository map
|
|
231
|
+
|
|
232
|
+
```
|
|
233
|
+
src/gpuhedge/
|
|
234
|
+
router.py Router — the public API
|
|
235
|
+
policies/ SingleProvider / FixedHedgePolicy / StateAwarePolicy /
|
|
236
|
+
CascadePolicy — plus the execute() protocol for custom ones
|
|
237
|
+
backends/ runpod / modal / cerebrium / sim / generic http adapters
|
|
238
|
+
validators/ wav / json / custom validator registry
|
|
239
|
+
benchmark/ paired rounds, live hedging, state-aware engine,
|
|
240
|
+
replay (offline policy evaluation), reports, demo
|
|
241
|
+
telemetry/ JSONL traces, projected-cost ledger with budget gates,
|
|
242
|
+
provider billing monitors
|
|
243
|
+
config/ benchmark.yaml (plan-as-data), demo.yaml
|
|
244
|
+
benchmarks/ 2026-07-moss (method, results, figures, analysis.py),
|
|
245
|
+
2026-07-queue-cutover (preregistration + validation),
|
|
246
|
+
2026-08-cascade (preregistration; not yet run)
|
|
247
|
+
deploy/ MOSS-TTS deployment recipes per provider
|
|
248
|
+
traces/ committed benchmark traces (JSONL, sanitized)
|
|
249
|
+
docs/ architecture, policies, capabilities, cancellation,
|
|
250
|
+
cost accounting, adding a provider, security
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## Status & caveats
|
|
254
|
+
|
|
255
|
+
- Benchmark data is one workload (TTS, ~5–7 s of audio), one region per
|
|
256
|
+
provider, collected across two days in 2026-07. Provider rankings move;
|
|
257
|
+
that is the argument *for* state-aware routing, not against it — treat any
|
|
258
|
+
single number as a snapshot.
|
|
259
|
+
- The Cerebrium adapter discovers run ids from the runs list (its async API
|
|
260
|
+
does not return usable handles): **benchmark-safe, not concurrency-safe**
|
|
261
|
+
— see [`docs/provider-capabilities.md`](docs/provider-capabilities.md).
|
|
262
|
+
- No p99s are quoted anywhere: n is tens, not thousands. Miss rates carry
|
|
263
|
+
Wilson 95% intervals.
|
|
264
|
+
|
|
265
|
+
## Contributing
|
|
266
|
+
|
|
267
|
+
`make dev && make lint && make test`. CI runs Python 3.10–3.12 and a wheel
|
|
268
|
+
smoke test. Adapter contributions welcome — the contract is one class with
|
|
269
|
+
`submit / result / status / cancel` returning honest lifecycle events, plus
|
|
270
|
+
mock tests; see [`docs/adding-a-provider.md`](docs/adding-a-provider.md) and
|
|
271
|
+
[`CONTRIBUTING.md`](CONTRIBUTING.md).
|
|
272
|
+
|
|
273
|
+
## License
|
|
274
|
+
|
|
275
|
+
Apache-2.0.
|