A local-first multi-agent app development platform, built on PenguinHarness
feat(plugins): 插件库收下 gpu-model-serving,在 GPU 机器上自部署模型接口
lmliheng8e1872bde203
diff --git a/README.md b/README.mdindex 61e14533..44d8c5d3 100644--- a/README.md+++ b/README.md@@ -97,7 +97,7 @@ optimise its own Skills:| Category | Plugins || --- | --- || Office Productivity | `data-analysis`, `use-firecrawl`, `use-offerdao`, `browser-automation`, `use-bento-slides`, `use-lieflat-charts`, `use-wps-office`, `use-seedance`, `use-seedream`, `humanizer`, `goal`, `continual-learning`, `csu-mail`, `lesson-video`, `requirements-box` |-| Software Development | `software-development`, `use-claude-code`, `wechat-miniprogram` |+| Software Development | `software-development`, `use-claude-code`, `wechat-miniprogram`, `gpu-model-serving` || AI App Development | `agent-development`, `model-development`, `skill-porting`, `agent-tuning` || Agent Company | `agent-company` |diff --git a/README.zh.md b/README.zh.mdindex 72864f93..d6ea2010 100644--- a/README.zh.md+++ b/README.zh.md@@ -83,7 +83,7 @@ Adelie 运行在你的电脑或服务器上,自动串联 Agent 应用的创建| 分类 | 插件 || ----------- | ------------------------------------------------------------------------------- || 办公效率 | `data-analysis`、`use-firecrawl`、`use-offerdao`、`browser-automation`、`use-bento-slides`、`use-lieflat-charts`、`use-wps-office`、`use-seedance`、`use-seedream`、`humanizer`、`goal`、`continual-learning`、`csu-mail`、`lesson-video`、`requirements-box` |-| 软件开发 | `software-development`、`use-claude-code`、`wechat-miniprogram` |+| 软件开发 | `software-development`、`use-claude-code`、`wechat-miniprogram`、`gpu-model-serving` || AI 应用开发 | `agent-development`、`model-development`、`skill-porting`、`agent-tuning` || Agent 公司 | `agent-company` |diff --git a/changelog/unreleased/2026-11-01-gpu-model-serving-plugin.md b/changelog/unreleased/2026-11-01-gpu-model-serving-plugin.mdnew file mode 100644index 00000000..dc4c0734--- /dev/null+++ b/changelog/unreleased/2026-11-01-gpu-model-serving-plugin.md@@ -0,0 +1,48 @@+# gpu-model-serving joins the library: standing up a model service on a rented GPU box++- **Date:** 2026-11-01+- **Type:** feature+- **Scope:** `plugins`, `core`, `docs`+- **Breaking:** no++[中文](2026-11-01-gpu-model-serving-plugin.zh.md)++`gpu-model-serving` lived on npm only (`@adelie/gpu-model-serving`), so it reached an Agent through the+**import from npm** path and appeared nowhere in the plugin market. It ships with the build now, and+both the library and the market carry it.++The skill it brings turns a GPU box into an OpenAI-compatible endpoint: pick the instance and where+the weights live, take an already-quantized checkpoint, build the pip CUDA toolchain, start+`serve.sh` detached, then verify health, the model list, a tool call, streaming and a repeated+prefix. What the first attempt costs is written down as symptom, cause and fix in+`reference/pitfalls.md`; a complete working `serve.sh` with the memory arithmetic is in+`reference/sglang-serve.md`; the console, port mapping and billing of a rented instance are in+`reference/gpu-cloud-console.md`.++Not preinstalled: it goes onto the Agents that serve models, not onto every new one.++## Details++- `plugins/gpu-model-serving/` (new): `plugin.json` (`category: software-development`,+ `preinstall: false`), `package.json`, `icon.svg`, `LICENSE` (Apache-2.0), `README.md`, and+ `skills/gpu-model-serving/SKILL.md` with four reference documents. The content is the published+ npm version (`@adelie/[email protected]`, the plugin's own version `2026.10.30.1`), with two+ additions for the repository's conventions: `package.json` follows the workspace version+ (`0.6.1`), and `SKILL.md` gains the `## Before you start` section every library skill carries.+- `packages/{core,cli,desktop}/package.json` and `pnpm-lock.yaml`:+ `@adelie/gpu-model-serving: workspace:*` — the loader reads plugin names out of the host package's+ dependencies, and a plugin that is not declared there is invisible to the market.+- The market shelf grows from 27 entries to 28 (the four hand-written sandbox backends plus one per+ shipped plugin package); this one is `@adelie/gpu-model-serving`, version `2026.10.30.1`, category+ `software-development`, all read from the package itself.+- `packages/core/test/plugins.test.ts`: the plugin count goes 23 → 24.+- `plugins/README.md`, `README.md`, `README.zh.md` and `packages/docs/content/skills.{zh,en}.md` each+ gain a row — the repository's guards compare those tables against the library entry by entry.+- The user plugin at `<data root>/plugins/gpu-model-serving/` stops taking effect: the built-in copy+ of a name wins (`pluginRoots`). The two are byte-for-byte identical, so that copy can simply go.++## Compatibility++- No interface changed: one more plugin, one more name in the manifest and in the two tables.+- A deployment that installed this plugin from npm gets the built-in copy instead after an upgrade;+ both carry plugin version `2026.10.30.1`, so nothing reports an available update.diff --git a/changelog/unreleased/2026-11-01-gpu-model-serving-plugin.zh.md b/changelog/unreleased/2026-11-01-gpu-model-serving-plugin.zh.mdnew file mode 100644index 00000000..4d5203fe--- /dev/null+++ b/changelog/unreleased/2026-11-01-gpu-model-serving-plugin.zh.md@@ -0,0 +1,42 @@+# 插件库收下 gpu-model-serving:在租来的 GPU 机器上立起模型服务++- **Date:** 2026-11-01+- **Type:** feature+- **Scope:** `plugins`, `core`, `docs`+- **Breaking:** no++[English](2026-11-01-gpu-model-serving-plugin.md)++`gpu-model-serving` 此前只发布在 npm 上(`@adelie/gpu-model-serving`),要靠**从 npm 导入**那一手才能装进+某个 Agent,插件市场里没有它。现在它随构建发布,插件库与插件市场各有一条。++它带的技能把一台 GPU 机器变成 OpenAI 兼容的模型端点:选实例与权重落盘的位置、直接取已量化好的+checkpoint、搭 pip 装的 CUDA 工具链、以 detached 方式拉起 `serve.sh`,最后按健康检查、模型清单、tool call、+流式与重复前缀五项逐项验证。第一次部署会踩的坑按「现象 → 原因 → 修法」写进 `reference/pitfalls.md`;+可用的完整 `serve.sh` 与显存算术在 `reference/sglang-serve.md`;租用实例的控制台、端口与计费在+`reference/gpu-cloud-console.md`。++不预装:它装到要自己起模型服务的 Agent 上,不在每个新 Agent 的预置名单里。++## 细节++- `plugins/gpu-model-serving/`(新增):`plugin.json`(`category: software-development`、+ `preinstall: false`)、`package.json`、`icon.svg`、`LICENSE`(Apache-2.0)、`README.md`,以及+ `skills/gpu-model-serving/SKILL.md` 与四份参考文档。内容取自 npm 上已发布的那一版+ (`@adelie/[email protected]`,插件自己的版本 `2026.10.30.1`),另按仓库约定补两处:+ `package.json` 的版本跟仓库走(`0.6.1`),`SKILL.md` 补上每个库内技能都有的 `## Before you start`。+- `packages/{core,cli,desktop}/package.json` 与 `pnpm-lock.yaml`:加+ `@adelie/gpu-model-serving: workspace:*` —— 加载器只认宿主包的依赖列表,不登记依赖的插件在市场里就是+ 不可见的。+- 市场货架随之从 27 条变成 28 条(四个沙箱后端是手写的条目,其余每个自带插件包各一条);这一条是+ `@adelie/gpu-model-serving`、版本 `2026.10.30.1`、分类 `software-development`,都读自包本身。+- `packages/core/test/plugins.test.ts`:插件总数 23 → 24。+- `plugins/README.md`、`README.md`、`README.zh.md` 与 `packages/docs/content/skills.{zh,en}.md`:分类表+ 与说明各补一条 —— 仓库里的守卫拿这些表和插件库逐条对。+- 数据根 `plugins/gpu-model-serving/` 里那份用户插件从此不再生效:同名时内置的那份优先+ (`pluginRoots`)。两份内容逐字节相同,所以那份删掉即可。++## 兼容++- 原有接口一个都没动:多了一个插件、插件清单与两张表里多一个名字。+- 从 npm 装过这个插件的部署,升级后接到的是内置的这一份,插件版本同为 `2026.10.30.1`,不会显示成有更新。diff --git a/packages/cli/package.json b/packages/cli/package.jsonindex dcdef57d..e73c4b94 100644--- a/packages/cli/package.json+++ b/packages/cli/package.json@@ -32,6 +32,7 @@"@adelie/csu-mail": "workspace:*","@adelie/data-analysis": "workspace:*","@adelie/goal": "workspace:*",+ "@adelie/gpu-model-serving": "workspace:*","@adelie/humanizer": "workspace:*","@adelie/lesson-video": "workspace:*","@adelie/model-development": "workspace:*",diff --git a/packages/core/package.json b/packages/core/package.jsonindex 0e7f6e9c..206ae006 100644--- a/packages/core/package.json+++ b/packages/core/package.json@@ -65,6 +65,7 @@"@adelie/csu-mail": "workspace:*","@adelie/data-analysis": "workspace:*","@adelie/goal": "workspace:*",+ "@adelie/gpu-model-serving": "workspace:*","@adelie/humanizer": "workspace:*","@adelie/lesson-video": "workspace:*","@adelie/model-development": "workspace:*",diff --git a/packages/core/test/plugins.test.ts b/packages/core/test/plugins.test.tsindex c1120f23..86df0600 100644--- a/packages/core/test/plugins.test.ts+++ b/packages/core/test/plugins.test.ts@@ -65,7 +65,7 @@ describe("loadLibraryPlugins", () => {it("loads every plugin directory sorted by name, each with a date-sequence version and a category", () => {const plugins = loadLibraryPlugins();expect(plugins.map((p) => p.name)).toEqual([...plugins.map((p) => p.name)].sort());- expect(plugins.length).toBe(23);+ expect(plugins.length).toBe(24);for (const plugin of plugins) {expect(plugin.version, plugin.name).toMatch(PLUGIN_VERSION_PATTERN);expect(diff --git a/packages/desktop/package.json b/packages/desktop/package.jsonindex 5e6a9193..73e981a4 100644--- a/packages/desktop/package.json+++ b/packages/desktop/package.json@@ -24,6 +24,7 @@"@adelie/csu-mail": "workspace:*","@adelie/data-analysis": "workspace:*","@adelie/goal": "workspace:*",+ "@adelie/gpu-model-serving": "workspace:*","@adelie/humanizer": "workspace:*","@adelie/lesson-video": "workspace:*","@adelie/model-development": "workspace:*",diff --git a/packages/docs/content/skills.en.md b/packages/docs/content/skills.en.mdindex 119e0675..ad537619 100644--- a/packages/docs/content/skills.en.md+++ b/packages/docs/content/skills.en.md@@ -233,6 +233,7 @@ The built-in plugins, by category (`PLUGIN_CATEGORIES` in `packages/core/src/plu| Software Development | `software-development` | Software development end to end, with two Skills: `software-engineering` (investigate, implement and validate with minimal scope) and `web-design` (the Penguin visual language for generated web UIs) || | `use-claude-code` | Run Claude Code on a remote host over SSH: a persistent expect session, headless `-p` with the stdin fix, a tmux-driven interactive TUI and multi-turn continuity (not preinstalled: install from the library when needed) || | `wechat-miniprogram` | Take a WeChat mini-program from code to published on a headless Linux server: QR login to mp.weixin.qq.com, switching from a public account to the mini-program backend, the AppID and upload key, IP whitelisting, upload with miniprogram-ci, a verified preview QR, the mandatory user-privacy policy, review and release (not preinstalled) |+| | `gpu-model-serving` | Stand up an OpenAI-compatible LLM endpoint on a rented or owned GPU box: pick the instance and where the weights live, take an already-quantized checkpoint, build the pip CUDA toolchain, start `serve.sh` detached, then verify with SGLang's speculative decoding, prefix caching and tool calling on — with the traps that cost the first attempt written down as symptom, cause and fix (not preinstalled: install from the library when needed) || AI App Development | `agent-development` | Agent development on Adelie, with four Skills: `penguin-sdk` (build agent/AI/RAG apps on the SDK, or connect a program to an agent over the Agent API; it asks which way first), `unified-llm-api` (call model APIs through `@prismshadow/agenthub`), `penguin-config` (manage model keys, defaults and Vault secrets) and `penguin-orchestration` (drive agents, Sessions, costs and schedules from a shell) || | `model-development` | Model development on your own hardware, with three Skills: `llamafactory` (fine-tune), `ollama` (run local models) and `vllm` (serve behind an OpenAI-compatible endpoint) || | `skill-porting` | Port Skills from external sources (plugin marketplaces, skills.sh registries, GitHub repos or local folders) into the agent after review and normalization |diff --git a/packages/docs/content/skills.zh.md b/packages/docs/content/skills.zh.mdindex 0d1d68ca..2f433b90 100644--- a/packages/docs/content/skills.zh.md+++ b/packages/docs/content/skills.zh.md@@ -233,6 +233,7 @@ Agent 可以在 Task 中重写自己的 `SKILL.md`。结合 Benchmark 评估和| 软件开发 | `software-development` | 端到端的软件开发,包含两个 Skill:`software-engineering`(在最小范围内调查、实现和验证)和 `web-design`(生成 Web UI 用的 Penguin 视觉语言) || | `use-claude-code` | 通过 SSH 在远程主机上运行 Claude Code:持久 expect 会话、带 stdin 修复的无头 `-p` 模式、tmux 驱动的交互式 TUI,以及多轮连续性(不预装:需要时从插件库安装) || | `wechat-miniprogram` | 在无桌面的 Linux 服务器上把微信小程序从代码做到发布:扫码登录 mp.weixin.qq.com、从公众号后台切到小程序后台、取 AppID 与上传密钥、加 IP 白名单、用 miniprogram-ci 上传、交付校验过的预览码、填写必填的用户隐私保护指引、提交审核与发布(不预装) |+| | `gpu-model-serving` | 在租用或自有的 GPU 机器上立起一个 OpenAI 兼容的模型服务:选实例与权重落盘的位置、直接取已量化好的 checkpoint、搭好 pip 装的 CUDA 工具链、把 `serve.sh` 以 detached 方式拉起,最后按 SGLang 开投机解码、前缀缓存与 tool calling 的状态逐项验证;第一次部署会踩的坑按「现象 → 原因 → 修法」写进参考文档(不预装:需要时从插件库安装) || AI 应用开发 | `agent-development` | Adelie 上的 Agent 开发,包含四个 Skill:`penguin-sdk`(基于 SDK 构建 Agent/AI/RAG 应用,或经 Agent API 把程序接入 Agent;动手前先问用哪种方式)、`unified-llm-api`(通过 `@prismshadow/agenthub` 调用模型 API)、`penguin-config`(管理模型密钥、默认值和 Vault 机密)和 `penguin-orchestration`(在 shell 里驱动 Agent、Session、成本和定时任务) || | `model-development` | 在自己的硬件上做模型开发,包含三个 Skill:`llamafactory`(微调)、`ollama`(运行本地模型)和 `vllm`(在 OpenAI 兼容端点后面提供服务) || | `skill-porting` | 把外部来源(插件市场、skills.sh 注册表、GitHub 仓库或本地文件夹)的 Skill 经审查和规范化后移植到 Agent |diff --git a/plugins/README.md b/plugins/README.mdindex 53998597..9f7d9665 100644--- a/plugins/README.md+++ b/plugins/README.md@@ -9,11 +9,11 @@ Included plugins, by category (`PLUGIN_CATEGORIES` in `packages/core/src/plugins| Category | Plugins || --- | --- || Office Productivity | `data-analysis`, `use-firecrawl`, `use-offerdao`, `browser-automation`, `use-bento-slides`, `use-lieflat-charts`, `use-wps-office`, `use-seedance`, `use-seedream`, `humanizer`, `goal`, `continual-learning`, `csu-mail`, `lesson-video`, `requirements-box` |-| Software Development | `software-development`, `use-claude-code`, `wechat-miniprogram` |+| Software Development | `software-development`, `use-claude-code`, `wechat-miniprogram`, `gpu-model-serving` || AI App Development | `agent-development`, `model-development`, `skill-porting`, `agent-tuning` || Agent Company | `agent-company` |-`humanizer`, `use-claude-code`, `continual-learning`, `agent-company`, `csu-mail`, `wechat-miniprogram`, `lesson-video`, `requirements-box` and `use-lieflat-charts` carry `preinstall: false`, so `default_agent` does not get them at initialization — they are installed from the library on demand (`agent-company` by the organization itself, when it creates the CEO and hires employees, or by hand onto any Agent that should be able to create one). `goal` is the stop hook behind goal mode: its `start.mjs`, a `user_prompt` command marked `"trigger": "host"` so that it runs only when a goal starts, writes the Session's `GOAL.json` and composes round 1; its `stop.mjs` reads the Trace after every Task and injects the next round or ends the goal. `continual-learning` hands a long task's condensed excerpt to a background subagent that folds the findings into the agent's skills.+`humanizer`, `use-claude-code`, `continual-learning`, `agent-company`, `csu-mail`, `wechat-miniprogram`, `lesson-video`, `requirements-box`, `gpu-model-serving` and `use-lieflat-charts` carry `preinstall: false`, so `default_agent` does not get them at initialization — they are installed from the library on demand (`agent-company` by the organization itself, when it creates the CEO and hires employees, or by hand onto any Agent that should be able to create one). `goal` is the stop hook behind goal mode: its `start.mjs`, a `user_prompt` command marked `"trigger": "host"` so that it runs only when a goal starts, writes the Session's `GOAL.json` and composes round 1; its `stop.mjs` reads the Trace after every Task and injects the next round or ends the goal. `continual-learning` hands a long task's condensed excerpt to a background subagent that folds the findings into the agent's skills.`browser-automation` drives the desktop app's built-in browser through `penguin browser`: GenericAgent's scan → act → check loop over simplified HTML, trusted clicks and typing, and sign-ins imported from the system browser, with Amazon orders as the worked example.@@ -21,6 +21,8 @@ Included plugins, by category (`PLUGIN_CATEGORIES` in `packages/core/src/plugins`agent-tuning` powers the self-improvement loop: create the Target Agent, design a Benchmark, evaluate it, optimize it to version N+1 with a snapshot before every round.+`gpu-model-serving` stands up an OpenAI-compatible endpoint on a rented or owned GPU box: pick the instance and where the weights live, take an already-quantized checkpoint, build the pip CUDA toolchain, start `serve.sh` detached, then put the service through the five checks that decide it is done. Its `reference/pitfalls.md` records what the first attempt costs — symptom, cause, fix — and `reference/verify.md` holds the commands and what each answer should look like. Installed onto the Agents that serve models rather than onto everyone.+`agent-company` is the whole toolkit of company mode, entry point included. `company-setup` is that entry point: the skill that creates an organization with the user, asking one question at a time and ending at `penguin org create`, leaving hiring and tickets to the CEO. `company-employee` is the protocol every desk and ticket session follows — including the rule that whatever touches the user's machine, spends money or reaches outside the organization is asked of the board in the all-hands channel first — and `company-ceo`, `company-hr` and `company-finance` are the playbooks of those titles. `company-research` is what a research organization's authors and reviewers add: fix the harness and the metric, run the experiment loop inside a resource envelope the board approved, keep only improvements, and put every claim through a reviewer who tries to break it. `company-mirror` is the seventh: the protocol a company of digital twins runs on instead, where every employee mirrors a real colleague and the company relays between people rather than filing tickets. Because the plugin is `preinstall: false`, `company-setup` is no longer on every Agent by default — an Agent gets it by installing `agent-company` from the library (the Agents page), and the CEO and the employees carry it already.## Documentationdiff --git a/plugins/gpu-model-serving/LICENSE b/plugins/gpu-model-serving/LICENSEnew file mode 100644index 00000000..261eeb9e--- /dev/null+++ b/plugins/gpu-model-serving/LICENSE@@ -0,0 +1,201 @@+ Apache License+ Version 2.0, January 2004+ http://www.apache.org/licenses/++ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION++ 1. Definitions.++ "License" shall mean the terms and conditions for use, reproduction,+ and distribution as defined by Sections 1 through 9 of this document.++ "Licensor" shall mean the copyright owner or entity authorized by+ the copyright owner that is granting the License.++ "Legal Entity" shall mean the union of the acting entity and all+ other entities that control, are controlled by, or are under common+ control with that entity. For the purposes of this definition,+ "control" means (i) the power, direct or indirect, to cause the+ direction or management of such entity, whether by contract or+ otherwise, or (ii) ownership of fifty percent (50%) or more of the+ outstanding shares, or (iii) beneficial ownership of such entity.++ "You" (or "Your") shall mean an individual or Legal Entity+ exercising permissions granted by this License.++ "Source" form shall mean the preferred form for making modifications,+ including but not limited to software source code, documentation+ source, and configuration files.++ "Object" form shall mean any form resulting from mechanical+ transformation or translation of a Source form, including but+ not limited to compiled object code, generated documentation,+ and conversions to other media types.++ "Work" shall mean the work of authorship, whether in Source or+ Object form, made available under the License, as indicated by a+ copyright notice that is included in or attached to the work+ (an example is provided in the Appendix below).++ "Derivative Works" shall mean any work, whether in Source or Object+ form, that is based on (or derived from) the Work and for which the+ editorial revisions, annotations, elaborations, or other modifications+ represent, as a whole, an original work of authorship. For the purposes+ of this License, Derivative Works shall not include works that remain+ separable from, or merely link (or bind by name) to the interfaces of,+ the Work and Derivative Works thereof.++ "Contribution" shall mean any work of authorship, including+ the original version of the Work and any modifications or additions+ to that Work or Derivative Works thereof, that is intentionally+ submitted to Licensor for inclusion in the Work by the copyright owner+ or by an individual or Legal Entity authorized to submit on behalf of+ the copyright owner. For the purposes of this definition, "submitted"+ means any form of electronic, verbal, or written communication sent+ to the Licensor or its representatives, including but not limited to+ communication on electronic mailing lists, source code control systems,+ and issue tracking systems that are managed by, or on behalf of, the+ Licensor for the purpose of discussing and improving the Work, but+ excluding communication that is conspicuously marked or otherwise+ designated in writing by the copyright owner as "Not a Contribution."++ "Contributor" shall mean Licensor and any individual or Legal Entity+ on behalf of whom a Contribution has been received by Licensor and+ subsequently incorporated within the Work.++ 2. Grant of Copyright License. Subject to the terms and conditions of+ this License, each Contributor hereby grants to You a perpetual,+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable+ copyright license to reproduce, prepare Derivative Works of,+ publicly display, publicly perform, sublicense, and distribute the+ Work and such Derivative Works in Source or Object form.++ 3. Grant of Patent License. Subject to the terms and conditions of+ this License, each Contributor hereby grants to You a perpetual,+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable+ (except as stated in this section) patent license to make, have made,+ use, offer to sell, sell, import, and otherwise transfer the Work,+ where such license applies only to those patent claims licensable+ by such Contributor that are necessarily infringed by their+ Contribution(s) alone or by combination of their Contribution(s)+ with the Work to which such Contribution(s) was submitted. If You+ institute patent litigation against any entity (including a+ cross-claim or counterclaim in a lawsuit) alleging that the Work+ or a Contribution incorporated within the Work constitutes direct+ or contributory patent infringement, then any patent licenses+ granted to You under this License for that Work shall terminate+ as of the date such litigation is filed.++ 4. Redistribution. You may reproduce and distribute copies of the+ Work or Derivative Works thereof in any medium, with or without+ modifications, and in Source or Object form, provided that You+ meet the following conditions:++ (a) You must give any other recipients of the Work or+ Derivative Works a copy of this License; and++ (b) You must cause any modified files to carry prominent notices+ stating that You changed the files; and++ (c) You must retain, in the Source form of any Derivative Works+ that You distribute, all copyright, patent, trademark, and+ attribution notices from the Source form of the Work,+ excluding those notices that do not pertain to any part of+ the Derivative Works; and++ (d) If the Work includes a "NOTICE" text file as part of its+ distribution, then any Derivative Works that You distribute must+ include a readable copy of the attribution notices contained+ within such NOTICE file, excluding those notices that do not+ pertain to any part of the Derivative Works, in at least one+ of the following places: within a NOTICE text file distributed+ as part of the Derivative Works; within the Source form or+ documentation, if provided along with the Derivative Works; or,+ within a display generated by the Derivative Works, if and+ wherever such third-party notices normally appear. The contents+ of the NOTICE file are for informational purposes only and+ do not modify the License. You may add Your own attribution+ notices within Derivative Works that You distribute, alongside+ or as an addendum to the NOTICE text from the Work, provided+ that such additional attribution notices cannot be construed+ as modifying the License.++ You may add Your own copyright statement to Your modifications and+ may provide additional or different license terms and conditions+ for use, reproduction, or distribution of Your modifications, or+ for any such Derivative Works as a whole, provided Your use,+ reproduction, and distribution of the Work otherwise complies with+ the conditions stated in this License.++ 5. Submission of Contributions. Unless You explicitly state otherwise,+ any Contribution intentionally submitted for inclusion in the Work+ by You to the Licensor shall be under the terms and conditions of+ this License, without any additional terms or conditions.+ Notwithstanding the above, nothing herein shall supersede or modify+ the terms of any separate license agreement you may have executed+ with Licensor regarding such Contributions.++ 6. Trademarks. This License does not grant permission to use the trade+ names, trademarks, service marks, or product names of the Licensor,+ except as required for reasonable and customary use in describing the+ origin of the Work and reproducing the content of the NOTICE file.++ 7. Disclaimer of Warranty. Unless required by applicable law or+ agreed to in writing, Licensor provides the Work (and each+ Contributor provides its Contributions) on an "AS IS" BASIS,+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or+ implied, including, without limitation, any warranties or conditions+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A+ PARTICULAR PURPOSE. You are solely responsible for determining the+ appropriateness of using or redistributing the Work and assume any+ risks associated with Your exercise of permissions under this License.++ 8. Limitation of Liability. In no event and under no legal theory,+ whether in tort (including negligence), contract, or otherwise,+ unless required by applicable law (such as deliberate and grossly+ negligent acts) or agreed to in writing, shall any Contributor be+ liable to You for damages, including any direct, indirect, special,+ incidental, or consequential damages of any character arising as a+ result of this License or out of the use or inability to use the+ Work (including but not limited to damages for loss of goodwill,+ work stoppage, computer failure or malfunction, or any and all+ other commercial damages or losses), even if such Contributor+ has been advised of the possibility of such damages.++ 9. Accepting Warranty or Additional Liability. While redistributing+ the Work or Derivative Works thereof, You may choose to offer,+ and charge a fee for, acceptance of support, warranty, indemnity,+ or other liability obligations and/or rights consistent with this+ License. However, in accepting such obligations, You may act only+ on Your own behalf and on Your sole responsibility, not on behalf+ of any other Contributor, and only if You agree to indemnify,+ defend, and hold each Contributor harmless for any liability+ incurred by, or claims asserted against, such Contributor by reason+ of your accepting any such warranty or additional liability.++ END OF TERMS AND CONDITIONS++ APPENDIX: How to apply the Apache License to your work.++ To apply the Apache License to your work, attach the following+ boilerplate notice, with the fields enclosed by brackets "[]"+ replaced with your own identifying information. (Don't include+ the brackets!) The text should be enclosed in the appropriate+ comment syntax for the file format. We also recommend that a+ file or class name and description of purpose be included on the+ same "printed page" as the copyright notice for easier+ identification within third-party archives.++ Copyright [yyyy] [name of copyright owner]++ Licensed under the Apache License, Version 2.0 (the "License");+ you may not use this file except in compliance with the License.+ You may obtain a copy of the License at++ http://www.apache.org/licenses/LICENSE-2.0++ Unless required by applicable law or agreed to in writing, software+ distributed under the License is distributed on an "AS IS" BASIS,+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ See the License for the specific language governing permissions and+ limitations under the License.diff --git a/plugins/gpu-model-serving/README.md b/plugins/gpu-model-serving/README.mdnew file mode 100644index 00000000..08ba4c47--- /dev/null+++ b/plugins/gpu-model-serving/README.md@@ -0,0 +1,31 @@+# GPU Model Serving++An Adelie plugin that teaches an agent to **stand up an OpenAI-compatible LLM endpoint on a GPU box** — a rented instance or your own machine — and to survive the parts that normally cost a day.++## What it installs++One skill, `gpu-model-serving`, plus its references:++| File | Contents |+| --- | --- |+| `skills/gpu-model-serving/SKILL.md` | The job in order: instance and disk layout, weights, environment, `serve.sh`, detached start, verification, hand-over — and the toolchain rules that actually bite. |+| `reference/sglang-serve.md` | Environment setup, a complete working `serve.sh` for a 27B 4-bit model + draft model on one 32GB card, flag-by-flag notes, memory arithmetic, startup and restart behaviour. |+| `reference/pitfalls.md` | The failure list: symptom → cause → fix, 14 entries, from NVFP4 checkpoint loading and CCCL header checks to JIT build OOM. |+| `reference/verify.md` | The five checks that decide whether the service is done — health, model list, tool call, stream, prefix cache — plus client wiring and the restart checklist. |+| `reference/gpu-cloud-console.md` | Operating the rented instance: console actions, the single exposed port, the public port that changes per boot, driving the web terminal, and prepaid billing that stops the instance at zero. |++## When it fires++The skill is loaded when a task involves self-hosting a model: deploying or moving an inference service, choosing quantization or serving flags, diagnosing a server that will not start, or wiring an agent framework to a local endpoint. It is written for the single-GPU, 24–48GB case that most agent workloads land on, and scales by arithmetic rather than by hope.++## Install++From the Adelie **Plugins** page, import from npm: `@adelie/gpu-model-serving`. The same string works from a URL — `https://www.npmjs.com/package/@adelie/gpu-model-serving` — or point the importer at the registry tarball. The plugin installs under the name `gpu-model-serving`.++## Provenance++Distilled from a real deployment: **算家云 RTX 5090 ×1 (32GB, sm_120), SGLang 0.5.21, a 27B NVFP4 model with a DFlash2 draft model**, serving tool-calling agent traffic with prefix caching on, verified end to end (health, `/v1/models`, `tool_calls`, streaming SSE, `#cached-token`, speculative accept length). Every entry in `pitfalls.md` is a failure that happened on the way there.++## License++Apache-2.0.diff --git a/plugins/gpu-model-serving/icon.svg b/plugins/gpu-model-serving/icon.svgnew file mode 100644index 00000000..cab3535c--- /dev/null+++ b/plugins/gpu-model-serving/icon.svg@@ -0,0 +1,7 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round">+ <rect x="3" y="4" width="18" height="7" rx="2" />+ <rect x="3" y="13" width="18" height="7" rx="2" />+ <path d="M7 7.5h.01M7 16.5h.01" />+ <path d="M11 7.5h5M11 16.5h3" />+ <path d="M17.5 16.5l1.2-1.6 1.3 3 1.2-1.4" />+</svg>diff --git a/plugins/gpu-model-serving/package.json b/plugins/gpu-model-serving/package.jsonnew file mode 100644index 00000000..c9edf8ef--- /dev/null+++ b/plugins/gpu-model-serving/package.json@@ -0,0 +1,33 @@+{+ "name": "@adelie/gpu-model-serving",+ "version": "0.6.1",+ "description": "Stand up an OpenAI-compatible LLM endpoint on a rented or owned GPU box: pick the instance, fetch and quantize weights, serve with SGLang — speculative decoding, prefix caching and tool calling for agent workloads — then verify it and expose the port.",+ "license": "Apache-2.0",+ "repository": {+ "type": "git",+ "url": "git+https://github.com/lmliheng/Adelie.git",+ "directory": "plugins/gpu-model-serving"+ },+ "keywords": [+ "adelie-plugin",+ "penguin-harness",+ "gpu",+ "llm",+ "sglang",+ "inference",+ "serving",+ "openai-compatible",+ "quantization",+ "speculative-decoding"+ ],+ "files": [+ "plugin.json",+ "icon.svg",+ "README.md",+ "skills",+ "LICENSE"+ ],+ "publishConfig": {+ "access": "public"+ }+}diff --git a/plugins/gpu-model-serving/plugin.json b/plugins/gpu-model-serving/plugin.jsonnew file mode 100644index 00000000..c5c3ba01--- /dev/null+++ b/plugins/gpu-model-serving/plugin.json@@ -0,0 +1,9 @@+{+ "description": "Stand up an OpenAI-compatible LLM endpoint on a rented or owned GPU box: pick the instance, fetch and quantize weights, serve with SGLang — speculative decoding, prefix caching and tool calling for agent workloads — then verify it and expose the port. Carries the CUDA/JIT traps that cost hours the first time (CCCL header checks, MAX_JOBS OOM, flashinfer cubin version skew, NVFP4 checkpoints, mamba state cache).",+ "description_zh": "在租用或自有的 GPU 机器上部署 OpenAI 兼容的模型服务:选实例、拉权重与量化、用 SGLang 开投机解码/前缀缓存/tool calling 服务 agent 负载,再验证并开放端口。附带第一次部署会耗掉数小时的 CUDA/JIT 坑(CCCL 头文件校验、MAX_JOBS 内存打爆、flashinfer cubin 版本错位、NVFP4 checkpoint、mamba 状态缓存)。",+ "short_description": "Self-host an LLM endpoint on a GPU box with SGLang.",+ "short_description_zh": "在 GPU 机器上用 SGLang 自部署模型接口。",+ "version": "2026.10.30.1",+ "category": "software-development",+ "preinstall": false+}diff --git a/plugins/gpu-model-serving/skills/gpu-model-serving/SKILL.md b/plugins/gpu-model-serving/skills/gpu-model-serving/SKILL.mdnew file mode 100644index 00000000..7d165c14--- /dev/null+++ b/plugins/gpu-model-serving/skills/gpu-model-serving/SKILL.md@@ -0,0 +1,60 @@+---+name: gpu-model-serving+description: Stand up an OpenAI-compatible LLM endpoint on a rented or owned GPU box — choose the instance and disk layout, fetch and quantize the weights, serve with SGLang (speculative decoding, prefix caching, tool calling), then verify it and expose the port. Use when a task needs a self-hosted model service, especially one GPU of 24–48GB serving an agent workload.+---++# GPU Model Serving++You are standing up a **self-hosted, OpenAI-compatible LLM endpoint** on a GPU machine — rented by the hour from a cloud, or a box you already have. The deliverable is a URL like `http://<host>:<port>/v1` plus a model name, good enough that an agent framework can point at it and call tools.++Two things make this harder than it looks, and both are scheduling, not modelling: the **build toolchain** (CUDA headers, nvcc, JIT kernel compilation) and the **memory budget** of a single card. Read [`reference/pitfalls.md`](reference/pitfalls.md) before you start typing; every entry there is a real failure that costs 10–60 minutes when it first appears.++## Before you start++If the message only names this skill with no job behind it, ask what the endpoint is for before touching a machine: the agent framework that will call it, and roughly how much traffic and how much context it needs. Those two answers decide the model class, the quantization and the card.++**Renting costs money by the hour, and prepaid balances stop the instance without warning.** Confirm which machine to use — a box the user owns, or a rented instance and which one — and say what an hour costs before starting a download that takes thirty minutes. Do not rent a larger card than the job needs; a 24–48GB single card covers most agent workloads, and the arithmetic in [`reference/sglang-serve.md`](reference/sglang-serve.md) is what says whether it is enough.++Nothing here is destructive to existing data, but a `sglang serve` occupies the whole card and its port. Before taking both, read back which service, if any, is already running there and get agreement to replace it.++## The shape of the job++1. **Pick the machine and where the bytes live.** A single 24–48GB card runs a 27B-class model at 4-bit with room for a draft model and KV cache. Put weights, virtualenv and scripts on a **persistent data disk**, never on the small system disk — a stopped/restarted instance keeps the data disk and loses nothing else, and re-downloading 20–30GB is the slowest thing in the whole job.+2. **Get the weights.** Prefer an already-quantized checkpoint (NVFP4 / AWQ / FP8) over quantizing yourself. Check the file set: an index plus its shards, the tokenizer, and a chat template that advertises `tools`. **Delete or move aside zero-byte leftovers** — a stale empty `*.index.json` or shard makes the loader crash on read.+3. **Build the environment.** One virtualenv with the torch build matching the driver, `sglang[all]`, and a CUDA toolkit from pip. Pin nvcc deliberately (see *Toolchain* below).+4. **Write a `serve.sh`** that exports the environment and ends in `exec sglang serve …`. Launch it detached: `setsid nohup ./serve.sh > serve.log 2>&1 < /dev/null &`. The first start compiles kernels and can take 20–60 minutes; every later start reuses the cache and takes minutes.+5. **Verify before wiring clients** — `/health`, `/v1/models`, a tool call, a streamed response, a repeated prefix. [`reference/verify.md`](reference/verify.md) has the exact commands and what each answer should look like.+6. **Expose the port and hand over** the base URL, the model name, the concurrency limit, and the cost per hour.++## Toolchain — the part that actually bites++- The pip-installed CUDA packages must be on the environment's path: `CUDA_HOME`/`CUDA_PATH` at `<venv>/…/nvidia/cu13` (with its `bin` on `PATH`), `LD_LIBRARY_PATH` and `LIBRARY_PATH` at `<venv>/…/nvidia/cu13/lib`. Without this, `deep_gemm` asserts `cuda_home is not None` and sgl_kernel fails to load `libnvrtc`.+- pip ships `libcudart.so.13` but no `libcudart.so`; linkers ask for the latter. Symlink `libcudart.so`, `libcublas.so`, `libcublasLt.so` in that lib directory.+- **CCCL refuses a nvcc that does not exactly match the CUDA headers** (`#error "CUDA compiler and CUDA toolkit headers are incompatible"`). If you cannot make them match, set `#define CCCL_DISABLE_CTK_COMPATIBILITY_CHECK 1` at the top of every `cuda_toolkit.h` in the venv — there is more than one copy, and the second one only shows up when SGLang's own JIT kernels compile. Find them all first: `grep -rln "headers are incompatible" <venv>/lib/python3.*/site-packages`.+- **Cap the compile parallelism.** `ninja` defaults to one compiler per core plus two; a 27B CUTLASS/FP4 template can take gigabytes each, and a 60GB container gets OOM-killed mid-build (`ninja` exits 137, the log only says `Received sigquit from a child process`). `export MAX_JOBS=3` in `serve.sh` fixes it; the JIT cache keeps whatever already compiled.+- flashinfer's cubin package lags the runtime, and the version check is fatal. `FLASHINFER_DISABLE_VERSION_CHECK=1`; the venv's flashinfer cache (`~/.cache/sglang/.cache/flashinfer`) is worth keeping between restarts.++## Serving choices for an agent workload++- **Speculative decoding** is a large win on a single card: a small draft model plus `--speculative-algorithm` (e.g. `DFLASH`, `EAGLE`) and 4–8 draft tokens. Expect an accept length of ~3–4; watch `accept len` in the decode log line.+- **Prefix caching** matters more than raw throughput when your client sends the same system prompt and tool schemas every turn. A repeat request should show `#cached-token:` close to the prompt length in the log.+- **Tool calling and reasoning** are parser settings, not model settings: `--tool-call-parser` (e.g. `qwen3_coder`), `--reasoning-parser` (e.g. `qwen3`). With a reasoning parser the chain of thought arrives in `reasoning_content` and the answer in `content`; without it your client sees raw think-tags.+- **Concurrency is usually not what you set.** Hybrid (mamba/GDN) models cap `max_running_requests` by the state cache and say so in the log: `max_running_requests is capped to 1 by the mamba state cache (max_mamba_cache_size=8, 5 state slots per request)`. Either raise `--max-mamba-cache-size` and accept a smaller KV pool, or tell the user it serialises.+- Budget the card explicitly: `--mem-fraction-static` sizes the KV pool off what is left; `--kv-cache-dtype fp8_e4m3`, `--context-length` and `--cuda-graph-max-bs-decode` trade context, concurrency and speed against each other. Read the two lines `KV Cache is allocated … #tokens:` and `available_gpu_mem` from the log and report them as the real limit.++The complete working example — every flag, every export, and the memory arithmetic — is in [`reference/sglang-serve.md`](reference/sglang-serve.md).++## Rented GPU clouds++The console, the port mapping and the billing are where a rented instance differs from your own box, and where an agent usually needs help: the container listens on one fixed port, the public port is assigned per boot, the port switch turns itself off when the instance stops, and a depleted balance stops the instance without warning. [`reference/gpu-cloud-console.md`](reference/gpu-cloud-console.md) walks through it with the 算家云 (suanjiayun) console as the concrete case, including how to drive its web terminal when SSH is password-only.++## Reporting++Give the user: the base URL and model name; what you verified (and what you could not); the measured concurrency and context limits with the reason; the hourly cost and the remaining balance; and the exact commands to restart the service after a reboot. If a client needs configuration, hand them the `base_url` / `model` pair and note that the placeholder API key can be any string when the server has no `--api-key`.++## Reference++- [`reference/pitfalls.md`](reference/pitfalls.md) — the failure list: symptom → cause → fix.+- [`reference/sglang-serve.md`](reference/sglang-serve.md) — environment setup, the full `serve.sh`, flag-by-flag notes, memory math, restart behaviour.+- [`reference/verify.md`](reference/verify.md) — verification commands and expected answers, prefix-cache evidence, client wiring.+- [`reference/gpu-cloud-console.md`](reference/gpu-cloud-console.md) — renting and operating the instance: console, ports, web terminal, billing.diff --git a/plugins/gpu-model-serving/skills/gpu-model-serving/reference/gpu-cloud-console.md b/plugins/gpu-model-serving/skills/gpu-model-serving/reference/gpu-cloud-console.mdnew file mode 100644index 00000000..d544b7c8--- /dev/null+++ b/plugins/gpu-model-serving/skills/gpu-model-serving/reference/gpu-cloud-console.md@@ -0,0 +1,42 @@+# Rented GPU clouds — console, ports, terminal, billing++The concrete case is **算家云 (suanjiayun.com)**, but the shape repeats on most Chinese GPU-rental consoles: a web console for the instance, a container you reach through a browser terminal, one exposed port, a persistent data disk, and prepaid billing.++## The instance++- Console: `https://suanjiayun.com/container/#/instanceMine` — the instance list; each row carries 立即关机/开机, WebShell, SSH/SFTP, 文件管理, 开放端口, 更多.+- Storage layout inside the container:+ - `/` — small system disk (~30GB), wiped on a system reset. Never put weights here.+ - `/root/sj-tmp` — the data disk (~50GB), **survives stop/restart and reset**. Keep models, the venv and `serve.sh` here.+- Memory is a cgroup cap of the rented size (`cat /sys/fs/cgroup/memory.max`, e.g. 60GiB) while `free` reports the **host's** memory. Never size `MAX_JOBS` or a cache from `free`.+- SSH: `ssh <account>@<region>.suanjiayun.com -p 2020` — **password-only**; a pubkey is refused, so a scripted shell must go through the web terminal (below) or an interactive login.++## Ports — read this twice++- The container must listen on **8080**; the platform forwards that one port.+- The forwarding is configured per instance under **开放端口 → 对外开放端口** (a switch, saved immediately), and the public address is revealed by **获取地址 / 新页面访问**, e.g. `http://<region>.suanjiayun.com:51197` → your OpenAI base URL is `http://<region>.suanjiayun.com:51197/v1`.+- **The public port is randomly assigned and can change on every boot** (observed: 51197 → 51476 across one stop/start), and **stopping the instance turns the port switch off**. So after every power-on: reopen the switch, read the new address, and update anything that hard-codes it (client configs, model registries, bookmarks).++## The web terminal (WebShell)++The WebShell tab is an xterm in an iframe. To drive it from a script:++1. `document.querySelector('iframe').contentDocument`, then the terminal's hidden input is `.xterm-helper-textarea`.+2. `focus()` it and dispatch a synthetic `ClipboardEvent('paste')` carrying the command as `text/plain` — synthetic `keydown` alone does not insert text.+3. To run it, dispatch synthetic `keydown`/`keyup` for `Enter` (keyCode 13).+4. Read output from `.xterm-rows` `innerText` after setting `.xterm-viewport.scrollTop = scrollHeight` — only the visible ~60 lines exist, so `grep`/`tail` inside the container first.+5. If the terminal freezes, reload the iframe (`iframe.contentWindow.location.reload()`); anything started with `setsid nohup` keeps running.++Long commands can lose characters or fail to submit on the first Enter — send a second bare Enter script rather than retyping.++## Billing++- Hourly, prepaid: an RTX 5090 ×1 instance billed **¥2.92/hour**.+- When the balance reaches zero the platform **stops the instance automatically** ("已关机 / 已暂停计费") and the public address dies with it. A negative balance blocks starting again until it is topped up.+- Consequences for an agent: check the balance before promising an always-on service, tell the user the hourly rate and roughly how long the remaining balance lasts, and remember that a stop also disables the port switch.+- Because a stopped instance loses nothing on the data disk, the restart ritual is short:+ 1. top up and power on;+ 2. **开放端口 → 对外开放端口**: switch on, read the new address;+ 3. in WebShell: `cd /root/sj-tmp; setsid nohup ./serve.sh > serve.log 2>&1 < /dev/null &`;+ 4. wait ~4 minutes (warm JIT cache) and re-verify;+ 5. update every client that held the old address.diff --git a/plugins/gpu-model-serving/skills/gpu-model-serving/reference/pitfalls.md b/plugins/gpu-model-serving/skills/gpu-model-serving/reference/pitfalls.mdnew file mode 100644index 00000000..300d4460--- /dev/null+++ b/plugins/gpu-model-serving/skills/gpu-model-serving/reference/pitfalls.md@@ -0,0 +1,85 @@+# Failure list — symptom → cause → fix++In the order they show up. Search this file by the error string before doing anything clever.++## 1. Checkpoint will not load: `assert param_data.shape == loaded_weight.shape`++**Cause:** the serving build does not know this quantization layout (here: an NVFP4/ModelOpt checkpoint on sglang 0.5.15).+**Fix:** upgrade (`sglang[all]==0.5.21` loaded it unchanged). If no version knows it, re-quantize or pick another checkpoint — do not patch the loader.++## 2. `AssertionError: extra_buffer_lazy unsupported with spec`++**Cause:** a lazy mamba radix-cache strategy under speculative decoding.+**Fix:** `--mamba-radix-cache-strategy extra_buffer`.++## 3. `unrecognized arguments: --mm-feature-transport`++**Cause:** the flag does not exist in the installed version.+**Fix:** upgrade, or drop it. Do not leave an unknown flag in `serve.sh` — the process exits before loading anything.++## 4. `ImportError: libnvrtc.so.13: cannot open shared object file`++**Cause:** the CUDA runtime inside the venv is not on the loader path.+**Fix:** `export LD_LIBRARY_PATH=<venv>/lib/python3.*/site-packages/nvidia/cu13/lib:$LD_LIBRARY_PATH`.++## 5. `deep_gemm: AssertionError: assert cuda_home is not None`++**Cause:** no toolkit for the JIT to call — a container has no system CUDA.+**Fix:** `export CUDA_HOME=$CS/nvidia/cu13`, `CUDA_PATH=$CUDA_HOME`, `PATH=$CUDA_HOME/bin:$PATH` **and** `LIBRARY_PATH=$CUDA_HOME/lib`.++## 6. `flashinfer-cubin 0.6.12 != flashinfer 0.6.18` (fatal version check)++**Cause:** the runtime and its prebuilt cubins are versioned separately, and the matching cubin often is not on PyPI yet.+**Fix:** `FLASHINFER_DISABLE_VERSION_CHECK=1`.++## 7. `#error "CUDA compiler and CUDA toolkit headers are incompatible, please check your include paths"`++**Cause:** CCCL inside the venv requires nvcc and `cuda_runtime.h` to be the *same* minor version (here nvcc 13.2 vs headers 13.0).+**Fix:** prepend `#define CCCL_DISABLE_CTK_COMPATIBILITY_CHECK 1` to every `cuda/std/__cccl/cuda_toolkit.h` in the venv. Verify with a full-line match — the file already contains `#ifndef CCCL_DISABLE_CTK_COMPATIBILITY_CHECK`, so a substring test always says "already fixed":++```bash+f=<venv>/…/nvidia/cu13/include/cccl/cuda/std/__cccl/cuda_toolkit.h+grep -q '^#define CCCL_DISABLE_CTK_COMPATIBILITY_CHECK 1' "$f" || sed -i '1i #define CCCL_DISABLE_CTK_COMPATIBILITY_CHECK 1' "$f"+```++## 8. `ptxas ... Unsupported .version 9.2` / `Unsupported .target sm_120`++**Cause:** you "fixed" #7 by downgrading nvcc to match the headers. The older toolchain cannot emit code for a newer card.+**Fix:** keep nvcc at the newest version and disable the check instead (#7). Never downgrade below the card's architecture support.++## 9. `ld: cannot find -lcudart`++**Cause:** pip ships versioned library names only (`libcudart.so.13`, never `libcudart.so`).+**Fix:** symlink `libcudart.so` (and `libcublas.so`, `libcublasLt.so` if the same error repeats) in the venv's `nvidia/cu13/lib`, and export `LIBRARY_PATH` to that directory.++## 10. Draft/auxiliary model directory crashes the loader++**Cause:** zero-byte leftovers — truncated shards, an empty `model.safetensors.index.json`, empty tokenizer files — a half-finished download that the loader trusts and then fails on.+**Fix:** move every zero-byte file out of the directory; keep only the files the manifest actually names (e.g. `config.json` + a single `model.safetensors` for a draft model). Check with `find <dir> -size 0`.++## 11. `Received sigquit from a child process. It usually means the child failed.`++**Cause:** this line is a symptom, never the reason. The scheduler dies because a compile or a child process died.+**Fix:** read upward: `grep -inE 'Killed|error:|Traceback|ninja:|CalledProcessError' serve.log | tail -20`. Expect #12 or #13.++## 12. The same CCCL error, after you already fixed it — from `sgl_kernel_jit_speculative_sampling_*`++**Cause:** there is more than one vendored CCCL in a venv. The flashinfer copy is patched by #7; SGLang's own JIT (speculative sampling, attention) compiles against `nvidia/cu13/include/cccl/…` and stops on the same check.+**Fix:** apply #7 to *every* copy found by `grep -rln "headers are incompatible" <venv>/lib/python3.*/site-packages`.++## 13. JIT build OOMs: `RuntimeError: Ninja build failed` with several `Killed` and exit status 137++**Cause:** ninja parallelises to `nproc+2` compilers; each CUTLASS/FP4 template can take gigabytes. A rented instance's memory is a cgroup cap (check `/sys/fs/cgroup/memory.max`), even though `free` inside the container prints the *host's* total and looks enormous.+**Fix:** `export MAX_JOBS=3` (flashinfer's `jit/cpp_ext.py` honours it) — or whatever keeps peak usage under the cap. Already-compiled kernels stay cached, so a restart continues from where it died.++## 14. Only one port is reachable from outside++**Cause:** the platform exposes a fixed container port (算家云: **8080**) and forwards it to a random public port; nothing else is reachable.+**Fix:** serve on the exposed port, and do not run anything else on it. A temporary `python3 -m http.server 8080` to read logs is a useful trick **only** while the model server is down — kill it before starting SGLang, and remember the public port can change on the next boot (`gpu-cloud-console.md`).++## Working habits that saved the most time++- **Read the log, not the terminal.** Long output through a web terminal is painful; `grep`/`tail` on the server first, and only then look at the screen. The reason for a crash is always above the last line.+- **Start detached** (`setsid nohup … &`) so a browser reload or a dropped SSH session cannot kill a 20-minute build.+- **Cache is an asset.** `~/.cache/sglang` holds every JIT artifact and autotune result; a warm restart is ~4 minutes instead of ~40.+- **Verify with the API, not the log.** "ready to roll" plus a green `/health` still does not prove tool calls, streaming or prefix caching work — see `verify.md`.diff --git a/plugins/gpu-model-serving/skills/gpu-model-serving/reference/sglang-serve.md b/plugins/gpu-model-serving/skills/gpu-model-serving/reference/sglang-serve.mdnew file mode 100644index 00000000..fc61529b--- /dev/null+++ b/plugins/gpu-model-serving/skills/gpu-model-serving/reference/sglang-serve.md@@ -0,0 +1,124 @@+# Deploying with SGLang — the working setup++Everything here was run on **one RTX 5090 (32GB, sm_120), 15 vCPU, 60GB RAM**, serving a 27B 4-bit model with a draft model for speculative decoding, Python 3.10. Scale the numbers, keep the shape.++## 1. Environment++```bash+apt-get install -y python3-venv || true+cd /root/sj-tmp # the persistent data disk+python3 -m venv venv && . venv/bin/activate+pip install -U pip+pip install "sglang[all]==0.5.21" # 0.5.15 could not load the NVFP4 checkpoint+pip install nvidia-cuda-nvcc==13.2.86 # pin the toolchain; see pitfalls 7 & 8+```++`torch 2.13.0+cu130` came in with `sglang[all]`. The pip CUDA packages land in the venv at `lib/python3.<x>/site-packages/nvidia/cu13/`, which is the toolkit you point everything at.++Three fixes to apply once, after installing:++```bash+CS=venv/lib/python3.10/site-packages+# (a) linker names pip does not ship+ln -sf libcudart.so.13 $CS/nvidia/cu13/lib/libcudart.so+ln -sf libcublas.so.13 $CS/nvidia/cu13/lib/libcublas.so 2>/dev/null || true+ln -sf libcublasLt.so.13 $CS/nvidia/cu13/lib/libcublasLt.so 2>/dev/null || true+# (b) find every CCCL copy that guards the toolkit-header check, then disable the check+grep -rln "headers are incompatible" $CS | tee /tmp/cccl.txt+while read -r f; do+ grep -q '^#define CCCL_DISABLE_CTK_COMPATIBILITY_CHECK 1' "$f" || \+ sed -i '1i #define CCCL_DISABLE_CTK_COMPATIBILITY_CHECK 1' "$f"+done < /tmp/cccl.txt+```++## 2. `serve.sh`++```bash+#!/bin/bash+cd /root/sj-tmp+. venv/bin/activate++export MAX_JOBS=3 # ninja parallelism -> container RAM+export FLASHINFER_DISABLE_VERSION_CHECK=1 # vendored cubin lags the runtime+CS=/root/sj-tmp/venv/lib/python3.10/site-packages+export LD_LIBRARY_PATH=$CS/nvidia/cu13/lib:$LD_LIBRARY_PATH+export LIBRARY_PATH=$CS/nvidia/cu13/lib:$LIBRARY_PATH+export CUDA_HOME=$CS/nvidia/cu13+export CUDA_PATH=$CUDA_HOME+export PATH=$CUDA_HOME/bin:$PATH++M=/root/sj-tmp/models/<target-model>+D=/root/sj-tmp/models/<draft-model>++exec sglang serve \+ --model-path "$M" \+ --served-model-name qwen3.8-27b-uncensored \+ --quantization modelopt_fp4 \+ --trust-remote-code \+ --speculative-algorithm DFLASH \+ --speculative-draft-model-path "$D" \+ --speculative-num-draft-tokens 8 \+ --context-length 122880 \+ --max-mamba-cache-size 8 \+ --mamba-radix-cache-strategy extra_buffer \+ --mamba-ssm-dtype bfloat16 \+ --kv-cache-dtype fp8_e4m3 \+ --attention-backend triton \+ --chunked-prefill-size 1024 \+ --mm-feature-transport cpu \+ --cuda-graph-max-bs-decode 1 \+ --mem-fraction-static 0.86 \+ --max-running-requests 4 \+ --reasoning-parser qwen3 \+ --tool-call-parser qwen3_coder \+ --host 0.0.0.0 --port 8080+```++Start it detached, and keep it that way — the service must survive the terminal that launched it:++```bash+cd /root/sj-tmp+setsid nohup ./serve.sh > serve.log 2>&1 < /dev/null &+```++## 3. Flags, and why each one is there++| Flag | Why |+| --- | --- |+| `--quantization modelopt_fp4` | The checkpoint is NVFP4 (ModelOpt). Wrong value → shape assertion while loading. |+| `--speculative-algorithm DFLASH` + `--speculative-draft-model-path` | A small draft model proposes tokens; the target verifies them. Cheapest latency win on one card. |+| `--speculative-num-draft-tokens 8` | 4–8 is the useful range; watch `accept len` in the decode log. |+| `--mamba-radix-cache-strategy extra_buffer` | Hybrid GDN models need this variant for prefix caching; the `*_lazy` strategies assert under speculative decoding. |+| `--mamba-ssm-dtype bfloat16` | Halves the mamba state size — the thing that caps concurrency. |+| `--kv-cache-dtype fp8_e4m3` | Doubles the tokens the KV pool holds at a small quality cost. |+| `--attention-backend triton` | Avoids a flashinfer attention path on sm_120; the JIT then compiles less. |+| `--chunked-prefill-size 1024` | Bounds the prefill burst so long prompts do not spike memory. |+| `--mm-feature-transport cpu` | Multimodal feature transport off the GPU; only exists from 0.5.21. |+| `--cuda-graph-max-bs-decode 1` | Capture CUDA graphs only up to this batch; more concurrency needs a bigger value and more memory. |+| `--mem-fraction-static 0.86` | Fraction of the card the server may use. Everything else (KV pool) is sized from what remains. |+| `--reasoning-parser qwen3` | Splits `…` into `reasoning_content`. |+| `--tool-call-parser qwen3_coder` | Turns the model's tool-call syntax into OpenAI `tool_calls`. |+| `--host 0.0.0.0 --port 8080` | The port the platform exposes; binding to `127.0.0.1` makes it unreachable from outside. |++## 4. Memory arithmetic (read these four log lines)++```+Load weight end. elapsed=32.91 s, type=… quant=modelopt_fp4, quant_algo=NVFP4, avail mem=11.89 GB+Mamba Cache is allocated. max_mamba_cache_size: 8, conv_state 0.02GB, ssm_state 0.63GB …+KV Cache is allocated. dtype torch.float8_e4m3fn, #tokens: 45259, K size: 0.22 GB, V size: 0.22 GB+max_running_requests is capped to 1 by the mamba state cache …+max_total_num_tokens=45259, chunked_prefill_size=1024, max_running_requests=1, context_len=122880, available_gpu_mem=3.18 GB+```++Derived rules of thumb for a 32GB card serving 27B@4bit + draft:++- mamba (state) cache: `ssm_state` ≈ **79MB per slot**, and each request takes ~5 slots → 8 slots = 1 request, 16 ≈ 2, 24 ≈ 3. Raising concurrency is a direct trade against KV tokens.+- KV pool ≈ 45k tokens here; a 122880 context window means one long conversation does not fit. If you need more effective context, raise `--mem-fraction-static`, drop `--kv-cache-dtype` to the default, or add SGLang's hierarchical cache (HiCache) so host RAM becomes a second-level prefix cache.+- `--cuda-graph-max-bs-decode` should be at least the concurrency you intend, or larger batches run without a captured graph.++## 5. Startup timeline and restart behaviour++- Cold start: weights ~30–40s, then **FlashInfer/`sgl_kernel` JIT compilation — the long pole**. With `MAX_JOBS=3` and a 60GB container a first start ran well past 20 minutes; a rebuild after changing compiler flags is faster but still minutes.+- Artifacts are cached in `~/.cache/sglang` (`jit/` and `flashinfer/`), plus flashinfer's own `~/.cache/sglang/.cache/flashinfer/<version>/…`. **Do not wipe them** — a restart with a warm cache reaches “The server is fired up and ready to roll!” in about 4 minutes.+- If you suspect a hung build, check progress cheaply: `ps -eo comm | grep -cE 'nvcc|cicc'` and `find ~/.cache/sglang -name '*.so' | wc -l`.+- The service writes only to `serve.log`; auditing a failed start is `grep -inE 'Killed|error:|Traceback|ninja:' serve.log | tail -20` — the reason is always *above* the last line.diff --git a/plugins/gpu-model-serving/skills/gpu-model-serving/reference/verify.md b/plugins/gpu-model-serving/skills/gpu-model-serving/reference/verify.mdnew file mode 100644index 00000000..934b299e--- /dev/null+++ b/plugins/gpu-model-serving/skills/gpu-model-serving/reference/verify.md@@ -0,0 +1,100 @@+# Verification++A model server is done when five things answer correctly. Run them in this order; stop at the first failure and read `serve.log`.++Set `BASE=http://<host>:<public-port>`.++## 1. The process is alive and listening++```bash+curl -s -o /dev/null -w '%{http_code}\n' $BASE/health # 200+# from inside the container, if the public address looks dead:+curl -s -o /dev/null -w 'local=%{http_code}\n' http://127.0.0.1:8080/health+```++Local 200 but a dead public address means the **port mapping**, not the server.++## 2. The model is registered++```bash+curl -s $BASE/v1/models+# {"object":"list","data":[{"id":"<served-model-name>",…,"max_model_len":122880}]}+```++## 3. Tool calling works++```bash+cat > req.json <<'JSON'+{"model":"<served-model-name>",+ "messages":[{"role":"system","content":"Use the provided tools when needed."},+ {"role":"user","content":"北京今天天气怎么样?请调用工具查询。"}],+ "tools":[{"type":"function","function":{"name":"get_weather","description":"查询指定城市的当前天气",+ "parameters":{"type":"object","properties":{"city":{"type":"string"}},"required":["city"]}}}],+ "tool_choice":"auto","temperature":0,"max_tokens":256}+JSON+curl -s -H 'Content-Type: application/json' -d @req.json $BASE/v1/chat/completions+```++Expect `"finish_reason":"tool_calls"` and a parsed call:++```json+"tool_calls":[{"id":"call_…","type":"function",+ "function":{"name":"get_weather","arguments":"{\"city\": \"北京\"}"}}]+```++With a reasoning parser the chain of thought sits in `reasoning_content` and the visible answer in `content`; a model that only emits think-tags means `--reasoning-parser` is missing or wrong for this family.++## 4. Streaming works++```bash+curl -sN -H 'Content-Type: application/json' -d @req.json $BASE/v1/chat/completions | head -c 800+```++Expect `data: {...}` chunks whose deltas accumulate, then a final chunk with `usage`, then `data: [DONE]`.++## 5. Prefix caching works++Send the same request a second time (any long, identical prefix) and read the server log — no client change is needed:++```bash+grep -oE '#cached-token: [0-9]+' serve.log | tail -4+```++A cached-token count close to the prompt length (`#cached-token: 320` out of 347) proves the radix cache is hitting. Zero on a genuine repeat means the strategy or the prompt identity is wrong.++## 6. Know your real limits++```bash+grep -nE 'capped|KV Cache is allocated|max_total_num_tokens' serve.log | tail -6+```++Report these to the user verbatim: the effective `max_running_requests`, the KV token pool, and the reason for any cap. A single-GPU hybrid model commonly caps concurrency at 1 because of the state cache — say so instead of letting requests pile up silently.++## Wiring a client++Any OpenAI-compatible client works:++```python+from openai import OpenAI+client = OpenAI(base_url=f"{BASE}/v1", api_key="sk-local") # placeholder: the server has no --api-key+client.chat.completions.create(model="<served-model-name>",+ messages=[{"role": "user", "content": "hi"}])+```++If the runtime is Adelie itself, register the endpoint so it appears in the model picker — the placeholder key is fine:++```bash+penguin config model add --root <data root> \+ --provider custom --model-id <served-model-name> \+ --base-url $BASE/v1 --client-type openai \+ --context-window <context-length> --no-vision --api-key sk-local+```++Re-run the same command with a new `--base-url` to move the entry when the public port changes.++## Restart checklist++1. Power the instance on; reopen the exposed port and read the (possibly new) public address.+2. `cd /root/sj-tmp; setsid nohup ./serve.sh > serve.log 2>&1 < /dev/null &`+3. Wait until the log says `The server is fired up and ready to roll!` (minutes with a warm JIT cache).+4. Repeat steps 1–5 above, then update every client with the new address.diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 0f3cfea6..026d2941 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -90,6 +90,9 @@ importers:'@adelie/goal':specifier: workspace:*version: link:../../plugins/goal+ '@adelie/gpu-model-serving':+ specifier: workspace:*+ version: link:../../plugins/gpu-model-serving'@adelie/humanizer':specifier: workspace:*version: link:../../plugins/humanizer@@ -199,6 +202,9 @@ importers:'@adelie/goal':specifier: workspace:*version: link:../../plugins/goal+ '@adelie/gpu-model-serving':+ specifier: workspace:*+ version: link:../../plugins/gpu-model-serving'@adelie/humanizer':specifier: workspace:*version: link:../../plugins/humanizer@@ -311,6 +317,9 @@ importers:'@adelie/goal':specifier: workspace:*version: link:../../plugins/goal+ '@adelie/gpu-model-serving':+ specifier: workspace:*+ version: link:../../plugins/gpu-model-serving'@adelie/humanizer':specifier: workspace:*version: link:../../plugins/humanizer@@ -761,6 +770,8 @@ importers:plugins/goal: {}+ plugins/gpu-model-serving: {}+plugins/humanizer: {}plugins/lesson-video: {}@@ -894,6 +905,9 @@ packages:'@adelie/goal@file:plugins/goal':resolution: {directory: plugins/goal, type: directory}+ '@adelie/gpu-model-serving@file:plugins/gpu-model-serving':+ resolution: {directory: plugins/gpu-model-serving, type: directory}+'@adelie/hmr@file:packages/hmr':resolution: {directory: packages/hmr, type: directory}@@ -2109,6 +2123,7 @@ packages:'@smithy/[email protected]':resolution: {integrity: sha512-KoUi4M1f3BG6kzN1FnCwL7oyFptTbyBJKjR6yhSib+JHRdUmM1o+VwsFtJ66NZCkCzVfJMWRHJNo0R0jznp0Pg==}engines: {node: '>=18.0.0'}+ deprecated: Deprecated due to a bug in custom logger data redaction. See https://github.com/aws/aws-sdk-js-v3/issues/8393.'@smithy/[email protected]':resolution: {integrity: sha512-ZlfJ/4Fa3jYb+3eaohPfG9utX9HmdhFNcFtpoGAhUhdynAOmGXtmigbi7eEiONKM+ykHw8RwKuDEb85Lx7t7fA==}@@ -4965,6 +4980,7 @@ snapshots:'@adelie/csu-mail': file:plugins/csu-mail'@adelie/data-analysis': file:plugins/data-analysis'@adelie/goal': file:plugins/goal+ '@adelie/gpu-model-serving': file:plugins/gpu-model-serving'@adelie/humanizer': file:plugins/humanizer'@adelie/lesson-video': file:plugins/lesson-video'@adelie/model-development': file:plugins/model-development@@ -5008,6 +5024,7 @@ snapshots:'@adelie/csu-mail': file:plugins/csu-mail'@adelie/data-analysis': file:plugins/data-analysis'@adelie/goal': file:plugins/goal+ '@adelie/gpu-model-serving': file:plugins/gpu-model-serving'@adelie/humanizer': file:plugins/humanizer'@adelie/lesson-video': file:plugins/lesson-video'@adelie/model-development': file:plugins/model-development@@ -5046,6 +5063,7 @@ snapshots:'@adelie/csu-mail': file:plugins/csu-mail'@adelie/data-analysis': file:plugins/data-analysis'@adelie/goal': file:plugins/goal+ '@adelie/gpu-model-serving': file:plugins/gpu-model-serving'@adelie/humanizer': file:plugins/humanizer'@adelie/lesson-video': file:plugins/lesson-video'@adelie/model-development': file:plugins/model-development@@ -5080,6 +5098,8 @@ snapshots:'@adelie/goal@file:plugins/goal': {}+ '@adelie/gpu-model-serving@file:plugins/gpu-model-serving': {}+'@adelie/hmr@file:packages/hmr([email protected])([email protected])':dependencies:'@adelie/core': file:packages/core([email protected])([email protected])