gpu4agents 0.8.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 (141) hide show
  1. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/.claude-plugin/plugin.json +1 -1
  2. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/.cursor-plugin/plugin.json +1 -1
  3. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/CHANGELOG.md +10 -0
  4. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/INSTALL.md +1 -1
  5. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/PKG-INFO +14 -1
  6. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/README.md +13 -0
  7. gpu4agents-0.9.0/SERVING.md +114 -0
  8. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/docs/CONFIG.md +5 -2
  9. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/__init__.py +1 -1
  10. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/agent/mcp.py +40 -5
  11. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/agent/skill/SKILL.md +11 -1
  12. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/cli/main.py +1 -0
  13. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/cli/setup.py +151 -8
  14. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/core/config.py +138 -2
  15. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/core/engine.py +150 -12
  16. gpu4agents-0.9.0/gpu4agents/runtime/__init__.py +17 -0
  17. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/runtime/base.py +7 -0
  18. gpu4agents-0.9.0/gpu4agents/runtime/service.py +197 -0
  19. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/runtime/vllm.py +5 -0
  20. gpu4agents-0.9.0/gpu4agents/serve/__init__.py +56 -0
  21. gpu4agents-0.9.0/gpu4agents/serve/hf/__init__.py +0 -0
  22. gpu4agents-0.9.0/gpu4agents/serve/hf/install.sh +34 -0
  23. gpu4agents-0.9.0/gpu4agents/serve/hf/server.py +981 -0
  24. gpu4agents-0.9.0/gpu4agents/serve/template/__init__.py +0 -0
  25. gpu4agents-0.9.0/gpu4agents/serve/template/gpujob.yaml +5 -0
  26. gpu4agents-0.9.0/gpu4agents/serve/template/server.py +136 -0
  27. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/watchdog/jobs_ext.py +48 -13
  28. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/install.sh +2 -2
  29. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/pyproject.toml +1 -1
  30. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/skills/gpu4agents/SKILL.md +11 -1
  31. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/tests/conftest.py +2 -0
  32. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/tests/test_agent.py +1 -0
  33. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/tests/test_integration.py +112 -0
  34. gpu4agents-0.9.0/tests/test_serve.py +565 -0
  35. gpu4agents-0.8.0/gpu4agents/runtime/__init__.py +0 -6
  36. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/.claude-plugin/marketplace.json +0 -0
  37. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/.env.example +0 -0
  38. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
  39. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/.github/ISSUE_TEMPLATE/config.yml +0 -0
  40. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
  41. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/.github/dependabot.yml +0 -0
  42. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/.github/pull_request_template.md +0 -0
  43. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/.github/workflows/ci.yml +0 -0
  44. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/.github/workflows/release.yml +0 -0
  45. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/.gitignore +0 -0
  46. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/CODE_OF_CONDUCT.md +0 -0
  47. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/CONTRIBUTING.md +0 -0
  48. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/JOBS.md +0 -0
  49. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/LICENSE +0 -0
  50. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/PROVIDERS.md +0 -0
  51. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/SECURITY.md +0 -0
  52. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/docs/ACCEPTANCE.md +0 -0
  53. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/docs/ADDING_A_PROVIDER.md +0 -0
  54. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/docs/AGENTS.md +0 -0
  55. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/docs/CHOOSING_A_MODEL.md +0 -0
  56. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/docs/INTEGRATION.md +0 -0
  57. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/docs/LIFECYCLE.md +0 -0
  58. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/docs/USAGE.md +0 -0
  59. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/docs/assets/banner.png +0 -0
  60. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/docs/assets/jambu-logo.jpg +0 -0
  61. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/examples/experiment.py +0 -0
  62. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/examples/jambu.yaml +0 -0
  63. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/examples/mastra-agent/README.md +0 -0
  64. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/examples/mastra-agent/package-lock.json +0 -0
  65. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/examples/mastra-agent/package.json +0 -0
  66. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/examples/mastra-agent/src/agent.ts +0 -0
  67. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/examples/mastra-agent/src/index.ts +0 -0
  68. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/examples/mastra-agent/src/tools/weather-tool.ts +0 -0
  69. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/examples/mastra-agent/tsconfig.json +0 -0
  70. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/examples/typescript-client/README.md +0 -0
  71. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/examples/typescript-client/package-lock.json +0 -0
  72. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/examples/typescript-client/package.json +0 -0
  73. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/examples/typescript-client/src/gpu.ts +0 -0
  74. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/examples/typescript-client/src/index.ts +0 -0
  75. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/examples/typescript-client/tsconfig.json +0 -0
  76. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/__main__.py +0 -0
  77. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/agent/__init__.py +0 -0
  78. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/agent/install.py +0 -0
  79. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/agent/jobs.py +0 -0
  80. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/cli/__init__.py +0 -0
  81. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/cli/_common.py +0 -0
  82. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/cli/account.py +0 -0
  83. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/cli/agent.py +0 -0
  84. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/cli/inspect.py +0 -0
  85. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/cli/job.py +0 -0
  86. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/cli/lifecycle.py +0 -0
  87. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/cli/providers.py +0 -0
  88. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/cli/run.py +0 -0
  89. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/cli/status.py +0 -0
  90. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/cli/timer.py +0 -0
  91. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/cli/validate.py +0 -0
  92. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/core/__init__.py +0 -0
  93. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/core/beacon.py +0 -0
  94. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/core/credentials.py +0 -0
  95. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/core/durations.py +0 -0
  96. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/core/errors.py +0 -0
  97. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/core/events.py +0 -0
  98. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/core/execution.py +0 -0
  99. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/core/health.py +0 -0
  100. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/core/hosts.py +0 -0
  101. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/core/job.py +0 -0
  102. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/core/model_inspect.py +0 -0
  103. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/core/models.py +0 -0
  104. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/core/paths.py +0 -0
  105. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/core/policy.py +0 -0
  106. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/core/state.py +0 -0
  107. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/core/sweep.py +0 -0
  108. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/core/tool_parsers.py +0 -0
  109. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/providers/__init__.py +0 -0
  110. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/providers/base.py +0 -0
  111. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/providers/registry.py +0 -0
  112. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/providers/scaffold.py +0 -0
  113. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/providers/vast/__init__.py +0 -0
  114. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/providers/vast/client.py +0 -0
  115. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/providers/vast/config.py +0 -0
  116. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/providers/vast/mapper.py +0 -0
  117. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/providers/vast/provider.py +0 -0
  118. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/watchdog/__init__.py +0 -0
  119. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/watchdog/agent_body.py +0 -0
  120. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/gpu4agents/watchdog/builder.py +0 -0
  121. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/jambu.example.yaml +0 -0
  122. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/jambu.models.yaml +0 -0
  123. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/jambu.yaml +0 -0
  124. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/jambu_gpu/__init__.py +0 -0
  125. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/jambu_gpu/__main__.py +0 -0
  126. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/skills/gpu4agents/agents/openai.yaml +0 -0
  127. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/tests/fakes.py +0 -0
  128. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/tests/test_cli.py +0 -0
  129. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/tests/test_config.py +0 -0
  130. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/tests/test_engine.py +0 -0
  131. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/tests/test_engine_sessions.py +0 -0
  132. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/tests/test_jobs.py +0 -0
  133. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/tests/test_model_inspect.py +0 -0
  134. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/tests/test_paths.py +0 -0
  135. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/tests/test_policy.py +0 -0
  136. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/tests/test_runtime_vllm.py +0 -0
  137. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/tests/test_state.py +0 -0
  138. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/tests/test_sweep.py +0 -0
  139. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/tests/test_vast_mapper.py +0 -0
  140. {gpu4agents-0.8.0 → gpu4agents-0.9.0}/tests/test_vast_provider.py +0 -0
  141. {gpu4agents-0.8.0 → gpu4agents-0.9.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.8.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.8.0",
4
+ "version": "0.9.0",
5
5
  "author": {
6
6
  "name": "João Gabriel Lima"
7
7
  },
@@ -2,6 +2,16 @@
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
+
5
15
  ## [0.8.0] - 2026-11-04
6
16
 
7
17
  ### 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.8.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
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: gpu4agents
3
- Version: 0.8.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
@@ -149,6 +149,19 @@ Write this as a GPU for Agents job and run it. Fetch https://gpu4agents.jambu.ai
149
149
 
150
150
  [JOBS.md](JOBS.md) has the contract: the directory, `gpujob.yaml`, the environment a job gets, and the rules its code follows.
151
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
+
152
165
  ## Use any GPU provider
153
166
 
154
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:
@@ -108,6 +108,19 @@ Write this as a GPU for Agents job and run it. Fetch https://gpu4agents.jambu.ai
108
108
 
109
109
  [JOBS.md](JOBS.md) has the contract: the directory, `gpujob.yaml`, the environment a job gets, and the rules its code follows.
110
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
+
111
124
  ## Use any GPU provider
112
125
 
113
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:
@@ -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.8.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,
@@ -78,6 +82,9 @@ Rules:
78
82
  that needs CUDA), write it in a directory following
79
83
  https://gpu4agents.jambu.ai/jobs.md, then gpu_setup, gpu_job_run,
80
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.
81
88
  """
82
89
 
83
90
 
@@ -220,6 +227,9 @@ class Server:
220
227
  directory = self._start_dir(args)
221
228
  directory.mkdir(parents=True, exist_ok=True)
222
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])]
223
233
  if args.get("force"):
224
234
  argv.append("--force")
225
235
  self._ok(self.cli(argv, directory))
@@ -232,11 +242,23 @@ class Server:
232
242
  if args.get("min_vram_gb") is not None:
233
243
  text = re.sub(r"(min_vram_gb:\s*)[0-9]+", rf"\g<1>{int(args['min_vram_gb'])}", text)
234
244
  config.write_text(text)
235
- return {
245
+ written = (yaml.safe_load(text) or {}).get("gpu_runtime") or {}
246
+ engine = (written.get("runtime") or {}).get("engine")
247
+ result = {
236
248
  "config_path": str(config),
237
249
  "model": args["model"],
250
+ "engine": engine,
251
+ "task": (written.get("model") or {}).get("task") or ("chat" if engine == "vllm" else None),
238
252
  "next": "gpu_validate, then gpu_offers to see prices",
239
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
240
262
 
241
263
  def tool_validate(self, args: dict[str, Any]) -> Any:
242
264
  return self._ok(self.cli(["validate"], self._project_dir(args)))
@@ -455,10 +477,23 @@ class Server:
455
477
  "gpu_init",
456
478
  "Create jambu.yaml",
457
479
  "Write a starter jambu.yaml for a HuggingFace model in project_dir. Use once per "
458
- "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.",
459
484
  _schema(
460
485
  {
461
- "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
+ },
462
497
  "max_hourly_cost_usd": {"type": "number", "description": "Price cap per hour."},
463
498
  "min_vram_gb": {"type": "integer", "description": "Minimum GPU memory."},
464
499
  "force": {"type": "boolean", "description": "Overwrite an existing jambu.yaml."},
@@ -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.8.0 or later. If the command is missing or older, install it (Linux and macOS; on Windows, use WSL):
20
+ Check: `gpu --version` prints 0.9.0 or later. 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>
@@ -103,6 +103,16 @@ When the work is code that needs a GPU, not requests to a model (training or fin
103
103
  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`.
104
104
  5. A running job keeps the machine up; `max_lifetime` and the budget still stop it. Pull outputs before `gpu destroy`, which deletes them.
105
105
 
106
+ ## Serve any model (images, voice, transcription, embeddings)
107
+
108
+ Any Hugging Face model can be served behind OpenAI routes, not only chat. The full contract is in https://gpu4agents.jambu.ai/serving.md (copy in the repository: `SERVING.md`). In short:
109
+
110
+ 1. `gpu init --model <repo>` (MCP: `gpu_init`) reads the model card and writes the engine: `vllm` for chat, `hf` for the rest, with `model.task` one of `embeddings`, `image`, `transcription`, `speech`, `pipeline`. The output and `gpu_init`'s result name it; `--engine` and `--task` override.
111
+ 2. `gpu setup` deploys it; `gpu env` (MCP: `gpu_connection`) gives `base_url`, `api_key`, `model` and `routes`. Call it with any OpenAI client: `images.generate`, `audio.speech.create`, `audio.transcriptions.create`, `embeddings.create`; other pipelines take `POST /v1/pipeline` with `{"inputs": ..., "parameters": {...}}`.
112
+ 3. To switch models, edit `model.id` (and `model.task`) in jambu.yaml and run `gpu setup` again: same machine, new server. A larger `min_vram_gb` needs `--recreate`.
113
+ 4. When the built-in server cannot load a model (its own library, several models chained, video), `gpu init --engine custom` writes `server/server.py` and `server/gpujob.yaml`. Fill in `load()` and the handlers; keep `/health` (503 until loaded), the `JAMBU_API_KEY` check and `/metrics` (`jambu_requests_running`, `jambu_requests_total`), and listen on `$PORT`.
114
+ 5. `gpu logs` shows the server's log. Requests keep the machine up; it stops after `idle_timeout` once they stop.
115
+
106
116
  ## Another provider
107
117
 
108
118
  When the user wants a provider `gpu providers` does not list, write an adapter for it. The full steps are in https://gpu4agents.jambu.ai/providers.md (copy in the repository: `PROVIDERS.md`). In short:
@@ -66,6 +66,7 @@ app.add_typer(providers.providers_app, name="providers")
66
66
  app.command("validate")(validate.validate_command)
67
67
  app.command("offers")(setup.offers_command)
68
68
  app.command("setup")(setup.setup_command)
69
+ app.command("redeploy")(setup.redeploy_command)
69
70
  app.command(
70
71
  "run",
71
72
  context_settings={"allow_extra_args": True, "ignore_unknown_options": True},
@@ -8,11 +8,17 @@ import typer
8
8
  from rich.table import Table
9
9
  from rich.text import Text
10
10
 
11
+ import shutil
12
+ from typing import Optional
13
+
11
14
  from ..core.config import (
15
+ CUSTOM_CONFIG_TEMPLATE,
12
16
  DEFAULT_CONFIG_TEMPLATE,
13
17
  DEFAULT_CONFIG_TEMPLATE_FLAT,
14
18
  CONFIG_FILENAMES,
15
19
  JOBS_CONFIG_TEMPLATE,
20
+ MODEL_TASKS,
21
+ SERVE_CONFIG_TEMPLATE,
16
22
  )
17
23
  from ..core.errors import JambuError
18
24
  from ._common import console, fmt_money, get_context, handle, print_json, register_project
@@ -31,7 +37,25 @@ def init_command(
31
37
  "--jobs",
32
38
  help="A machine that serves no model and only runs `gpu job` (runtime.engine: none).",
33
39
  ),
34
- min_vram_gb: int = typer.Option(24, "--min-vram-gb", help="Minimum GPU memory to rent."),
40
+ engine: str = typer.Option(
41
+ "auto",
42
+ "--engine",
43
+ help=(
44
+ "auto (from the model card: chat models on vllm, any other task on hf), "
45
+ "vllm, hf, custom (a server you write, SERVING.md) or none (same as --jobs)."
46
+ ),
47
+ ),
48
+ task: Optional[str] = typer.Option(
49
+ None,
50
+ "--task",
51
+ help="With hf: chat, embeddings, image, transcription, speech or pipeline (default: from the model card).",
52
+ ),
53
+ service_dir: str = typer.Option(
54
+ "server", "--service-dir", help="With --engine custom: where your server lives."
55
+ ),
56
+ min_vram_gb: Optional[int] = typer.Option(
57
+ None, "--min-vram-gb", help="Minimum GPU memory to rent (default 24, or sized from the model)."
58
+ ),
35
59
  force: bool = typer.Option(False, "--force", help="Overwrite an existing config file."),
36
60
  flat: bool = typer.Option(
37
61
  False,
@@ -42,7 +66,13 @@ def init_command(
42
66
  ),
43
67
  ),
44
68
  ) -> None:
45
- """Write a starter jambu.yaml (and .env.example) in the current directory."""
69
+ """Write a starter jambu.yaml (and .env.example) in the current directory.
70
+
71
+ Any Hugging Face model works: a chat model is served by vLLM; an image,
72
+ speech, transcription, embeddings or other pipeline model by gpu's own
73
+ OpenAI-compatible server (runtime.engine: hf). The model card decides,
74
+ unless --engine says otherwise.
75
+ """
46
76
  from ..core.errors import ConfigError as _ConfigError
47
77
  from ..providers import scaffold
48
78
  from ..providers.registry import load_builtin_providers
@@ -56,19 +86,57 @@ def init_command(
56
86
  credential_names = []
57
87
  indent = " " if flat else " "
58
88
  provider_block = f"{indent}name: {provider}\n" + (f"{indent}plugin: {plugin}\n" if plugin else "")
59
- if jobs and flat:
60
- console.print(Text("! --jobs writes jambu.yaml; drop --flat", style="yellow"))
89
+ if engine not in ("auto", "vllm", "hf", "custom", "none"):
90
+ console.print(Text("! --engine must be auto, vllm, hf, custom or none", style="yellow"))
91
+ raise typer.Exit(2)
92
+ if task is not None and task not in MODEL_TASKS:
93
+ console.print(Text(f"! --task must be one of {', '.join(MODEL_TASKS)}", style="yellow"))
94
+ raise typer.Exit(2)
95
+ if jobs:
96
+ engine = "none"
97
+ if flat and engine not in ("auto", "vllm"):
98
+ console.print(Text("! only a vllm config can be --flat; drop --flat", style="yellow"))
61
99
  raise typer.Exit(2)
100
+ model_given = ctx.get_parameter_source("model") is not None and (
101
+ ctx.get_parameter_source("model").name != "DEFAULT"
102
+ )
103
+ sized: Optional[int] = None
104
+ if engine == "auto" or (engine == "hf" and task is None):
105
+ detected_engine, detected_task, sized, note = detect_serving(model, model_given)
106
+ if engine == "auto":
107
+ engine = detected_engine
108
+ task = task or detected_task
109
+ if note:
110
+ console.print(Text(f" {note}", style="dim"))
111
+ vram = min_vram_gb or sized or 24
62
112
  if flat:
63
113
  target = Path.cwd() / "config.yml"
64
114
  content = DEFAULT_CONFIG_TEMPLATE_FLAT.format(model_id=model)
65
- elif jobs:
115
+ elif engine == "none":
116
+ target = Path.cwd() / CONFIG_FILENAMES[0]
117
+ content = JOBS_CONFIG_TEMPLATE.format(min_vram_gb=vram)
118
+ elif engine == "hf":
119
+ target = Path.cwd() / CONFIG_FILENAMES[0]
120
+ task = task or "auto"
121
+ content = SERVE_CONFIG_TEMPLATE.format(
122
+ model_id=model,
123
+ min_vram_gb=vram,
124
+ task=task,
125
+ task_note=(
126
+ "From the model card. chat, embeddings, image, transcription, speech or pipeline."
127
+ if task != "auto"
128
+ else "auto: read from the model card when the server starts."
129
+ ),
130
+ )
131
+ elif engine == "custom":
66
132
  target = Path.cwd() / CONFIG_FILENAMES[0]
67
- content = JOBS_CONFIG_TEMPLATE.format(min_vram_gb=min_vram_gb)
133
+ content = CUSTOM_CONFIG_TEMPLATE.format(
134
+ model_id=model if model_given else '""', min_vram_gb=vram, service_dir=service_dir
135
+ )
68
136
  else:
69
137
  target = Path.cwd() / CONFIG_FILENAMES[0] # jambu.yaml
70
138
  content = DEFAULT_CONFIG_TEMPLATE.format(model_id=model)
71
- content = content.replace("min_vram_gb: 24\n", f"min_vram_gb: {min_vram_gb}\n", 1)
139
+ content = content.replace("min_vram_gb: 24\n", f"min_vram_gb: {vram}\n", 1)
72
140
  content = content.replace(f"{indent}name: vast\n", provider_block, 1)
73
141
 
74
142
  if target.exists() and not force:
@@ -76,6 +144,8 @@ def init_command(
76
144
  raise typer.Exit(1)
77
145
  target.write_text(content)
78
146
  console.print(Text(f"+ wrote {target}", style="green"))
147
+ if engine == "custom":
148
+ scaffold_server(Path.cwd() / service_dir)
79
149
  if not flat:
80
150
  console.print(
81
151
  Text(
@@ -101,8 +171,59 @@ def init_command(
101
171
  )
102
172
  login = "gpu login" if provider == "vast" else f"gpu login --provider {provider}"
103
173
  console.print(f"next: {login} && gpu validate")
104
- if jobs:
174
+ if engine == "none":
105
175
  console.print("then: gpu job run -- python your_script.py (see `gpu job --help`)")
176
+ elif engine == "hf":
177
+ console.print(f"then: gpu setup (serves {model} as {task}; routes in `gpu env --format json`)")
178
+ elif engine == "custom":
179
+ console.print(f"then: write your model into {service_dir}/server.py, and gpu setup")
180
+
181
+
182
+ def detect_serving(model: str, model_given: bool) -> tuple[str, Optional[str], Optional[int], str]:
183
+ """(engine, task, min VRAM GB or None, a note) from the model's Hugging Face card."""
184
+ from ..core.model_inspect import ModelInspectError, fetch_hf_api_metadata
185
+ from ..serve import serving_for
186
+
187
+ import os
188
+
189
+ if not model_given or os.environ.get("GPU_NO_MODEL_CARD"):
190
+ # The default model is a chat model; GPU_NO_MODEL_CARD=1 works offline.
191
+ return "vllm", "chat", None, ""
192
+
193
+ try:
194
+ card = fetch_hf_api_metadata(model, token=os.environ.get("HF_TOKEN") or None, timeout=8.0)
195
+ except ModelInspectError as exc:
196
+ return "vllm", None, None, f"could not read the model card ({exc}); assuming a chat model on vLLM"
197
+ engine, task = serving_for(card)
198
+ sized = None
199
+ total = (card.get("safetensors") or {}).get("total")
200
+ if total:
201
+ # bf16 weights plus headroom; the same floor `gpu inspect-model` uses.
202
+ sized = max(8, int(total * 2 / 1e9 * 1.3 + 2.999))
203
+ tag = card.get("pipeline_tag") or card.get("library_name") or "no pipeline_tag"
204
+ if engine == "vllm":
205
+ return engine, task, None, f"{model}: {tag} -> vLLM"
206
+ note = f"{model}: {tag} -> runtime.engine: hf, model.task: {task}"
207
+ library = card.get("library_name")
208
+ if library not in ("transformers", "diffusers", "sentence-transformers"):
209
+ note += (
210
+ f". Its library is {library or 'not declared'}: if the hf server cannot load it, "
211
+ "serve it with your own server (gpu init --engine custom, SERVING.md)"
212
+ )
213
+ return engine, task, sized, note
214
+
215
+
216
+ def scaffold_server(directory: Path) -> None:
217
+ """A starting server for runtime.engine: custom (serve/template/)."""
218
+ from ..serve import TEMPLATE_DIR
219
+
220
+ if (directory / "gpujob.yaml").exists() or (directory / "server.py").exists():
221
+ console.print(Text(f"= {directory} already has a server; left as is", style="dim"))
222
+ return
223
+ directory.mkdir(parents=True, exist_ok=True)
224
+ for name in ("server.py", "gpujob.yaml"):
225
+ shutil.copyfile(TEMPLATE_DIR / name, directory / name)
226
+ console.print(Text(f"+ wrote {directory}/server.py and gpujob.yaml (contract: SERVING.md)", style="green"))
106
227
 
107
228
 
108
229
  def setup_command(
@@ -129,6 +250,10 @@ def setup_command(
129
250
  handle(exc)
130
251
  return
131
252
 
253
+ _print_connection(context, engine, state)
254
+
255
+
256
+ def _print_connection(context, engine, state) -> None:
132
257
  payload = engine.connection(state)
133
258
  watchdog = state.watchdog.to_dict()
134
259
  watchdog.pop("token", None)
@@ -137,15 +262,33 @@ def setup_command(
137
262
  print_json(payload)
138
263
  return
139
264
  if state.endpoint:
265
+ routes = ", ".join(payload.get("routes") or []) or "see GET /v1/models"
140
266
  console.print(
141
267
  f"\n endpoint [bold]{state.endpoint}[/bold]\n"
142
268
  f" openai [bold]{payload['base_url']}[/bold]\n"
143
269
  f" model [bold]{payload['model']}[/bold]\n"
270
+ f" routes {routes}\n"
144
271
  " api key [dim]gpu env[/dim]"
145
272
  )
146
273
  console.print("\nnext: gpu run python your_experiment.py")
147
274
 
148
275
 
276
+ def redeploy_command(ctx: typer.Context) -> None:
277
+ """Restart the model server on the running machine (runtime.engine: hf or custom).
278
+
279
+ `gpu setup` already redeploys when the model, its settings or your server's
280
+ code changed; this restarts it even when nothing did.
281
+ """
282
+ context = get_context(ctx)
283
+ try:
284
+ engine = context.engine()
285
+ state = engine.redeploy()
286
+ except JambuError as exc:
287
+ handle(exc)
288
+ return
289
+ _print_connection(context, engine, state)
290
+
291
+
149
292
  def offers_command(
150
293
  ctx: typer.Context,
151
294
  limit: int = typer.Option(10, "--limit", "-n", help="How many offers to show."),