gpu4agents 0.11.0__tar.gz → 0.12.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.
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/.claude-plugin/plugin.json +1 -1
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/.cursor-plugin/plugin.json +1 -1
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/CHANGELOG.md +11 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/INSTALL.md +1 -1
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/JOBS.md +10 -2
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/PKG-INFO +2 -2
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/README.md +1 -1
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/SERVING.md +2 -2
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/docs/AGENTS.md +2 -2
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/docs/INTEGRATION.md +1 -1
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/docs/LIFECYCLE.md +8 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/docs/USAGE.md +1 -1
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu.example.yaml +4 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/__init__.py +1 -1
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/agent/mcp.py +10 -2
- {gpu4agents-0.11.0/skills/gpu4agents → gpu4agents-0.12.0/gpu4agents/agent/skill}/SKILL.md +2 -2
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/cli/lifecycle.py +7 -2
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/core/engine.py +256 -4
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/core/events.py +2 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/watchdog/agent_body.py +8 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/watchdog/builder.py +5 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/watchdog/jobs_ext.py +90 -1
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/install.sh +2 -2
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/pyproject.toml +1 -1
- {gpu4agents-0.11.0/gpu4agents/agent/skill → gpu4agents-0.12.0/skills/gpu4agents}/SKILL.md +2 -2
- gpu4agents-0.12.0/tests/test_job_outputs.py +239 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/.claude-plugin/marketplace.json +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/.env.example +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/.github/ISSUE_TEMPLATE/config.yml +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/.github/dependabot.yml +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/.github/pull_request_template.md +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/.github/workflows/ci.yml +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/.github/workflows/release.yml +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/.gitignore +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/CODE_OF_CONDUCT.md +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/CONTRIBUTING.md +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/LICENSE +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/PROVIDERS.md +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/SECURITY.md +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/docs/ACCEPTANCE.md +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/docs/ADDING_A_PROVIDER.md +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/docs/CHOOSING_A_MODEL.md +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/docs/CONFIG.md +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/docs/assets/banner.png +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/docs/assets/jambu-logo.jpg +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/examples/experiment.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/examples/gpu.yaml +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/examples/mastra-agent/README.md +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/examples/mastra-agent/package-lock.json +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/examples/mastra-agent/package.json +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/examples/mastra-agent/src/agent.ts +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/examples/mastra-agent/src/index.ts +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/examples/mastra-agent/src/tools/weather-tool.ts +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/examples/mastra-agent/tsconfig.json +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/examples/typescript-client/README.md +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/examples/typescript-client/package-lock.json +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/examples/typescript-client/package.json +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/examples/typescript-client/src/gpu.ts +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/examples/typescript-client/src/index.ts +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/examples/typescript-client/tsconfig.json +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu.models.yaml +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu.yaml +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/__main__.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/agent/__init__.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/agent/install.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/agent/jobs.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/cli/__init__.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/cli/_common.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/cli/account.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/cli/agent.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/cli/inspect.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/cli/job.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/cli/main.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/cli/providers.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/cli/run.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/cli/setup.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/cli/status.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/cli/timer.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/cli/validate.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/core/__init__.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/core/beacon.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/core/config.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/core/credentials.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/core/durations.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/core/errors.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/core/execution.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/core/health.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/core/hosts.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/core/job.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/core/model_inspect.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/core/models.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/core/paths.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/core/policy.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/core/state.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/core/sweep.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/core/tool_parsers.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/providers/__init__.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/providers/base.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/providers/gpus.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/providers/http.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/providers/lambdacloud/__init__.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/providers/lambdacloud/client.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/providers/lambdacloud/config.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/providers/lambdacloud/mapper.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/providers/lambdacloud/provider.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/providers/registry.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/providers/runpod/__init__.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/providers/runpod/client.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/providers/runpod/config.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/providers/runpod/mapper.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/providers/runpod/provider.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/providers/scaffold.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/providers/vast/__init__.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/providers/vast/client.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/providers/vast/config.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/providers/vast/mapper.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/providers/vast/provider.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/runtime/__init__.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/runtime/base.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/runtime/service.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/runtime/vllm.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/serve/__init__.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/serve/hf/__init__.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/serve/hf/install.sh +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/serve/hf/server.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/serve/template/__init__.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/serve/template/gpujob.yaml +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/serve/template/server.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/gpu4agents/watchdog/__init__.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/jambu_gpu/__init__.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/jambu_gpu/__main__.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/reports/GPU pr/303/263pria para agentes de c/303/263digo.md" +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/research_notes/GPU pr/303/263pria para agentes de c/303/263digo/capabilities_unlocked.md" +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/research_notes/GPU pr/303/263pria para agentes de c/303/263digo/market.md" +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/research_notes/GPU pr/303/263pria para agentes de c/303/263digo/user_pain.md" +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/skills/gpu4agents/agents/openai.yaml +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/tests/conftest.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/tests/fakes.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/tests/test_agent.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/tests/test_cli.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/tests/test_config.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/tests/test_engine.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/tests/test_engine_sessions.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/tests/test_integration.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/tests/test_jobs.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/tests/test_lambda_provider.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/tests/test_model_inspect.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/tests/test_paths.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/tests/test_policy.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/tests/test_runpod_provider.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/tests/test_runtime_vllm.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/tests/test_serve.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/tests/test_state.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/tests/test_sweep.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/tests/test_vast_mapper.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/tests/test_vast_provider.py +0 -0
- {gpu4agents-0.11.0 → gpu4agents-0.12.0}/tests/test_watchdog.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gpu4agents",
|
|
3
3
|
"description": "Your agent rents the GPU it needs, serves a model on it and runs the experiment. You pay only while it works.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.12.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "João Gabriel Lima",
|
|
7
7
|
"url": "https://www.linkedin.com/in/joaogabriellima"
|
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses [Semantic Versioning](https://semver.org/).
|
|
4
4
|
|
|
5
|
+
## [0.12.0] - 2026-11-07
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
- **A job's results are no longer deleted before anyone downloaded them.** 0.11.0 made an idle Vast.ai machine be destroyed, and with it the outputs of a job run with `--detach` that nobody had pulled yet, or the checkpoints of a job cut off by `max_lifetime`. Now:
|
|
9
|
+
- On the machine, the job runner knows which outputs were downloaded after their job ended. While any are not, a shutdown that would delete them becomes a stop that keeps the disk. Where no stop keeps the disk (Lambda, a RunPod pod without a volume), an idle machine waits up to 2 hours for the download.
|
|
10
|
+
- `gpu sweep` and `gpu guard` download finished jobs' results into `gpu-outputs/<job id>/` on their own, and before any automatic destroy. A stopped machine that still holds results (and bills its disk) is started, emptied and destroyed. With `gpu sweep --install-timer`, results reach your computer within minutes, with nobody at the keyboard.
|
|
11
|
+
- `gpu job pull` works on a stopped machine: it starts it, downloads, and puts it back.
|
|
12
|
+
- `gpu destroy` (and the MCP `gpu_destroy`) downloads the results first, and refuses when it cannot; `--discard-outputs` (`discard_outputs=true`) deletes them.
|
|
13
|
+
- `gpu status` lists the jobs whose results are only on the machine (`job_outputs_unsaved`).
|
|
14
|
+
- `gpu job run` refuses a job whose `timeout` is longer than `lifecycle.max_lifetime` before anything runs, instead of letting the machine shut down mid-job, and warns when the machine will shut down before a job without a timeout could finish.
|
|
15
|
+
|
|
5
16
|
## [0.11.0] - 2026-11-06
|
|
6
17
|
|
|
7
18
|
### Changed
|
|
@@ -20,7 +20,7 @@ curl -fsSL https://raw.githubusercontent.com/jambuai/gpu4agents/main/install.sh
|
|
|
20
20
|
|
|
21
21
|
The script needs only `curl` (Linux or macOS; on Windows, run it inside WSL). It installs [uv](https://docs.astral.sh/uv/) if missing, uses it to install the `gpu4agents` package with a Python it downloads by itself, and then installs the skill and registers the `gpu` MCP server for your runtime. It does not ask for or read any key.
|
|
22
22
|
|
|
23
|
-
Check: `~/.local/bin/gpu --version` prints 0.
|
|
23
|
+
Check: `~/.local/bin/gpu --version` prints 0.12.0 or later.
|
|
24
24
|
|
|
25
25
|
For the rest of this session, call the command by its full path, `~/.local/bin/gpu`. Your shell may define `gpu` as an alias: Oh My Zsh's git plugin, on by default, makes `gpu` mean `git push upstream`, and an alias wins over the command, so plain `gpu setup` could run git instead. The installer removes that alias for new shells and says so; tell the user if it did. The same command is also installed as `gpu4agents`.
|
|
26
26
|
|
|
@@ -56,7 +56,7 @@ These never upload: `.git`, virtualenvs, `__pycache__`, `node_modules`, `.gpu`,
|
|
|
56
56
|
3. Exit non-zero on failure. Do not catch every exception and exit 0.
|
|
57
57
|
4. Never print secrets, and never write them into outputs.
|
|
58
58
|
5. Install dependencies in `setup:`, pinned (`torch` comes with the default image; do not reinstall it).
|
|
59
|
-
6. Keep the job under `lifecycle.max_lifetime` (6 h by default) and the session budget: those
|
|
59
|
+
6. Keep the job under `lifecycle.max_lifetime` (6 h by default) and the session budget: those shut the machine down even while a job runs. For a longer job, raise `max_lifetime` in `gpu.yaml` first; `gpu job run` refuses a `timeout:` longer than it. What the job wrote to `$JAMBU_OUTPUT_DIR` by then is kept (see section 6), so write checkpoints as you go.
|
|
60
60
|
|
|
61
61
|
## 5. Running it
|
|
62
62
|
|
|
@@ -79,4 +79,12 @@ States: `running`, `succeeded`, `failed`, `timeout`, `cancelled`, `lost` (the ma
|
|
|
79
79
|
|
|
80
80
|
## 6. Afterwards
|
|
81
81
|
|
|
82
|
-
The machine
|
|
82
|
+
The machine shuts down by itself after `idle_timeout` (15 min) once no job runs. Its results are kept until they reach this computer:
|
|
83
|
+
|
|
84
|
+
- `gpu job run` downloads them when the job ends. After `--detach`, `gpu job pull` does, whenever you like.
|
|
85
|
+
- A job's results count as saved once they were downloaded after it ended. Until then, a shutdown that would delete them becomes a stop, which keeps the disk (Vast.ai, a RunPod pod with a volume). Where a stop would wipe the disk too (Lambda, a RunPod pod without a volume), the idle machine stays up for up to 2 hours after the job ended, waiting for the download. Only there can results still be lost: when nothing downloads them within those 2 hours, or when `max_lifetime` or the budget ends the machine first.
|
|
86
|
+
- `gpu job pull` works on a stopped machine: it starts it, downloads, and puts it back (destroyed on Vast.ai once nothing is left on it, since a stopped machine bills its disk).
|
|
87
|
+
- `gpu sweep` and `gpu guard` do the same on their own: they download the results of finished jobs into `gpu-outputs/<job id>/` while the machine is up, start a stopped machine that still holds some (then destroy it), and download before any automatic destroy. With `gpu sweep --install-timer` this happens within minutes, with no one at the keyboard.
|
|
88
|
+
- `gpu destroy` downloads the results first. If it cannot, it refuses; `gpu destroy --discard-outputs` deletes them.
|
|
89
|
+
|
|
90
|
+
Tell the user what ran, how long it took, what it cost (`gpu job status` reports `cost_usd`) and where the outputs are.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: gpu4agents
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.12.0
|
|
4
4
|
Summary: GPU for Agents: your coding agent rents the GPU it needs, on its own. You pay only while it works.
|
|
5
5
|
Project-URL: Homepage, https://gpu4agents.jambu.ai
|
|
6
6
|
Project-URL: Documentation, https://github.com/jambuai/gpu4agents/tree/main/docs
|
|
@@ -202,7 +202,7 @@ gpu_runtime:
|
|
|
202
202
|
provider: {name: vast}
|
|
203
203
|
model_profile: qwythos-9b
|
|
204
204
|
lifecycle:
|
|
205
|
-
idle_timeout: 15m # the watchdog on the machine
|
|
205
|
+
idle_timeout: 15m # the watchdog on the machine shuts it down
|
|
206
206
|
max_lifetime: 6h # a hard ceiling, busy or not
|
|
207
207
|
budget:
|
|
208
208
|
max_hourly_cost_usd: 0.60 # offers above this are never rented
|
|
@@ -161,7 +161,7 @@ gpu_runtime:
|
|
|
161
161
|
provider: {name: vast}
|
|
162
162
|
model_profile: qwythos-9b
|
|
163
163
|
lifecycle:
|
|
164
|
-
idle_timeout: 15m # the watchdog on the machine
|
|
164
|
+
idle_timeout: 15m # the watchdog on the machine shuts it down
|
|
165
165
|
max_lifetime: 6h # a hard ceiling, busy or not
|
|
166
166
|
budget:
|
|
167
167
|
max_hourly_cost_usd: 0.60 # offers above this are never rented
|
|
@@ -73,11 +73,11 @@ Image extras go in the body (`extra_body` in the SDK): `num_inference_steps`, `g
|
|
|
73
73
|
|
|
74
74
|
## 3. Lifecycle
|
|
75
75
|
|
|
76
|
-
- Requests are activity. The server counts them on `/metrics` and the watchdog reads that, so the machine stays up while clients call it and
|
|
76
|
+
- Requests are activity. The server counts them on `/metrics` and the watchdog reads that, so the machine stays up while clients call it and shuts down by itself after `lifecycle.idle_timeout` (15 min) once they stop. `max_lifetime` and the session budget still apply.
|
|
77
77
|
- Changing the model keeps the machine. Edit `model.id` or `model.task` (or your server's code) and run `gpu setup`: it stops the running server and starts the new one on the same GPU. `gpu redeploy` restarts it with nothing changed. A bigger `min_vram_gb` does need a new machine (`gpu setup --recreate`).
|
|
78
78
|
- A machine serves one model, and the GPU takes one request at a time; the rest queue. For concurrent chat traffic, use vLLM.
|
|
79
79
|
- `gpu logs` shows the server's log (installs, download, load, tracebacks). A server that dies while loading ends `gpu setup` with its last lines.
|
|
80
|
-
-
|
|
80
|
+
- When the machine is stopped, it keeps its disk, weights included: `gpu setup` restarts it and redeploys in about a minute. On Vast.ai an idle machine is destroyed instead, because a stopped one still bills its disk, so the next `gpu setup` rents a new one and downloads again (`lifecycle.keep_disk: true` stops it instead).
|
|
81
81
|
|
|
82
82
|
## 4. Your own server (`runtime.engine: custom`)
|
|
83
83
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
`gpu` ships a skill and a local MCP server, so Claude Code, Codex, Gemini CLI, Cursor or Claude Desktop can rent a GPU, serve a model, run an experiment against it and shut it down, from a request like "compare Qwen 7B and Llama 8B on these 50 prompts".
|
|
4
4
|
|
|
5
|
-
A watchdog on the machine makes this safe to hand to an agent. A machine the agent forgets, or a conversation that ends mid-experiment,
|
|
5
|
+
A watchdog on the machine makes this safe to hand to an agent. A machine the agent forgets, or a conversation that ends mid-experiment, shuts down by itself after `lifecycle.idle_timeout`.
|
|
6
6
|
|
|
7
7
|
## Install: let the agent do it
|
|
8
8
|
|
|
@@ -85,7 +85,7 @@ Another agent that reads `SKILL.md` files: `gpu agent skill > path/to/skills/gpu
|
|
|
85
85
|
| `gpu_logs` | runtime, onstart, watchdog or provider log | no |
|
|
86
86
|
| `gpu_lock` / `gpu_unlock` | keep the machine up through a quiet period | while locked |
|
|
87
87
|
| `gpu_stop` | stop now; disk kept, restart takes about a minute | ends billing for compute |
|
|
88
|
-
| `gpu_destroy` | delete; needs `confirm=true` | ends all billing |
|
|
88
|
+
| `gpu_destroy` | delete; needs `confirm=true`; downloads job results first, `discard_outputs=true` deletes them | ends all billing |
|
|
89
89
|
| `gpu_ls` | every machine in the account, from any project | no |
|
|
90
90
|
|
|
91
91
|
Each tool runs the `gpu` CLI with `--json` in the project directory, so errors carry the same `exit_code` as the [application contract](INTEGRATION.md#exit-codes), plus `meaning` and `next` for the agent. A tool takes an optional `project_dir`; by default it is the server's `--project`, `$GPU_PROJECT_DIR`, or the directory the client started it in.
|
|
@@ -7,7 +7,7 @@ How any application, in any language, uses a GPU that `gpu` rents, serves and sh
|
|
|
7
7
|
| Control | the `gpu` command | runs it as a subprocess with `--json` and reads stdout and the exit code |
|
|
8
8
|
| Data | vLLM's OpenAI-compatible HTTP API | any OpenAI SDK, or plain HTTP, with the base URL, key and model `gpu` printed |
|
|
9
9
|
|
|
10
|
-
The app never has to stop the GPU. The watchdog on the machine
|
|
10
|
+
The app never has to stop the GPU. The watchdog on the machine shuts it down once nothing has used it for `lifecycle.idle_timeout`, and every inference request counts as use. The app's only duty is to call `gpu setup` again when the machine it was using is gone.
|
|
11
11
|
|
|
12
12
|
## 1. Prepare the host the app runs on
|
|
13
13
|
|
|
@@ -71,6 +71,14 @@ A stopped instance is then destroyed once it has been stopped longer than `lifec
|
|
|
71
71
|
|
|
72
72
|
`stopped_since` keeps the first time the CLI saw the instance stopped, but only while nothing says it ran since. A session start, local activity, watchdog contact or a provider start time newer than `stopped_since` means the instance was restarted and stopped again while the CLI was not looking (from the web console, say), so the clock restarts at the current observation instead of destroying a fresh stop.
|
|
73
73
|
|
|
74
|
+
## Job results
|
|
75
|
+
|
|
76
|
+
A job's results are on the machine's disk until someone downloads them. No automatic shutdown deletes them unseen.
|
|
77
|
+
|
|
78
|
+
On the machine, the job runner marks a job's outputs saved once `GET /jobs/<id>/outputs` streamed them after the job ended and nothing changed since. While any are unsaved, it changes what the watchdog does (a `TERMINATE_HOOKS` entry): a destroy becomes a stop where a stop keeps the disk (`outputs_kept`); where it would not (no persistent disk, or no stop at all), an idle shutdown waits up to 2 hours after the last job ended (`outputs_hold`). After that, or when `max_lifetime` or the budget fires there, the machine goes and the event is `outputs_lost`. An explicit `gpu stop` or `gpu destroy` and the stop-failure escalation are not changed.
|
|
79
|
+
|
|
80
|
+
On this computer, `gpu guard` and `gpu sweep` download the results of finished jobs into `gpu-outputs/<job id>/` while the machine runs, and before any automatic destroy. A stopped machine that still holds results, on a provider where a stopped machine bills and without `keep_disk`, is started, emptied and destroyed (reason `job_outputs_saved`); a failed attempt is retried after an hour and recorded as `job_outputs_kept`. `gpu job pull` starts a stopped machine too, and puts it back afterwards. `gpu destroy` downloads first and refuses when it cannot, unless `--discard-outputs`. `gpu status` lists the jobs whose results are only on the machine (`job_outputs_unsaved`).
|
|
81
|
+
|
|
74
82
|
## A second path
|
|
75
83
|
|
|
76
84
|
Run the same rule from anywhere that has API access:
|
|
@@ -18,7 +18,7 @@ Operator reference. The project front page is the [README](../README.md). Field-
|
|
|
18
18
|
| `gpu lock --for 2h` | Prevent automatic shutdown until the TTL expires |
|
|
19
19
|
| `gpu unlock` | Resume normal lifecycle rules |
|
|
20
20
|
| `gpu stop` | Stop compute. Idempotent |
|
|
21
|
-
| `gpu destroy` | Destroy the remote resource. Idempotent |
|
|
21
|
+
| `gpu destroy` | Destroy the remote resource. Idempotent. Job results not downloaded yet are fetched first; if that fails it refuses, and `--discard-outputs` deletes them |
|
|
22
22
|
| `gpu logs` | The model server's log on the instance (`--source runtime\|onstart\|watchdog\|provider`, `--lines N`). Falls back to the provider's container log when the watchdog does not answer |
|
|
23
23
|
| `gpu events` | Structured lifecycle event log |
|
|
24
24
|
| `gpu guard` | Evaluate and enforce the lifecycle rule from cron or CI |
|
|
@@ -55,6 +55,10 @@ gpu_runtime:
|
|
|
55
55
|
|
|
56
56
|
auto_stop: true
|
|
57
57
|
auto_destroy: false
|
|
58
|
+
# Where a stopped instance still bills storage (Vast.ai), the guard
|
|
59
|
+
# destroys it instead of stopping. true stops it (disk kept, restart in
|
|
60
|
+
# about a minute) and leaves the removal to stopped_ttl.
|
|
61
|
+
keep_disk: false
|
|
58
62
|
|
|
59
63
|
# Requests served by vLLM count as activity (read from its /metrics).
|
|
60
64
|
traffic_counts_as_activity: true
|
|
@@ -414,6 +414,8 @@ class Server:
|
|
|
414
414
|
project_dir = self._project_dir(args)
|
|
415
415
|
cancelled = self._cancel_setup(project_dir)
|
|
416
416
|
argv = ["destroy", "--yes", "--reason", str(args.get("reason") or "agent")]
|
|
417
|
+
if args.get("discard_outputs"):
|
|
418
|
+
argv.append("--discard-outputs")
|
|
417
419
|
result = self._ok(self.cli(argv, project_dir))
|
|
418
420
|
if cancelled:
|
|
419
421
|
result["setup_cancelled"] = cancelled
|
|
@@ -683,10 +685,16 @@ class Server:
|
|
|
683
685
|
"gpu_destroy",
|
|
684
686
|
"Delete the GPU",
|
|
685
687
|
"Delete the machine and its disk: nothing is billed afterwards, and the next "
|
|
686
|
-
"gpu_setup rents and downloads from scratch. Cancels a setup in progress.
|
|
688
|
+
"gpu_setup rents and downloads from scratch. Cancels a setup in progress. Job results "
|
|
689
|
+
"not downloaded yet are fetched into gpu-outputs/ first; if that fails it refuses, "
|
|
690
|
+
"and discard_outputs=true (only with the user's yes) deletes them. Requires "
|
|
687
691
|
"confirm=true after the user agrees.",
|
|
688
692
|
_schema(
|
|
689
|
-
{
|
|
693
|
+
{
|
|
694
|
+
"confirm": {"type": "boolean"},
|
|
695
|
+
"reason": {"type": "string"},
|
|
696
|
+
"discard_outputs": {"type": "boolean"},
|
|
697
|
+
},
|
|
690
698
|
["confirm"],
|
|
691
699
|
),
|
|
692
700
|
self.tool_destroy,
|
|
@@ -17,7 +17,7 @@ Do these in order. Skip a step whose check already passes.
|
|
|
17
17
|
|
|
18
18
|
### 1. Install the `gpu` command
|
|
19
19
|
|
|
20
|
-
Check: `gpu --version` prints 0.
|
|
20
|
+
Check: `gpu --version` prints 0.12.0 or later. First run `type gpu`: if it says `gpu` is an alias or a function (Oh My Zsh's git plugin makes it `git push upstream`), plain `gpu` runs that instead, so use `command gpu`, `~/.local/bin/gpu` or `gpu4agents` for every command in this session. In a git repository the alias would really push. If the command is missing or older, install it (Linux and macOS; on Windows, use WSL):
|
|
21
21
|
|
|
22
22
|
```bash
|
|
23
23
|
curl -fsSL https://gpu4agents.jambu.ai/install.sh | sh -s -- --agent <runtime>
|
|
@@ -102,7 +102,7 @@ When the work is code that needs a GPU, not requests to a model (training or fin
|
|
|
102
102
|
2. Put the code in a directory with a `gpujob.yaml`: `run:` (the command), `setup:` (pinned installs), `env:`, `timeout:`, `exclude:`. `.git`, virtualenvs, `.env` files and `gpu-outputs/` never upload; the limit is 2 GB, so the job downloads large data itself.
|
|
103
103
|
3. The code writes every result to `$JAMBU_OUTPUT_DIR` (checkpoints too, as it goes), prints progress, exits non-zero on failure and never prints secrets. `HF_HOME` is a cache on the machine.
|
|
104
104
|
4. With the user's yes: `gpu job run` (uploads, runs, streams the log, downloads to `gpu-outputs/<job id>/`, exits with the job's code). Through MCP: `gpu_setup` until ready, `gpu_job_run`, `gpu_job_status` until the state is not `running`, `gpu_job_pull`.
|
|
105
|
-
5. A running job keeps the machine up; `max_lifetime` and the budget still
|
|
105
|
+
5. A running job keeps the machine up; `max_lifetime` and the budget still shut it down, so raise `max_lifetime` before a long job (`gpu job run` refuses a `timeout` longer than it). Results are kept until downloaded: the machine is stopped rather than destroyed while it holds results nobody pulled, `gpu job pull` works on a stopped machine, and `gpu destroy` downloads them first. If destroy refuses because it could not fetch them, tell the user; only their explicit yes justifies `--discard-outputs`.
|
|
106
106
|
|
|
107
107
|
## Serve any model (images, voice, transcription, embeddings)
|
|
108
108
|
|
|
@@ -79,8 +79,13 @@ def destroy_command(
|
|
|
79
79
|
ctx: typer.Context,
|
|
80
80
|
yes: bool = typer.Option(False, "--yes", "-y", help="Skip the confirmation prompt."),
|
|
81
81
|
reason: str = typer.Option("manual", "--reason", help="Recorded with the destroy event."),
|
|
82
|
+
discard_outputs: bool = typer.Option(
|
|
83
|
+
False,
|
|
84
|
+
"--discard-outputs",
|
|
85
|
+
help="Destroy even if job results could not be downloaded first (they are deleted).",
|
|
86
|
+
),
|
|
82
87
|
) -> None:
|
|
83
|
-
"""Destroy the remote resource (idempotent)."""
|
|
88
|
+
"""Destroy the remote resource (idempotent). Job results are downloaded first."""
|
|
84
89
|
context = get_context(ctx)
|
|
85
90
|
try:
|
|
86
91
|
engine = context.engine()
|
|
@@ -93,7 +98,7 @@ def destroy_command(
|
|
|
93
98
|
if not confirm:
|
|
94
99
|
console.print("aborted")
|
|
95
100
|
raise typer.Exit(1)
|
|
96
|
-
result = engine.destroy(reason=reason)
|
|
101
|
+
result = engine.destroy(reason=reason, discard_outputs=discard_outputs)
|
|
97
102
|
except JambuError as exc:
|
|
98
103
|
handle(exc)
|
|
99
104
|
return
|
|
@@ -7,6 +7,7 @@ reconciliation, idempotency and cleanup. It knows about the provider
|
|
|
7
7
|
|
|
8
8
|
from __future__ import annotations
|
|
9
9
|
|
|
10
|
+
import json
|
|
10
11
|
import re
|
|
11
12
|
import secrets
|
|
12
13
|
import tempfile
|
|
@@ -486,6 +487,8 @@ class Engine:
|
|
|
486
487
|
activity_probe=probe,
|
|
487
488
|
runtime_pid_path=self.runtime.runtime_pid_path(),
|
|
488
489
|
runtime_log_path=self.runtime.runtime_log_path(),
|
|
490
|
+
stop_keeps_disk=self.provider.capabilities.stop
|
|
491
|
+
and self.provider.capabilities.persistent_disk,
|
|
489
492
|
)
|
|
490
493
|
runtime_env = dict(self.runtime.env())
|
|
491
494
|
# A configured key is already on the command line; only a generated
|
|
@@ -1169,6 +1172,14 @@ class Engine:
|
|
|
1169
1172
|
"or set run: in gpujob.yaml"
|
|
1170
1173
|
)
|
|
1171
1174
|
timeout = timeout or manifest.timeout
|
|
1175
|
+
timeout_s = parse_duration(timeout) if timeout else None
|
|
1176
|
+
lifetime = self.config.max_lifetime_s
|
|
1177
|
+
if lifetime and timeout_s and timeout_s > lifetime:
|
|
1178
|
+
raise ConfigError(
|
|
1179
|
+
f"the job may run {format_duration(timeout_s)} but lifecycle.max_lifetime "
|
|
1180
|
+
f"shuts the machine down after {format_duration(lifetime)}; raise "
|
|
1181
|
+
"max_lifetime in gpu.yaml (and the session budget, if set) to at least the timeout"
|
|
1182
|
+
)
|
|
1172
1183
|
merged_env = dict(manifest.env)
|
|
1173
1184
|
merged_env.update(env or {})
|
|
1174
1185
|
|
|
@@ -1182,9 +1193,16 @@ class Engine:
|
|
|
1182
1193
|
env={**self.job_env(state), **merged_env},
|
|
1183
1194
|
exclude=list(manifest.exclude) + list(exclude),
|
|
1184
1195
|
label=label or manifest.label or "",
|
|
1185
|
-
timeout_s=
|
|
1196
|
+
timeout_s=timeout_s,
|
|
1186
1197
|
)
|
|
1187
1198
|
self.echo(f"+ job {record['id']} running on instance {state.instance_id}")
|
|
1199
|
+
if lifetime and state.session_started_at:
|
|
1200
|
+
left = lifetime - (utc_now() - state.session_started_at)
|
|
1201
|
+
if timeout_s is None or timeout_s > left:
|
|
1202
|
+
self.echo(
|
|
1203
|
+
f"! lifecycle.max_lifetime shuts this machine down in {format_duration(max(0.0, left))}"
|
|
1204
|
+
", even mid-job; what the job wrote by then is kept and downloaded"
|
|
1205
|
+
)
|
|
1188
1206
|
return record
|
|
1189
1207
|
|
|
1190
1208
|
def _submit(
|
|
@@ -1387,14 +1405,234 @@ class Engine:
|
|
|
1387
1405
|
return info
|
|
1388
1406
|
|
|
1389
1407
|
def job_pull(self, job_id: Optional[str] = None, dest: Optional[Path] = None) -> dict[str, Any]:
|
|
1408
|
+
"""Download a job's outputs; a stopped machine is started for it and put back."""
|
|
1390
1409
|
job_id = self._resolve_job(job_id)
|
|
1391
|
-
|
|
1410
|
+
with self.store.process_lock():
|
|
1411
|
+
state = self._reconcile(self.store.load())
|
|
1412
|
+
woken = False
|
|
1413
|
+
if state.has_instance() and state.state == InstanceState.STOPPED.value:
|
|
1414
|
+
state = self._wake_for_outputs(state)
|
|
1415
|
+
woken = True
|
|
1416
|
+
try:
|
|
1417
|
+
_, jobs = self._job_client(start=False)
|
|
1418
|
+
result = self._pull_outputs(jobs, job_id, dest)
|
|
1419
|
+
finally:
|
|
1420
|
+
if woken:
|
|
1421
|
+
self._settle_after_wake(state)
|
|
1422
|
+
return result
|
|
1423
|
+
|
|
1424
|
+
def _pull_outputs(self, jobs: JobClient, job_id: str, dest: Optional[Path] = None) -> dict[str, Any]:
|
|
1392
1425
|
target = Path(dest) if dest else self.config.project_dir / OUTPUTS_DIRNAME / job_id
|
|
1393
1426
|
files = jobs.download_outputs(job_id, target)
|
|
1394
|
-
|
|
1427
|
+
try:
|
|
1428
|
+
unsaved = bool(jobs.info(job_id).get("outputs_unsaved", False))
|
|
1429
|
+
except (StateError, WatchdogUnavailable):
|
|
1430
|
+
unsaved = True
|
|
1431
|
+
JobRecords(self.store.dir).update(
|
|
1432
|
+
job_id, outputs_dir=str(target), outputs=len(files), outputs_unsaved=unsaved
|
|
1433
|
+
)
|
|
1395
1434
|
self.events.emit(ev.JOB_OUTPUTS_PULLED, job_id=job_id, files=len(files), dest=str(target))
|
|
1435
|
+
self.echo(f"+ job {job_id}: {len(files)} output files in {target}")
|
|
1396
1436
|
return {"job_id": job_id, "outputs_dir": str(target), "files": files}
|
|
1397
1437
|
|
|
1438
|
+
# ------------------------------------------------------------------
|
|
1439
|
+
# job results are never deleted unseen
|
|
1440
|
+
# ------------------------------------------------------------------
|
|
1441
|
+
|
|
1442
|
+
def unsaved_job_outputs(self, state: RuntimeState, jobs: Optional[JobClient] = None) -> list[str]:
|
|
1443
|
+
"""Jobs on this instance whose results may not exist anywhere else.
|
|
1444
|
+
|
|
1445
|
+
With ``jobs`` (the machine's runner) the machine's own answer is
|
|
1446
|
+
recorded locally, so it is still known once the machine is stopped.
|
|
1447
|
+
Without it, a job never confirmed saved counts as unsaved.
|
|
1448
|
+
"""
|
|
1449
|
+
if not state.instance_id:
|
|
1450
|
+
return []
|
|
1451
|
+
records = JobRecords(self.store.dir)
|
|
1452
|
+
mine = {
|
|
1453
|
+
r["id"]: r
|
|
1454
|
+
for r in records.all()
|
|
1455
|
+
if r.get("instance_id") == state.instance_id and not r.get("service")
|
|
1456
|
+
}
|
|
1457
|
+
if jobs is not None and mine:
|
|
1458
|
+
remote = {r.get("id"): r for r in jobs.list()}
|
|
1459
|
+
for job_id, record in list(mine.items()):
|
|
1460
|
+
found = remote.get(job_id)
|
|
1461
|
+
# Gone from the machine: there is nothing left there to lose.
|
|
1462
|
+
unsaved = bool(found.get("outputs_unsaved", True)) if found else False
|
|
1463
|
+
if record.get("outputs_unsaved") != unsaved:
|
|
1464
|
+
mine[job_id] = records.update(
|
|
1465
|
+
job_id,
|
|
1466
|
+
outputs_unsaved=unsaved,
|
|
1467
|
+
**({"state": found.get("state")} if found else {}),
|
|
1468
|
+
)
|
|
1469
|
+
return sorted(j for j, r in mine.items() if r.get("outputs_unsaved", True))
|
|
1470
|
+
|
|
1471
|
+
def _reachable_jobs(self, state: RuntimeState) -> Optional[JobClient]:
|
|
1472
|
+
if not InstanceState(state.state).is_billable_compute:
|
|
1473
|
+
return None
|
|
1474
|
+
client = self.beacon(state)
|
|
1475
|
+
if client is None or not client.ping():
|
|
1476
|
+
return None
|
|
1477
|
+
jobs = JobClient(client)
|
|
1478
|
+
try:
|
|
1479
|
+
jobs.ensure_runner()
|
|
1480
|
+
except (StateError, WatchdogUnavailable):
|
|
1481
|
+
return None
|
|
1482
|
+
return jobs
|
|
1483
|
+
|
|
1484
|
+
WAKE_RETRY_S = 3600.0
|
|
1485
|
+
|
|
1486
|
+
def _wake_allowed(self) -> bool:
|
|
1487
|
+
"""The guard restarts a machine for its results at most once an hour."""
|
|
1488
|
+
path = self.store.dir / "outputs-wake.json"
|
|
1489
|
+
try:
|
|
1490
|
+
last = float(json.loads(path.read_text()).get("at") or 0)
|
|
1491
|
+
except (OSError, ValueError, AttributeError):
|
|
1492
|
+
last = 0.0
|
|
1493
|
+
if utc_now() - last < self.WAKE_RETRY_S:
|
|
1494
|
+
return False
|
|
1495
|
+
self.store.ensure_dirs()
|
|
1496
|
+
path.write_text(json.dumps({"at": utc_now()}))
|
|
1497
|
+
return True
|
|
1498
|
+
|
|
1499
|
+
def _save_job_outputs(
|
|
1500
|
+
self, state: RuntimeState, throttle: bool = False, finished_only: bool = False
|
|
1501
|
+
) -> tuple[RuntimeState, list[str]]:
|
|
1502
|
+
"""Download every unsaved job result. Returns the state and what is still unsaved.
|
|
1503
|
+
|
|
1504
|
+
A stopped machine is started for it (and left running: the caller
|
|
1505
|
+
decides what happens to it next).
|
|
1506
|
+
"""
|
|
1507
|
+
if not state.instance_id or not JobRecords(self.store.dir).all():
|
|
1508
|
+
return state, []
|
|
1509
|
+
jobs = self._reachable_jobs(state)
|
|
1510
|
+
unsaved = self.unsaved_job_outputs(state, jobs)
|
|
1511
|
+
if not unsaved:
|
|
1512
|
+
return state, []
|
|
1513
|
+
if jobs is None and state.state == InstanceState.STOPPED.value:
|
|
1514
|
+
if throttle and not self._wake_allowed():
|
|
1515
|
+
return state, unsaved
|
|
1516
|
+
try:
|
|
1517
|
+
state = self._wake_for_outputs(state)
|
|
1518
|
+
except JambuError as exc:
|
|
1519
|
+
self.events.emit(ev.JOB_OUTPUTS_KEPT, job_ids=unsaved, error=str(exc))
|
|
1520
|
+
self.echo(f"! could not start instance {state.instance_id} to fetch job results: {exc}")
|
|
1521
|
+
return state, unsaved
|
|
1522
|
+
jobs = self._reachable_jobs(state)
|
|
1523
|
+
if jobs is not None:
|
|
1524
|
+
unsaved = self.unsaved_job_outputs(state, jobs)
|
|
1525
|
+
if jobs is None:
|
|
1526
|
+
self.events.emit(ev.JOB_OUTPUTS_KEPT, job_ids=unsaved, error="watchdog unreachable")
|
|
1527
|
+
return state, unsaved
|
|
1528
|
+
if finished_only:
|
|
1529
|
+
done = {r.get("id") for r in jobs.list() if r.get("state") != "running"}
|
|
1530
|
+
unsaved = [j for j in unsaved if j in done]
|
|
1531
|
+
left = []
|
|
1532
|
+
for job_id in unsaved:
|
|
1533
|
+
try:
|
|
1534
|
+
self._pull_outputs(jobs, job_id)
|
|
1535
|
+
except (JambuError, WatchdogUnavailable, OSError) as exc:
|
|
1536
|
+
self.events.emit(ev.JOB_OUTPUTS_KEPT, job_ids=[job_id], error=str(exc))
|
|
1537
|
+
left.append(job_id)
|
|
1538
|
+
# A job still running was just pulled as far as it got; what it writes
|
|
1539
|
+
# after this is lost with the machine, but nothing it already wrote is.
|
|
1540
|
+
return state, left
|
|
1541
|
+
|
|
1542
|
+
def _wake_for_outputs(self, state: RuntimeState) -> RuntimeState:
|
|
1543
|
+
"""Start a stopped machine just far enough to reach its watchdog."""
|
|
1544
|
+
instance = state.instance
|
|
1545
|
+
if instance is None or not self.provider.capabilities.stop:
|
|
1546
|
+
raise StateError(f"instance {state.instance_id} cannot be started again")
|
|
1547
|
+
self.echo(f"> starting instance {instance.id} to download job results")
|
|
1548
|
+
instance = self.provider.start(instance)
|
|
1549
|
+
state.instance = instance
|
|
1550
|
+
state.mark_billable(True)
|
|
1551
|
+
state.mark_session_start()
|
|
1552
|
+
self.events.emit(ev.INSTANCE_STARTED, instance_id=instance.id, reason="job_outputs")
|
|
1553
|
+
state.state = InstanceState.STARTING.value
|
|
1554
|
+
self.store.save(state)
|
|
1555
|
+
instance = self._wait_running(state)
|
|
1556
|
+
state.instance = instance
|
|
1557
|
+
state.endpoint = instance.endpoint_url(ENDPOINT_NAME)
|
|
1558
|
+
watchdog_url = instance.endpoint_url("watchdog")
|
|
1559
|
+
if watchdog_url:
|
|
1560
|
+
state.watchdog.url = watchdog_url
|
|
1561
|
+
self.store.save(state)
|
|
1562
|
+
client = self.beacon(state)
|
|
1563
|
+
deadline = time.time() + 120
|
|
1564
|
+
while client is not None and time.time() < deadline:
|
|
1565
|
+
if client.ping():
|
|
1566
|
+
state.watchdog.last_contact = utc_now()
|
|
1567
|
+
state.watchdog.last_error = None
|
|
1568
|
+
return state
|
|
1569
|
+
time.sleep(5)
|
|
1570
|
+
raise StateError(f"the watchdog on instance {instance.id} did not answer after the restart")
|
|
1571
|
+
|
|
1572
|
+
def _settle_after_wake(self, state: RuntimeState) -> None:
|
|
1573
|
+
"""Put a machine started only for its results back the way policy wants it."""
|
|
1574
|
+
caps = self.provider.capabilities
|
|
1575
|
+
billing_stop = not caps.stop_eliminates_billing and not self.config.lifecycle.keep_disk
|
|
1576
|
+
if billing_stop and caps.destroy and not self.unsaved_job_outputs(state):
|
|
1577
|
+
action = policy.ACTION_DESTROY
|
|
1578
|
+
else:
|
|
1579
|
+
action = policy.ACTION_STOP
|
|
1580
|
+
try:
|
|
1581
|
+
self._terminate(state, action=action, reason="job_outputs_saved")
|
|
1582
|
+
except ProviderError:
|
|
1583
|
+
pass # the watchdog still shuts an idle machine down
|
|
1584
|
+
self.store.save(state)
|
|
1585
|
+
|
|
1586
|
+
def _protect_job_outputs(
|
|
1587
|
+
self, state: RuntimeState, decision: policy.Decision, locked: bool
|
|
1588
|
+
) -> tuple[RuntimeState, policy.Decision]:
|
|
1589
|
+
"""No automatic shutdown deletes job results nobody downloaded.
|
|
1590
|
+
|
|
1591
|
+
Before one would, the results are downloaded into gpu-outputs/. A
|
|
1592
|
+
stopped machine kept only for them (a stop that still bills, without
|
|
1593
|
+
keep_disk) is started, emptied and destroyed. What cannot be fetched
|
|
1594
|
+
keeps the machine: stopped where the disk survives that, else as is.
|
|
1595
|
+
"""
|
|
1596
|
+
caps = self.provider.capabilities
|
|
1597
|
+
stopped = state.state == InstanceState.STOPPED.value
|
|
1598
|
+
if (
|
|
1599
|
+
not decision.terminates
|
|
1600
|
+
and InstanceState(state.state).is_billable_compute
|
|
1601
|
+
and self.unsaved_job_outputs(state)
|
|
1602
|
+
):
|
|
1603
|
+
# Fetch finished jobs' results while the machine is still up: then
|
|
1604
|
+
# the watchdog can destroy it when idle instead of keeping a disk.
|
|
1605
|
+
state, _ = self._save_job_outputs(state, finished_only=True)
|
|
1606
|
+
return state, decision
|
|
1607
|
+
if not decision.terminates:
|
|
1608
|
+
billing_stop = not caps.stop_eliminates_billing and not self.config.lifecycle.keep_disk
|
|
1609
|
+
if not (stopped and billing_stop and caps.destroy and not locked):
|
|
1610
|
+
return state, decision
|
|
1611
|
+
if not self.unsaved_job_outputs(state):
|
|
1612
|
+
return state, decision
|
|
1613
|
+
state, left = self._save_job_outputs(state, throttle=True)
|
|
1614
|
+
detail = dict(decision.detail)
|
|
1615
|
+
if not left:
|
|
1616
|
+
return state, policy.Decision(policy.ACTION_DESTROY, "job_outputs_saved", detail)
|
|
1617
|
+
detail["job_outputs_unsaved"] = left
|
|
1618
|
+
if InstanceState(state.state).is_billable_compute:
|
|
1619
|
+
return state, policy.Decision(policy.ACTION_STOP, "job_outputs_unsaved", detail)
|
|
1620
|
+
return state, policy.Decision(policy.ACTION_NONE, "job_outputs_unsaved", detail)
|
|
1621
|
+
|
|
1622
|
+
if decision.action != policy.ACTION_DESTROY and caps.persistent_disk:
|
|
1623
|
+
return state, decision # a stop keeps the disk, results included
|
|
1624
|
+
state, left = self._save_job_outputs(state, throttle=True)
|
|
1625
|
+
if not left:
|
|
1626
|
+
return state, decision
|
|
1627
|
+
detail = dict(decision.detail)
|
|
1628
|
+
detail["job_outputs_unsaved"] = left
|
|
1629
|
+
running = InstanceState(state.state).is_billable_compute
|
|
1630
|
+
if running and caps.stop and caps.persistent_disk:
|
|
1631
|
+
return state, policy.Decision(policy.ACTION_STOP, decision.reason, detail)
|
|
1632
|
+
if not running or decision.reason == policy.REASON_IDLE:
|
|
1633
|
+
return state, policy.Decision(policy.ACTION_NONE, "job_outputs_unsaved", detail)
|
|
1634
|
+
return state, decision
|
|
1635
|
+
|
|
1398
1636
|
def job_cancel(self, job_id: Optional[str] = None) -> dict[str, Any]:
|
|
1399
1637
|
job_id = self._resolve_job(job_id)
|
|
1400
1638
|
_, jobs = self._job_client(start=False)
|
|
@@ -1467,6 +1705,8 @@ class Engine:
|
|
|
1467
1705
|
"session_cost_usd": state.session_cost_usd,
|
|
1468
1706
|
"session_started_at": state.session_started_at,
|
|
1469
1707
|
"stopped_since": state.stopped_since,
|
|
1708
|
+
# Jobs whose results are only on the machine (as last known here).
|
|
1709
|
+
"job_outputs_unsaved": self.unsaved_job_outputs(state) if state.instance_id else [],
|
|
1470
1710
|
"workloads": [
|
|
1471
1711
|
{
|
|
1472
1712
|
"id": w.id,
|
|
@@ -1565,12 +1805,22 @@ class Engine:
|
|
|
1565
1805
|
self.store.save(state)
|
|
1566
1806
|
return {"changed": True, "state": state.state, "action": action}
|
|
1567
1807
|
|
|
1568
|
-
def destroy(self, reason: str = "manual") -> dict[str, Any]:
|
|
1808
|
+
def destroy(self, reason: str = "manual", discard_outputs: bool = False) -> dict[str, Any]:
|
|
1569
1809
|
with self.store.process_lock():
|
|
1570
1810
|
state = self._reconcile(self.store.load())
|
|
1571
1811
|
if not state.instance_id:
|
|
1572
1812
|
self.echo("= nothing to destroy")
|
|
1573
1813
|
return {"changed": False, "state": state.state}
|
|
1814
|
+
if not discard_outputs:
|
|
1815
|
+
# Results a job wrote are downloaded first, waking a stopped machine.
|
|
1816
|
+
state, left = self._save_job_outputs(state)
|
|
1817
|
+
if left:
|
|
1818
|
+
self.store.save(state)
|
|
1819
|
+
raise StateError(
|
|
1820
|
+
f"job {', '.join(left)} wrote results that are not downloaded yet and "
|
|
1821
|
+
"could not be fetched now; destroying the machine would delete them. "
|
|
1822
|
+
"Retry, or run `gpu job pull`; `gpu destroy --discard-outputs` deletes them."
|
|
1823
|
+
)
|
|
1574
1824
|
self._terminate(state, action=policy.ACTION_DESTROY, reason=reason)
|
|
1575
1825
|
self.store.save(state)
|
|
1576
1826
|
return {"changed": True, "state": state.state}
|
|
@@ -1646,6 +1896,8 @@ class Engine:
|
|
|
1646
1896
|
decision = policy.evaluate(snap, cfg)
|
|
1647
1897
|
if idle_skipped:
|
|
1648
1898
|
decision.detail["idle_skipped"] = "watchdog_unreachable"
|
|
1899
|
+
if apply:
|
|
1900
|
+
state, decision = self._protect_job_outputs(state, decision, snap.lock_active(cfg))
|
|
1649
1901
|
if decision.terminates and apply:
|
|
1650
1902
|
self.events.emit(
|
|
1651
1903
|
ev.LIFECYCLE_GUARD_TRIGGERED,
|
|
@@ -40,6 +40,8 @@ HOST_FAILED = "host_failed"
|
|
|
40
40
|
JOB_SUBMITTED = "job_submitted"
|
|
41
41
|
JOB_FINISHED = "job_finished"
|
|
42
42
|
JOB_OUTPUTS_PULLED = "job_outputs_pulled"
|
|
43
|
+
# Results nobody downloaded kept a machine from being destroyed (or a fetch failed).
|
|
44
|
+
JOB_OUTPUTS_KEPT = "job_outputs_kept"
|
|
43
45
|
|
|
44
46
|
|
|
45
47
|
class EventLog:
|
|
@@ -77,6 +77,8 @@ _ACTION_LOCK = threading.Lock()
|
|
|
77
77
|
_PROBE = {}
|
|
78
78
|
# name -> handler(request, method, path, body) returning True when it answered.
|
|
79
79
|
EXT_ROUTES = {}
|
|
80
|
+
# name -> f(choice, cfg): may change or veto (None) a shutdown (see jobs_ext).
|
|
81
|
+
TERMINATE_HOOKS = {}
|
|
80
82
|
# name -> digest of the loaded source, so the CLI uploads only what changed.
|
|
81
83
|
_EXT = {}
|
|
82
84
|
|
|
@@ -463,6 +465,12 @@ def guard_tick(interval, idle_announced):
|
|
|
463
465
|
|
|
464
466
|
with _LOCK:
|
|
465
467
|
choice = _choose(decision, cfg)
|
|
468
|
+
for hook in list(TERMINATE_HOOKS.values()):
|
|
469
|
+
if choice is not None:
|
|
470
|
+
try:
|
|
471
|
+
choice = hook(choice, cfg)
|
|
472
|
+
except Exception as exc: # noqa: BLE001 - a hook never blocks a shutdown
|
|
473
|
+
log_event("watchdog_error", where="terminate_hook", error=str(exc))
|
|
466
474
|
if choice is None:
|
|
467
475
|
return idle_announced
|
|
468
476
|
action, reason, original = choice
|