gpu4agents 0.7.0__tar.gz → 0.9.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 (142) hide show
  1. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/.claude-plugin/plugin.json +1 -1
  2. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/.cursor-plugin/plugin.json +1 -1
  3. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/CHANGELOG.md +31 -0
  4. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/INSTALL.md +1 -1
  5. gpu4agents-0.9.0/JOBS.md +82 -0
  6. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/PKG-INFO +33 -1
  7. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/README.md +32 -0
  8. gpu4agents-0.9.0/SERVING.md +114 -0
  9. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/docs/CONFIG.md +5 -2
  10. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/__init__.py +1 -1
  11. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/agent/mcp.py +141 -5
  12. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/agent/skill/SKILL.md +27 -3
  13. gpu4agents-0.9.0/gpu4agents/cli/job.py +295 -0
  14. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/cli/main.py +3 -1
  15. gpu4agents-0.9.0/gpu4agents/cli/setup.py +348 -0
  16. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/core/config.py +186 -3
  17. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/core/engine.py +365 -2
  18. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/core/events.py +4 -0
  19. gpu4agents-0.9.0/gpu4agents/core/job.py +378 -0
  20. gpu4agents-0.9.0/gpu4agents/runtime/__init__.py +17 -0
  21. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/runtime/base.py +22 -2
  22. gpu4agents-0.9.0/gpu4agents/runtime/service.py +197 -0
  23. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/runtime/vllm.py +5 -0
  24. gpu4agents-0.9.0/gpu4agents/serve/__init__.py +56 -0
  25. gpu4agents-0.9.0/gpu4agents/serve/hf/__init__.py +0 -0
  26. gpu4agents-0.9.0/gpu4agents/serve/hf/install.sh +34 -0
  27. gpu4agents-0.9.0/gpu4agents/serve/hf/server.py +981 -0
  28. gpu4agents-0.9.0/gpu4agents/serve/template/__init__.py +0 -0
  29. gpu4agents-0.9.0/gpu4agents/serve/template/gpujob.yaml +5 -0
  30. gpu4agents-0.9.0/gpu4agents/serve/template/server.py +136 -0
  31. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/watchdog/agent_body.py +81 -0
  32. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/watchdog/builder.py +13 -9
  33. gpu4agents-0.9.0/gpu4agents/watchdog/jobs_ext.py +505 -0
  34. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/install.sh +2 -2
  35. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/pyproject.toml +1 -1
  36. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/skills/gpu4agents/SKILL.md +27 -3
  37. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/tests/conftest.py +2 -0
  38. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/tests/test_agent.py +15 -1
  39. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/tests/test_engine.py +4 -4
  40. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/tests/test_integration.py +183 -0
  41. gpu4agents-0.9.0/tests/test_jobs.py +335 -0
  42. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/tests/test_runtime_vllm.py +1 -1
  43. gpu4agents-0.9.0/tests/test_serve.py +565 -0
  44. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/tests/test_watchdog.py +1 -1
  45. gpu4agents-0.7.0/gpu4agents/cli/setup.py +0 -189
  46. gpu4agents-0.7.0/gpu4agents/runtime/__init__.py +0 -6
  47. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/.claude-plugin/marketplace.json +0 -0
  48. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/.env.example +0 -0
  49. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
  50. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/.github/ISSUE_TEMPLATE/config.yml +0 -0
  51. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
  52. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/.github/dependabot.yml +0 -0
  53. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/.github/pull_request_template.md +0 -0
  54. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/.github/workflows/ci.yml +0 -0
  55. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/.github/workflows/release.yml +0 -0
  56. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/.gitignore +0 -0
  57. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/CODE_OF_CONDUCT.md +0 -0
  58. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/CONTRIBUTING.md +0 -0
  59. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/LICENSE +0 -0
  60. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/PROVIDERS.md +0 -0
  61. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/SECURITY.md +0 -0
  62. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/docs/ACCEPTANCE.md +0 -0
  63. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/docs/ADDING_A_PROVIDER.md +0 -0
  64. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/docs/AGENTS.md +0 -0
  65. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/docs/CHOOSING_A_MODEL.md +0 -0
  66. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/docs/INTEGRATION.md +0 -0
  67. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/docs/LIFECYCLE.md +0 -0
  68. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/docs/USAGE.md +0 -0
  69. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/docs/assets/banner.png +0 -0
  70. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/docs/assets/jambu-logo.jpg +0 -0
  71. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/examples/experiment.py +0 -0
  72. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/examples/jambu.yaml +0 -0
  73. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/examples/mastra-agent/README.md +0 -0
  74. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/examples/mastra-agent/package-lock.json +0 -0
  75. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/examples/mastra-agent/package.json +0 -0
  76. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/examples/mastra-agent/src/agent.ts +0 -0
  77. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/examples/mastra-agent/src/index.ts +0 -0
  78. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/examples/mastra-agent/src/tools/weather-tool.ts +0 -0
  79. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/examples/mastra-agent/tsconfig.json +0 -0
  80. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/examples/typescript-client/README.md +0 -0
  81. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/examples/typescript-client/package-lock.json +0 -0
  82. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/examples/typescript-client/package.json +0 -0
  83. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/examples/typescript-client/src/gpu.ts +0 -0
  84. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/examples/typescript-client/src/index.ts +0 -0
  85. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/examples/typescript-client/tsconfig.json +0 -0
  86. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/__main__.py +0 -0
  87. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/agent/__init__.py +0 -0
  88. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/agent/install.py +0 -0
  89. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/agent/jobs.py +0 -0
  90. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/cli/__init__.py +0 -0
  91. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/cli/_common.py +0 -0
  92. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/cli/account.py +0 -0
  93. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/cli/agent.py +0 -0
  94. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/cli/inspect.py +0 -0
  95. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/cli/lifecycle.py +0 -0
  96. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/cli/providers.py +0 -0
  97. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/cli/run.py +0 -0
  98. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/cli/status.py +0 -0
  99. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/cli/timer.py +0 -0
  100. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/cli/validate.py +0 -0
  101. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/core/__init__.py +0 -0
  102. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/core/beacon.py +0 -0
  103. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/core/credentials.py +0 -0
  104. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/core/durations.py +0 -0
  105. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/core/errors.py +0 -0
  106. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/core/execution.py +0 -0
  107. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/core/health.py +0 -0
  108. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/core/hosts.py +0 -0
  109. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/core/model_inspect.py +0 -0
  110. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/core/models.py +0 -0
  111. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/core/paths.py +0 -0
  112. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/core/policy.py +0 -0
  113. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/core/state.py +0 -0
  114. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/core/sweep.py +0 -0
  115. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/core/tool_parsers.py +0 -0
  116. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/providers/__init__.py +0 -0
  117. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/providers/base.py +0 -0
  118. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/providers/registry.py +0 -0
  119. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/providers/scaffold.py +0 -0
  120. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/providers/vast/__init__.py +0 -0
  121. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/providers/vast/client.py +0 -0
  122. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/providers/vast/config.py +0 -0
  123. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/providers/vast/mapper.py +0 -0
  124. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/providers/vast/provider.py +0 -0
  125. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/gpu4agents/watchdog/__init__.py +0 -0
  126. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/jambu.example.yaml +0 -0
  127. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/jambu.models.yaml +0 -0
  128. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/jambu.yaml +0 -0
  129. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/jambu_gpu/__init__.py +0 -0
  130. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/jambu_gpu/__main__.py +0 -0
  131. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/skills/gpu4agents/agents/openai.yaml +0 -0
  132. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/tests/fakes.py +0 -0
  133. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/tests/test_cli.py +0 -0
  134. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/tests/test_config.py +0 -0
  135. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/tests/test_engine_sessions.py +0 -0
  136. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/tests/test_model_inspect.py +0 -0
  137. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/tests/test_paths.py +0 -0
  138. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/tests/test_policy.py +0 -0
  139. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/tests/test_state.py +0 -0
  140. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/tests/test_sweep.py +0 -0
  141. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/tests/test_vast_mapper.py +0 -0
  142. {gpu4agents-0.7.0 → gpu4agents-0.9.0}/tests/test_vast_provider.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.7.0",
4
+ "version": "0.9.0",
5
5
  "author": {
6
6
  "name": "João Gabriel Lima",
7
7
  "url": "https://www.linkedin.com/in/joaogabriellima"
@@ -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.7.0",
4
+ "version": "0.9.0",
5
5
  "author": {
6
6
  "name": "João Gabriel Lima"
7
7
  },
@@ -2,6 +2,37 @@
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.9.0] - 2026-11-04
6
+
7
+ ### Added
8
+ - **Serve any Hugging Face model.** `gpu init --model <repo>` reads the Hugging Face model card and picks the server: chat and vision-language models stay on vLLM; every other task runs on gpu's own OpenAI-compatible server (`runtime.engine: hf`): `/v1/embeddings`, `/v1/images/generations`, `/v1/audio/transcriptions` and `/translations`, `/v1/audio/speech`, and `/v1/pipeline` for any other transformers pipeline. `model.task` records which; `--engine` and `--task` override the card, and `runtime.packages` adds pip packages a model needs.
9
+ - `runtime.engine: custom`: a model server the agent writes. `gpu init --engine custom` scaffolds `server/server.py` and `server/gpujob.yaml`; gpu uploads and runs it like the built-in one. [`SERVING.md`](SERVING.md), served at `gpu4agents.jambu.ai/serving.md`, is the contract.
10
+ - Both run as *service jobs* on the job runner: deployed after boot, so changing the model or the server's code and running `gpu setup` swaps the server on the same machine instead of renting a new one. `gpu redeploy` restarts it.
11
+ - Requests to these servers count as activity through their `/metrics`, so a machine in use stays up and an unused one stops after `idle_timeout`. A server that dies while loading ends `gpu setup` with its log, and `gpu logs` shows it.
12
+ - `gpu env --format json`, `gpu setup --json` and the MCP connection now include `engine`, `task` and `routes`. `gpu_init` takes `engine` and `task` and reports what it chose.
13
+ - `GPU_NO_MODEL_CARD=1` makes `gpu init` skip reading the model card (offline).
14
+
15
+ ## [0.8.0] - 2026-11-04
16
+
17
+ ### Added
18
+ - **Jobs: your own code on the GPU.** `gpu job run` packs a directory, uploads it to the rented machine, runs a shell command there, streams the log and downloads whatever the job wrote to `$JAMBU_OUTPUT_DIR` into `gpu-outputs/<job id>/`. Use it for anything that needs CUDA and is not a request to a served model: training or fine-tuning, image, audio or video models, batches, benchmarks. `gpu job status | logs -f | pull | cancel | ls` follow it.
19
+ - A running job counts as work: the watchdog on the machine heartbeats it, so the machine stays up with no laptop connected and becomes idle when the job ends. `max_lifetime` and the session budget still apply. Jobs survive a watchdog respawn; their exit code is written by the job's own shell.
20
+ - `gpujob.yaml` next to the code declares `run`, `setup`, `env`, `timeout`, `exclude` and `label`. `.git`, virtualenvs, caches, `.env` files and earlier outputs never upload.
21
+ - [`JOBS.md`](JOBS.md), served at `gpu4agents.jambu.ai/jobs.md`: the contract an agent follows to write a job.
22
+ - `gpu init --jobs` writes a `jambu.yaml` for a machine that serves no model (`runtime.engine: none`, PyTorch 2.8 with CUDA 12.8). `model` is now optional when nothing is served. `--min-vram-gb` sets the GPU size.
23
+ - MCP tools `gpu_job_run`, `gpu_job_status`, `gpu_job_pull` and `gpu_job_cancel`.
24
+ - The watchdog loads extensions the CLI uploads once the machine is up (`POST /extend`), so the boot script stays under Vast.ai's 16 KB limit. The job runner is the first one.
25
+
26
+ ### Changed
27
+ - The boot payload is base85 instead of base64, about 700 bytes smaller.
28
+ - The default image for `runtime.engine: none` is `pytorch/pytorch:2.8.0-cuda12.8-cudnn9-runtime` (was 2.4.0 with CUDA 12.1).
29
+
30
+ ### Fixed
31
+ - A machine with `runtime.engine: none` stayed in "starting" until the boot grace ran out (about 45 minutes), so an unused one could not idle out sooner.
32
+
33
+ ### Upgrading
34
+ - Machines rented by an earlier version have a watchdog that cannot load the job runner. `gpu job run` says so; `gpu setup --recreate` replaces the machine.
35
+
5
36
  ## [0.7.0] - 2026-11-02
6
37
 
7
38
  ### Added
@@ -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.7.0 or later. Use `~/.local/bin/gpu` for the rest of this session if plain `gpu` is not found.
23
+ Check: `~/.local/bin/gpu --version` prints 0.9.0 or later. Use `~/.local/bin/gpu` for the rest of this session if plain `gpu` is not found.
24
24
 
25
25
  ## 2. Connect a GPU provider account
26
26
 
@@ -0,0 +1,82 @@
1
+ # Run your own code on the GPU (instructions for the agent)
2
+
3
+ You are a coding agent and the work needs a GPU: training or fine-tuning, an image, audio or video model, a batch over a dataset, a kernel benchmark, anything that wants CUDA. GPU for Agents (`gpu`) rents the machine, runs your code on it as a **job**, brings back the files it writes, and stops the machine once nothing runs. This page is the contract a job follows. Follow it exactly.
4
+
5
+ ## 1. The machine
6
+
7
+ The job runs on the project's machine, described by `jambu.yaml`. For a machine that only runs jobs:
8
+
9
+ ```bash
10
+ gpu init --jobs --min-vram-gb 24 # runtime.engine: none, image pytorch/pytorch:2.8.0-cuda12.8-cudnn9-runtime
11
+ ```
12
+
13
+ Size `--min-vram-gb` for the job (a 7B model in bf16 needs about 16 GB to run and much more to fully fine-tune; LoRA on 7B fits in 24 GB). To use a different image, set `compute.image`. It needs `bash` and `python3`.
14
+
15
+ A project that serves a model with vLLM can run jobs too. The job then reaches the model over loopback through `OPENAI_BASE_URL`, `OPENAI_API_KEY` and `JAMBU_MODEL_ID`, which are already set, and vLLM holds most of the GPU memory.
16
+
17
+ ## 2. The job directory
18
+
19
+ Put everything the job needs in one directory (the project directory by default):
20
+
21
+ ```
22
+ my-job/
23
+ gpujob.yaml # what to run (optional; flags override it)
24
+ train.py # your code
25
+ requirements.txt # installed by setup:
26
+ ```
27
+
28
+ `gpujob.yaml`:
29
+
30
+ ```yaml
31
+ run: python train.py --epochs 3 # required here or as `gpu job run -- CMD`
32
+ setup: pip install -r requirements.txt # runs first; if it fails, run does not
33
+ env: # extra environment variables
34
+ EPOCHS: "3"
35
+ timeout: 2h # killed after this long (exit 124)
36
+ exclude: [data/raw, "*.ckpt"] # left out of the upload
37
+ label: lora-qwen-7b
38
+ ```
39
+
40
+ These never upload: `.git`, virtualenvs, `__pycache__`, `node_modules`, `.gpu`, `.env` and `.env.*`, and `gpu-outputs/`. The upload limit is 2 GB. Have the job download large data itself (Hugging Face, a URL) instead of shipping it.
41
+
42
+ ## 3. What the job can count on
43
+
44
+ - It runs in its own copy of the directory, with that copy as the working directory.
45
+ - `JAMBU_OUTPUT_DIR`: write every result here (files, checkpoints, images, metrics). Nothing else comes back.
46
+ - `JAMBU_JOB_ID` and `JAMBU_JOB_DIR` are set.
47
+ - `HF_HOME` points to a cache on the machine's disk, so a model downloaded once is reused by the next job on that machine. `HF_TOKEN` is set when the project has one (`gpu login` or `.env`).
48
+ - stdout and stderr go into one log. Python output is unbuffered.
49
+ - The exit code is the job's result: 0 means succeeded, anything else means failed.
50
+ - The provider credential the machine uses to stop itself is removed from the environment.
51
+
52
+ ## 4. Rules for the code you write
53
+
54
+ 1. Write results only to `$JAMBU_OUTPUT_DIR`. Write checkpoints there as you go, so a pull mid-run or a cut-off job still leaves something.
55
+ 2. Print progress lines (step, loss, items done). The log is the only way anyone sees the job running.
56
+ 3. Exit non-zero on failure. Do not catch every exception and exit 0.
57
+ 4. Never print secrets, and never write them into outputs.
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 stop the machine even while a job runs. Set `timeout:` below them.
60
+
61
+ ## 5. Running it
62
+
63
+ With the user's yes (renting costs money; show `gpu offers` first):
64
+
65
+ ```bash
66
+ gpu job run # pack, upload, run, stream the log, download the outputs
67
+ gpu job run -- python eval.py # the command, without gpujob.yaml
68
+ gpu job run --detach # return once it starts
69
+ gpu job status # state, exit code, time, cost, output files (latest job)
70
+ gpu job logs -f # follow the log
71
+ gpu job pull # outputs into gpu-outputs/<job id>/ (works mid-run)
72
+ gpu job cancel # TERM, then KILL after 10 s
73
+ gpu job ls
74
+ ```
75
+
76
+ Through MCP: `gpu_setup` until ready, `gpu_job_run`, then `gpu_job_status(job_id)` until the state is no longer `running`, then `gpu_job_pull(job_id)`.
77
+
78
+ States: `running`, `succeeded`, `failed`, `timeout`, `cancelled`, `lost` (the machine restarted under it). `gpu job run` exits with the job's code, 124 on timeout and 130 on cancel.
79
+
80
+ ## 6. Afterwards
81
+
82
+ The machine stops by itself after `idle_timeout` (15 min) once no job runs. A stopped machine keeps its disk, so `gpu setup` restarts it and `gpu job pull` still works. `gpu destroy` deletes the disk and every job file on it, so pull the outputs first. 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.7.0
3
+ Version: 0.9.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
@@ -131,6 +131,37 @@ gpu login --check # which account gpu finds, and its balance
131
131
 
132
132
  Restart the agent and ask for an experiment. See [Letting a coding agent rent GPUs](docs/AGENTS.md).
133
133
 
134
+ ## Run your own code on the GPU
135
+
136
+ Serving a model is one use. A **job** is any program: training a LoRA, generating images or audio with an open model, a batch over a dataset, a CUDA benchmark. The agent writes the code in a directory, and `gpu` uploads it, runs it on the rented machine, streams the log and brings back whatever it wrote to `$JAMBU_OUTPUT_DIR`. The machine stays up while the job runs and stops by itself after it ends.
137
+
138
+ ```bash
139
+ gpu init --jobs --min-vram-gb 24 # a machine that runs jobs, no model server
140
+ gpu job run -- python train.py --epochs 3 # upload, run, follow, download to gpu-outputs/<job id>/
141
+ gpu job status # state, exit code, time, cost
142
+ ```
143
+
144
+ To have the agent write one, paste:
145
+
146
+ ```text
147
+ Write this as a GPU for Agents job and run it. Fetch https://gpu4agents.jambu.ai/jobs.md with curl and follow its contract.
148
+ ```
149
+
150
+ [JOBS.md](JOBS.md) has the contract: the directory, `gpujob.yaml`, the environment a job gets, and the rules its code follows.
151
+
152
+ ## Serve any model
153
+
154
+ Give `gpu` a Hugging Face model id and it serves it behind the OpenAI API shapes, whatever the model does. It reads the model card: chat and vision-language models run on vLLM; image, voice, transcription, embedding and other pipeline models run on gpu's own server. Any OpenAI client then works unchanged.
155
+
156
+ ```bash
157
+ gpu init --model stabilityai/sd-turbo # text-to-image -> /v1/images/generations
158
+ gpu init --model openai/whisper-large-v3 # speech recognition -> /v1/audio/transcriptions
159
+ gpu init --model BAAI/bge-m3 # embeddings -> /v1/embeddings
160
+ gpu setup && eval "$(gpu env)" # OPENAI_BASE_URL, OPENAI_API_KEY, JAMBU_MODEL_ID
161
+ ```
162
+
163
+ Requests count as activity, so the machine stays up while clients call it and stops by itself once they stop. Pointing `model.id` at another model and running `gpu setup` again swaps the model on the same GPU, with no new rental. When no built-in server can load a model, `gpu init --engine custom` writes a small server for the agent to fill in, and gpu runs it the same way. [SERVING.md](SERVING.md) has the contract, the routes and the limits.
164
+
134
165
  ## Use any GPU provider
135
166
 
136
167
  `gpu` talks to providers through a small contract: find offers, rent, report status, stop, destroy, and two calls the watchdog makes from the machine to shut itself down. Vast.ai ships with it. For anything else, such as RunPod, Lambda or your company's cluster, paste this into your agent:
@@ -186,6 +217,7 @@ A full example is [`jambu.example.yaml`](jambu.example.yaml). `gpu ls` shows eve
186
217
 
187
218
  - [Letting a coding agent rent GPUs (Claude Code, Codex, Gemini CLI, Cursor, Claude Desktop)](docs/AGENTS.md)
188
219
  - [Integrating into an application (any language)](docs/INTEGRATION.md)
220
+ - [Running your own code as a job](JOBS.md)
189
221
  - [Commands, workloads, and agents](docs/USAGE.md)
190
222
  - [Every config field](docs/CONFIG.md)
191
223
  - [Choosing a model](docs/CHOOSING_A_MODEL.md)
@@ -90,6 +90,37 @@ gpu login --check # which account gpu finds, and its balance
90
90
 
91
91
  Restart the agent and ask for an experiment. See [Letting a coding agent rent GPUs](docs/AGENTS.md).
92
92
 
93
+ ## Run your own code on the GPU
94
+
95
+ Serving a model is one use. A **job** is any program: training a LoRA, generating images or audio with an open model, a batch over a dataset, a CUDA benchmark. The agent writes the code in a directory, and `gpu` uploads it, runs it on the rented machine, streams the log and brings back whatever it wrote to `$JAMBU_OUTPUT_DIR`. The machine stays up while the job runs and stops by itself after it ends.
96
+
97
+ ```bash
98
+ gpu init --jobs --min-vram-gb 24 # a machine that runs jobs, no model server
99
+ gpu job run -- python train.py --epochs 3 # upload, run, follow, download to gpu-outputs/<job id>/
100
+ gpu job status # state, exit code, time, cost
101
+ ```
102
+
103
+ To have the agent write one, paste:
104
+
105
+ ```text
106
+ Write this as a GPU for Agents job and run it. Fetch https://gpu4agents.jambu.ai/jobs.md with curl and follow its contract.
107
+ ```
108
+
109
+ [JOBS.md](JOBS.md) has the contract: the directory, `gpujob.yaml`, the environment a job gets, and the rules its code follows.
110
+
111
+ ## Serve any model
112
+
113
+ Give `gpu` a Hugging Face model id and it serves it behind the OpenAI API shapes, whatever the model does. It reads the model card: chat and vision-language models run on vLLM; image, voice, transcription, embedding and other pipeline models run on gpu's own server. Any OpenAI client then works unchanged.
114
+
115
+ ```bash
116
+ gpu init --model stabilityai/sd-turbo # text-to-image -> /v1/images/generations
117
+ gpu init --model openai/whisper-large-v3 # speech recognition -> /v1/audio/transcriptions
118
+ gpu init --model BAAI/bge-m3 # embeddings -> /v1/embeddings
119
+ gpu setup && eval "$(gpu env)" # OPENAI_BASE_URL, OPENAI_API_KEY, JAMBU_MODEL_ID
120
+ ```
121
+
122
+ Requests count as activity, so the machine stays up while clients call it and stops by itself once they stop. Pointing `model.id` at another model and running `gpu setup` again swaps the model on the same GPU, with no new rental. When no built-in server can load a model, `gpu init --engine custom` writes a small server for the agent to fill in, and gpu runs it the same way. [SERVING.md](SERVING.md) has the contract, the routes and the limits.
123
+
93
124
  ## Use any GPU provider
94
125
 
95
126
  `gpu` talks to providers through a small contract: find offers, rent, report status, stop, destroy, and two calls the watchdog makes from the machine to shut itself down. Vast.ai ships with it. For anything else, such as RunPod, Lambda or your company's cluster, paste this into your agent:
@@ -145,6 +176,7 @@ A full example is [`jambu.example.yaml`](jambu.example.yaml). `gpu ls` shows eve
145
176
 
146
177
  - [Letting a coding agent rent GPUs (Claude Code, Codex, Gemini CLI, Cursor, Claude Desktop)](docs/AGENTS.md)
147
178
  - [Integrating into an application (any language)](docs/INTEGRATION.md)
179
+ - [Running your own code as a job](JOBS.md)
148
180
  - [Commands, workloads, and agents](docs/USAGE.md)
149
181
  - [Every config field](docs/CONFIG.md)
150
182
  - [Choosing a model](docs/CHOOSING_A_MODEL.md)
@@ -0,0 +1,114 @@
1
+ # Serve any model behind an OpenAI-compatible API (instructions for the agent)
2
+
3
+ You are a coding agent and the work needs a model that is not a chat model, or a chat model on your own terms: an image generator, a voice, a transcriber, an embedding model, a detector, an open model with its own policy. GPU for Agents (`gpu`) rents the GPU, serves the model there behind the OpenAI API shapes, and stops the machine once nobody calls it. This page is the contract. Follow it exactly.
4
+
5
+ ## 1. Choosing the model and its server
6
+
7
+ ```bash
8
+ gpu init --model stabilityai/sd-turbo # reads the model card, writes jambu.yaml
9
+ gpu offers # prices; ask the user before renting
10
+ gpu setup # rents, deploys, waits until the model answers
11
+ eval "$(gpu env)" # OPENAI_BASE_URL, OPENAI_API_KEY, JAMBU_MODEL_ID
12
+ ```
13
+
14
+ `gpu init` reads the model's Hugging Face card (`pipeline_tag`, `library_name`) and writes one of three engines:
15
+
16
+ | The model | `runtime.engine` | `model.task` | Routes |
17
+ |---|---|---|---|
18
+ | chat, vision-language (`text-generation`, `image-text-to-text`) | `vllm` | chat | `/v1/chat/completions`, `/v1/completions`, `/v1/responses` |
19
+ | embeddings (`feature-extraction`, `sentence-similarity`) | `hf` | `embeddings` | `/v1/embeddings` |
20
+ | images (`text-to-image`, diffusers) | `hf` | `image` | `/v1/images/generations` |
21
+ | transcription (`automatic-speech-recognition`) | `hf` | `transcription` | `/v1/audio/transcriptions`, `/v1/audio/translations` |
22
+ | voice (`text-to-speech`, `text-to-audio`) | `hf` | `speech` | `/v1/audio/speech` |
23
+ | any other pipeline (detection, classification, translation, depth, ...) | `hf` | `pipeline` | `/v1/pipeline` |
24
+ | a model the above cannot load | `custom` | (yours) | (yours, section 4) |
25
+
26
+ Flags win over the card: `--engine hf --task speech`, `--min-vram-gb 24`. A chat model vLLM cannot run can go on `hf` with `--task chat`. `GET /v1/models` on the endpoint lists the model, its task and its routes.
27
+
28
+ `engine: hf` runs gpu's own server (`gpu4agents/serve/hf/server.py`) on `pytorch/pytorch:2.8.0-cuda12.8-cudnn9-runtime`. It installs `transformers`, `diffusers`, `sentence-transformers` or `soundfile` as the task needs, then loads the model. When the model card asks for more packages, list them, pinned:
29
+
30
+ ```yaml
31
+ gpu_runtime:
32
+ model:
33
+ id: org/model
34
+ task: speech
35
+ runtime:
36
+ engine: hf
37
+ packages: ["phonemizer==3.3.0"]
38
+ ```
39
+
40
+ ## 2. Call it with any OpenAI client
41
+
42
+ The base URL and key come from `gpu env` (or `gpu_connection` over MCP). The key is per machine.
43
+
44
+ ```python
45
+ import base64
46
+ from openai import OpenAI
47
+ client = OpenAI() # reads OPENAI_BASE_URL and OPENAI_API_KEY
48
+ model = "stabilityai/sd-turbo" # JAMBU_MODEL_ID
49
+
50
+ # image
51
+ img = client.images.generate(model=model, prompt="a red fox, watercolor", size="512x512",
52
+ extra_body={"num_inference_steps": 2, "guidance_scale": 0.0, "seed": 7})
53
+ open("fox.png", "wb").write(base64.b64decode(img.data[0].b64_json))
54
+
55
+ # voice (WAV; mp3, flac and opus when the machine's libsndfile can write them)
56
+ client.audio.speech.create(model=model, voice="default", input="Hello.", response_format="wav").write_to_file("hi.wav")
57
+
58
+ # transcription (wav, flac, ogg, mp3); response_format json, text, srt, vtt, verbose_json
59
+ text = client.audio.transcriptions.create(model=model, file=open("hi.wav", "rb")).text
60
+
61
+ # embeddings (float or base64; the SDK asks for base64 by default)
62
+ vectors = client.embeddings.create(model=model, input=["first", "second"]).data
63
+ ```
64
+
65
+ Any other pipeline task takes JSON, with images and audio as base64 data URLs, and returns the pipeline's output as JSON (images inside it come back as base64 PNG):
66
+
67
+ ```bash
68
+ curl -s "$OPENAI_BASE_URL/pipeline" -H "Authorization: Bearer $OPENAI_API_KEY" \
69
+ -d '{"inputs": "data:image/jpeg;base64,...", "parameters": {"threshold": 0.9}}'
70
+ ```
71
+
72
+ Image extras go in the body (`extra_body` in the SDK): `num_inference_steps`, `guidance_scale`, `negative_prompt`, `seed`, `output_format` (png, jpeg, webp). `response_format: "url"` returns a data URL, since nothing is hosted.
73
+
74
+ ## 3. Lifecycle
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 stops by itself after `lifecycle.idle_timeout` (15 min) once they stop. `max_lifetime` and the session budget still apply.
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
+ - A machine serves one model, and the GPU takes one request at a time; the rest queue. For concurrent chat traffic, use vLLM.
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
+ - A stopped machine keeps its disk, weights included: `gpu setup` restarts it and redeploys in about a minute.
81
+
82
+ ## 4. Your own server (`runtime.engine: custom`)
83
+
84
+ When no built-in server loads the model (a library of its own, a pipeline of several models, video, a custom API), write the server. gpu runs it on the GPU and treats it exactly like the built-in one.
85
+
86
+ ```bash
87
+ gpu init --engine custom --min-vram-gb 24 # writes jambu.yaml and server/ (server.py, gpujob.yaml)
88
+ ```
89
+
90
+ `server/gpujob.yaml` says how to start it:
91
+
92
+ ```yaml
93
+ run: python3 server.py
94
+ setup: pip install -r requirements.txt # pinned; torch already comes with the image
95
+ env: {}
96
+ ```
97
+
98
+ The server must:
99
+
100
+ 1. Listen on `0.0.0.0:$PORT`.
101
+ 2. Answer `GET /health` with 503 until the model is loaded, then 200. `gpu setup` waits for the 200.
102
+ 3. Require `Authorization: Bearer $JAMBU_API_KEY` on every route except `/health` and `/metrics`.
103
+ 4. Serve `GET /metrics` in Prometheus text with `jambu_requests_running` (a gauge) and `jambu_requests_total` (a counter). Without them, requests do not count as activity and the machine stops after `idle_timeout` even while in use.
104
+ 5. Use the OpenAI request and response shapes where one exists, so OpenAI clients work unchanged. Invent a route only for what OpenAI has no shape for.
105
+ 6. Exit non-zero when loading fails, after printing why. Never print secrets.
106
+
107
+ The template in `server/server.py` already does 1 to 4; write `load()` and the handlers. It also gets `JAMBU_MODEL_ID` (the config's `model.id`, if any), `HF_HOME` (a cache on the machine's disk) and `HF_TOKEN` when the project has one. The same exclusions as jobs apply to the upload (`.git`, virtualenvs, `.env` files, ...), and the 2 GB limit: download weights in `load()`, do not ship them.
108
+
109
+ ## 5. Rules
110
+
111
+ 1. Renting costs money: show `gpu offers` and get the user's yes before `gpu setup`.
112
+ 2. Size `--min-vram-gb` from the weights: bf16 needs about 2 GB per billion parameters, plus room for activations (a 12B image model wants 32 GB or more; `gpu init` sizes it from the card when it can).
113
+ 3. Use models for what their licenses and the user's purpose allow. Open models with other policies are for legitimate work the user owns: research, evaluation, red-teaming their own systems, creative work.
114
+ 4. When the work is done, tell the user what ran, the endpoint, the cost (`gpu status`), and offer `gpu stop` or `gpu destroy`.
@@ -92,11 +92,12 @@ which source each number comes from.
92
92
 
93
93
  | Field | Default | Meaning |
94
94
  | --- | --- | --- |
95
- | `id` | *required* | HuggingFace repo id. |
95
+ | `id` | *required* | HuggingFace repo id. Optional with `runtime.engine: none` or `custom`. |
96
96
  | `revision` | – | Pin a commit/branch/tag. |
97
97
  | `hf_token_env` | `HF_TOKEN` | Env var holding the HF token for gated models. |
98
98
  | `trust_remote_code` | `false` | Pass `--trust-remote-code` to the runtime. |
99
99
  | `served_name` | – | Name the model is served under (`--served-model-name`). |
100
+ | `task` | `auto` | With `runtime.engine: hf`: `chat`, `embeddings`, `image`, `transcription`, `speech` or `pipeline`, which picks the OpenAI routes ([SERVING.md](../SERVING.md)). `auto` reads the model card's `pipeline_tag` when the server starts; `gpu init` writes the card's answer. |
100
101
 
101
102
  ## `runtime`
102
103
 
@@ -104,7 +105,7 @@ How the model runs. Independent from where it runs.
104
105
 
105
106
  | Field | Default | Meaning |
106
107
  | --- | --- | --- |
107
- | `engine` | `vllm` | `vllm` or `none` (bare compute, start nothing). |
108
+ | `engine` | `vllm` | `vllm` (chat models), `hf` (any other Hugging Face model, gpu's own OpenAI-compatible server), `custom` (a server you write, in `service_dir`) or `none` (bare compute for jobs, start nothing). `hf` and `custom` are deployed after boot: changing the model or the server code redeploys on the same machine at the next `gpu setup`. See [SERVING.md](../SERVING.md). |
108
109
  | `port` | `8000` | Container port the server listens on; published publicly. |
109
110
  | `context_length` | `16384` | `--max-model-len`. |
110
111
  | `dtype` | `auto` | vLLM dtype. |
@@ -116,6 +117,8 @@ How the model runs. Independent from where it runs.
116
117
  | `tool_calling` | `auto` | `auto` guesses `--tool-call-parser` from `model.id` and turns tool calling on if recognized; `on` requires a resolvable parser (fails `validate` otherwise); `off` never passes tool-calling flags. |
117
118
  | `tool_call_parser` | – | Explicit vLLM parser name, overrides the guess. See [vLLM's tool calling docs](https://docs.vllm.ai/en/latest/features/tool_calling/) for the current list (`hermes`, `llama3_json`, `llama4_pythonic`, `mistral`, `granite`, `qwen3_xml`, `deepseek_v3`, ...). |
118
119
  | `tool_server` | – | MCP server URL (or `demo`). vLLM routes `/v1/responses` tool calls to it and runs them server-side. Leave unset to let the calling agent framework execute tools itself. |
120
+ | `packages` | `[]` | `hf`: extra pip packages the model needs, installed before it loads. Pin them. |
121
+ | `service_dir` | `server` | `custom`: the directory holding your server and its `gpujob.yaml`, relative to the project. |
119
122
 
120
123
  `gpu inspect-model <repo>` also suggests `dtype`, `context_length` and
121
124
  `tool_calling` for a given model. See
@@ -1,5 +1,5 @@
1
1
  """GPU for Agents: GPUs your agent rents on its own, billed only while they work."""
2
2
 
3
- __version__ = "0.7.0"
3
+ __version__ = "0.9.0"
4
4
 
5
5
  __all__ = ["__version__"]
@@ -28,6 +28,8 @@ from dataclasses import dataclass, field
28
28
  from pathlib import Path
29
29
  from typing import Any, Callable, Optional
30
30
 
31
+ import yaml
32
+
31
33
  from .. import __version__
32
34
  from ..core.config import find_config
33
35
  from .jobs import Job
@@ -58,8 +60,10 @@ EXIT_MEANINGS = {
58
60
 
59
61
  INSTRUCTIONS = """\
60
62
  gpu rents a cloud GPU (Vast.ai built in; other providers through an adapter),
61
- serves a model on it with vLLM behind an OpenAI-compatible API, and stops it
62
- by itself when nobody uses it.
63
+ serves a model on it behind an OpenAI-compatible API, and stops it by itself
64
+ when nobody uses it. Any Hugging Face model: chat models on vLLM; image,
65
+ speech, transcription, embeddings and other pipeline models on gpu's own
66
+ server (gpu_init picks from the model card; the result says which routes).
63
67
 
64
68
  Rules:
65
69
  - Renting costs the user money. Before the first gpu_setup in a conversation,
@@ -74,6 +78,13 @@ Rules:
74
78
  explicit yes. Finish by checking gpu_ls for anything still running.
75
79
  - Never print or ask for the provider's API key; the user runs `gpu login`
76
80
  in a terminal. The endpoint api_key is per machine.
81
+ - To run your own code on the GPU (training, image or audio models, anything
82
+ that needs CUDA), write it in a directory following
83
+ https://gpu4agents.jambu.ai/jobs.md, then gpu_setup, gpu_job_run,
84
+ gpu_job_status until it ends, and gpu_job_pull for the outputs.
85
+ - To serve a model the built-in servers cannot load, write your own server
86
+ following https://gpu4agents.jambu.ai/serving.md (gpu_init with
87
+ engine="custom" writes a starting one), then gpu_setup.
77
88
  """
78
89
 
79
90
 
@@ -216,6 +227,9 @@ class Server:
216
227
  directory = self._start_dir(args)
217
228
  directory.mkdir(parents=True, exist_ok=True)
218
229
  argv = ["init", "--model", str(args["model"])]
230
+ for key in ("engine", "task"):
231
+ if args.get(key):
232
+ argv += [f"--{key}", str(args[key])]
219
233
  if args.get("force"):
220
234
  argv.append("--force")
221
235
  self._ok(self.cli(argv, directory))
@@ -228,11 +242,23 @@ class Server:
228
242
  if args.get("min_vram_gb") is not None:
229
243
  text = re.sub(r"(min_vram_gb:\s*)[0-9]+", rf"\g<1>{int(args['min_vram_gb'])}", text)
230
244
  config.write_text(text)
231
- return {
245
+ written = (yaml.safe_load(text) or {}).get("gpu_runtime") or {}
246
+ engine = (written.get("runtime") or {}).get("engine")
247
+ result = {
232
248
  "config_path": str(config),
233
249
  "model": args["model"],
250
+ "engine": engine,
251
+ "task": (written.get("model") or {}).get("task") or ("chat" if engine == "vllm" else None),
234
252
  "next": "gpu_validate, then gpu_offers to see prices",
235
253
  }
254
+ if engine == "custom":
255
+ service_dir = (written.get("runtime") or {}).get("service_dir") or "server"
256
+ result["server_dir"] = str(directory / service_dir)
257
+ result["next"] = (
258
+ f"write the model into {service_dir}/server.py following "
259
+ "https://gpu4agents.jambu.ai/serving.md, then gpu_validate and gpu_offers"
260
+ )
261
+ return result
236
262
 
237
263
  def tool_validate(self, args: dict[str, Any]) -> Any:
238
264
  return self._ok(self.cli(["validate"], self._project_dir(args)))
@@ -393,6 +419,51 @@ class Server:
393
419
  result["setup_cancelled"] = cancelled
394
420
  return result
395
421
 
422
+ def tool_job_run(self, args: dict[str, Any]) -> Any:
423
+ project_dir = self._project_dir(args)
424
+ argv = ["job", "run", "--detach", "--no-start"]
425
+ if args.get("dir"):
426
+ argv += ["--dir", str(Path(str(args["dir"])).expanduser())]
427
+ for key in ("setup", "timeout", "label"):
428
+ if args.get(key):
429
+ argv += [f"--{key}", str(args[key])]
430
+ for key, value in (args.get("env") or {}).items():
431
+ argv += ["--env", f"{key}={value}"]
432
+ if args.get("command"):
433
+ argv += ["--", str(args["command"])]
434
+ result = self.cli(argv, project_dir)
435
+ if result.returncode == 3:
436
+ error = result.error()
437
+ error["next"] = "start the machine first with gpu_setup (it costs money: ask the user), then call gpu_job_run again"
438
+ raise ToolError(error)
439
+ data = self._ok(result)
440
+ data["next"] = "call gpu_job_status(job_id) to follow it; gpu_job_pull(job_id) once it ends"
441
+ return data
442
+
443
+ def tool_job_status(self, args: dict[str, Any]) -> Any:
444
+ project_dir = self._project_dir(args)
445
+ job_id = args.get("job_id")
446
+ if not job_id:
447
+ return self._ok(self.cli(["job", "ls"], project_dir))
448
+ info = self._ok(self.cli(["job", "status", str(job_id)], project_dir))
449
+ logs = self.cli(["job", "logs", str(job_id)], project_dir)
450
+ if logs.returncode == 0 and isinstance(logs.data, dict):
451
+ info["log_tail"] = _tail_text(logs.data.get("data") or "", int(args.get("log_chars") or OUTPUT_TAIL_CHARS))
452
+ if info.get("state") == "running":
453
+ info["next"] = "still running; call gpu_job_status again later (the machine stays up while it runs)"
454
+ else:
455
+ info["next"] = "gpu_job_pull(job_id) downloads the outputs; then offer gpu_stop"
456
+ return info
457
+
458
+ def tool_job_pull(self, args: dict[str, Any]) -> Any:
459
+ argv = ["job", "pull", str(args["job_id"])]
460
+ if args.get("dest"):
461
+ argv += ["--out", str(Path(str(args["dest"])).expanduser())]
462
+ return self._ok(self.cli(argv, self._project_dir(args)))
463
+
464
+ def tool_job_cancel(self, args: dict[str, Any]) -> Any:
465
+ return self._ok(self.cli(["job", "cancel", str(args["job_id"])], self._project_dir(args)))
466
+
396
467
  def tool_ls(self, args: dict[str, Any]) -> Any:
397
468
  start = self._start_dir(args)
398
469
  config = find_config(start)
@@ -406,10 +477,23 @@ class Server:
406
477
  "gpu_init",
407
478
  "Create jambu.yaml",
408
479
  "Write a starter jambu.yaml for a HuggingFace model in project_dir. Use once per "
409
- "project, before anything else. Defaults: 24 GB VRAM, $1.00/h cap, stop after 15 min idle.",
480
+ "project, before anything else. Any model: the model card picks the server (chat on "
481
+ "vLLM; image, speech, transcription, embeddings or other pipelines on gpu's hf "
482
+ "server) and the result says which. Defaults: 24 GB VRAM (or sized from the model), "
483
+ "$1.00/h cap, stop after 15 min idle.",
410
484
  _schema(
411
485
  {
412
- "model": {"type": "string", "description": "HuggingFace model id, e.g. Qwen/Qwen2.5-7B-Instruct"},
486
+ "model": {"type": "string", "description": "HuggingFace model id, e.g. Qwen/Qwen2.5-7B-Instruct or openai/whisper-large-v3"},
487
+ "engine": {
488
+ "type": "string",
489
+ "enum": ["auto", "vllm", "hf", "custom", "none"],
490
+ "description": "auto (default) reads the model card. custom: a server you write (serving.md).",
491
+ },
492
+ "task": {
493
+ "type": "string",
494
+ "enum": ["chat", "embeddings", "image", "transcription", "speech", "pipeline"],
495
+ "description": "With engine hf: override the task the model card gives.",
496
+ },
413
497
  "max_hourly_cost_usd": {"type": "number", "description": "Price cap per hour."},
414
498
  "min_vram_gb": {"type": "integer", "description": "Minimum GPU memory."},
415
499
  "force": {"type": "boolean", "description": "Overwrite an existing jambu.yaml."},
@@ -498,6 +582,58 @@ class Server:
498
582
  self.tool_run,
499
583
  {"readOnlyHint": False, "destructiveHint": False, "idempotentHint": False, "openWorldHint": True},
500
584
  ),
585
+ Tool(
586
+ "gpu_job_run",
587
+ "Run code on the GPU",
588
+ "Upload a directory of code to the running GPU machine and start a shell command "
589
+ "there (training, image/audio/video models, anything needing CUDA). Returns job_id "
590
+ "at once; the job keeps the machine up while it runs. Files it writes to "
591
+ "$JAMBU_OUTPUT_DIR come back with gpu_job_pull. Needs a machine started with "
592
+ "gpu_setup. Contract: https://gpu4agents.jambu.ai/jobs.md",
593
+ _schema(
594
+ {
595
+ "dir": {"type": "string", "description": "Directory to upload (default: project_dir). gpujob.yaml there may declare run/setup/env/timeout."},
596
+ "command": {"type": "string", "description": "Shell command, e.g. \"python train.py --epochs 3\". Default: run: in gpujob.yaml."},
597
+ "setup": {"type": "string", "description": "Shell command run first, e.g. \"pip install -r requirements.txt\"."},
598
+ "env": {"type": "object", "additionalProperties": {"type": "string"}},
599
+ "timeout": {"type": "string", "description": "Kill the job after this long, e.g. 2h."},
600
+ "label": {"type": "string"},
601
+ }
602
+ ),
603
+ self.tool_job_run,
604
+ {"readOnlyHint": False, "destructiveHint": False, "idempotentHint": False, "openWorldHint": True},
605
+ ),
606
+ Tool(
607
+ "gpu_job_status",
608
+ "Job status and log",
609
+ "State (running, succeeded, failed, timeout, cancelled), exit code, run time, cost, "
610
+ "output files and the tail of the log of one job. Without job_id, lists this project's jobs.",
611
+ _schema(
612
+ {
613
+ "job_id": {"type": "string"},
614
+ "log_chars": {"type": "integer", "minimum": 100, "maximum": 100000},
615
+ }
616
+ ),
617
+ self.tool_job_status,
618
+ read_only,
619
+ ),
620
+ Tool(
621
+ "gpu_job_pull",
622
+ "Download job outputs",
623
+ "Download what a job wrote to $JAMBU_OUTPUT_DIR into gpu-outputs/<job_id>/ (or dest). "
624
+ "Works while the job still runs. Do it before gpu_destroy: the files live on the machine's disk.",
625
+ _schema({"job_id": {"type": "string"}, "dest": {"type": "string"}}, ["job_id"]),
626
+ self.tool_job_pull,
627
+ {"readOnlyHint": False, "destructiveHint": False, "idempotentHint": True, "openWorldHint": True},
628
+ ),
629
+ Tool(
630
+ "gpu_job_cancel",
631
+ "Cancel a job",
632
+ "Stop a running job (TERM, then KILL after 10 s). Outputs written so far stay.",
633
+ _schema({"job_id": {"type": "string"}}, ["job_id"]),
634
+ self.tool_job_cancel,
635
+ {"readOnlyHint": False, "destructiveHint": True, "idempotentHint": True, "openWorldHint": True},
636
+ ),
501
637
  Tool(
502
638
  "gpu_logs",
503
639
  "GPU logs",