文档
命令行、Agent 技能
与 MCP
一条命令提交,一条命令取回补丁。中间每一步——上传哪些文件、什么时候扣费——都会先展示给你,征得同意后再执行。
pipx install autooptm安装到独立环境autooptm login在浏览器中授权这台机器autooptm run . --entrypoint train.py先免费估算,扣费前征得你同意安装
autooptm 是一个命令行工具,推荐用 pipx 或 uv tool 安装到独立环境。macOS 的 Homebrew Python 和较新的 Debian / Ubuntu 会拒绝直接用 pip install 往系统环境装包,这两种方式则不受影响。
$ pipx install autooptm # or $ uv tool install autooptm $ autooptm --help
MCP 服务器需要一个额外依赖,安装时带上 extra 即可:pipx install 'autooptm[mcp]'。
登录
autooptm login 会打开浏览器,在网页上确认授权这台机器即可。终端随即获得一个 30 天有效的令牌,每次使用自动续期,保存在 ~/.config/autooptm/token。
$ autooptm login signed in as you@example.com; token saved to ~/.config/autooptm/token (valid 30 days, and it slides on use) # a server with no browser: print the approval URL, open it anywhere $ autooptm login --no-browser # or the email code (QQ / 163 mail work): one command sends it, the next verifies $ autooptm login --email you@example.com $ autooptm login --email you@example.com --code 482913 $ autooptm balance 12.4 credits (≈ $12.4) $ autooptm logout
CI 与脚本:API key
无法使用浏览器的场景,请用 API key。key 只显示一次;默认只有 read,submit 两项权限,unlock 会产生费用,需要显式授予。把它设到 AUTOOPTM_TOKEN 环境变量中,命令行会自动读取。
$ autooptm keys create "CI pipeline" --scopes read,submit --expires-in-days 90 $ autooptm keys list $ autooptm keys revoke <keyId> $ export AUTOOPTM_TOKEN=ao_…
一次完整的优化
run 接受公开仓库地址或本地目录,走完整个流程:打包、免费估算、询问是否继续、等待结果、给出补丁报价。中途断线也没关系,任务会在我们这边继续运行,用 wait 重新接上即可。
沿用你平时运行的命令:入口脚本用 --entrypoint,其余参数用 --args。显卡选 auto 会在 RTX 4090 上运行,显存不够再选 RTX5090;程序不用显卡就选 CPU,不收机器费。
本地目录会先在你的机器上生成清单:权重、数据、大文件以及文件数特别多的目录会逐项询问你,确认后才上传。详见上传了什么。
几秒钟的静态扫描,不执行你的代码,也不扣费。输出预期加速比及区间,然后询问是否继续。
回答 y 扣 2 credits 分析押金,解锁补丁时全额抵扣;没有加速、或失败在我们这边时退回。回答 n 或不作答,任务就停在估算阶段,始终免费。
运行结束后输出端到端实测加速比和补丁报价。unlock 会再确认一次才扣费,补丁保存为 autooptm.patch,执行 git apply 即可。低于 1.10× 不卖补丁,押金退回。
$ autooptm run . --entrypoint train.py --workload training --gpu auto skipped: .git (1), __pycache__ (14) y = into the code archive · n = leave out · d = upload as the private dataset instead (sandbox only, 7 days, up to 1 GB, one per run) checkpoints/ weight files: 2, 1.9 GB (.pt×2) include? [y/N/d] n data/ crowded directory: 1204 files, 310 MB (0 of 1204 files are code) include? [y/N/d] d data/ goes up as the dataset, unpacked at ./data packing 87 files, 1.4 MB before compression: src/ 62 files 1.1 MB configs/ 14 files 38 KB train.py 1 files 12 KB dataset: /home/you/repo/data -> ./data in the sandbox upload? [Y/n] y job 7f3c2a1b queued estimate: expected 1.6x · range 1.2x - 2.3x · lossless 1.4x next: autooptm decide 7f3c2a1b continue (takes the deposit, credited against the unlock) autooptm decide 7f3c2a1b stop (free) continue? takes the analysis deposit (2 credits), credited against the unlock. [y/N] y … 1.61x (937.8s -> 582.5s) patch: locked. unlock for 4.6 credits (autooptm unlock 7f3c2a1b) report: https://api.autooptm.com/api/my/reports/… $ autooptm unlock 7f3c2a1b Unlock spends 4.6 credits. Continue? [y/N] y $ git apply autooptm.patch
autooptm wait <jobId> 继续等待,autooptm status <jobId> 查看状态,autooptm estimate <jobId> 重新查看估算。
上传了什么
提交本地目录时,打包在你的机器上完成,打包前会先扫描一遍。哪些内容进入代码包,由你决定:
| 类别 | 处理方式 |
|---|---|
| .git、缓存、虚拟环境、编辑器目录 | 直接跳过,只打印一行 skipped:。包括 __pycache__、.venv、node_modules、wandb、.idea、.DS_Store 等。 |
| 权重文件asked | .pt .pth .ckpt .safetensors .onnx .npz .bin .gguf 等,按目录列出,默认不传。 |
| 数据文件asked | 图片、音视频、表格、.npy / .h5 / .pkl、压缩包等,按目录列出,默认不传。 |
| 单个超过 8 MB 的文件asked | 逐个列出,默认不传。 |
| 超过 200 个文件的目录asked | 列出文件数、大小和其中代码所占比例。一半以上是代码则默认上传(如 src/),否则默认不传(如 outputs/)。 |
每组三选一:y 放进代码包,n 不上传,d 作为私有数据集上传。数据集走独立通道:只进沙箱,7 天后删除,上限 1 GB,在沙箱中解压到相同的相对路径,你的命令无需改动;每个任务只能带一个数据集。全部回答完后打印打包清单,确认后才上传。代码包压缩后上限 64 MB。
# only show the list; nothing leaves the machine $ autooptm run . --entrypoint train.py --dry-run # answer from the command line instead of the prompts $ autooptm run . --entrypoint train.py --include checkpoints --exclude outputs --yes # send a directory as the dataset, unpacked at ./data in the sandbox $ autooptm run . --entrypoint train.py --dataset ./data --dataset-path data --yes
--yes 时,run 只打印清单、不上传(退出码 1)。建议先用 --dry-run 预览,再带上 --include / --exclude 和 --yes 提交。
命令参考
| 命令 | 作用 | 选项 |
|---|---|---|
| run SOURCE | 提交公开仓库地址或本地目录,并等待运行结束。默认先免费估算,再询问是否继续;--no-wait 提交后立即返回。 | --entrypoint main.py--workload training|inference--gpu auto|RTX4090|RTX5090|CPU--args "…"--setup FILE--git-ref REF--model opus|glm--lang zh|en--dataset DIR_OR_ARCHIVE--dataset-path ./data--include PATH--exclude PATH--dry-run--no-estimate--no-wait--yes |
| wait JOB | 继续等待某个任务,用于断线后或使用 --no-wait 之后。停在估算阶段的任务会再次询问是否继续。 | --yes--timeout SECONDS |
| estimate JOB | 重新查看免费估算:预期值、区间、lossless 档位以及审查备注。 | |
| decide JOB continue|stop | 对估算作出答复。continue 扣 2 credits 押金,stop 免费;7 天未答复视为 stop。 | --yes |
| status JOB | 查看任务当前的状态、加速比和报价。 | |
| unlock JOB | 按报价扣费并下载补丁。扣费前会先确认;实付不超过报价。 | --yes--out autooptm.patch |
| cancel JOB | 停止排队中或运行中的任务。已取消的运行不扣 credits。 | |
| balance | 查看可用 credits。 | |
| datasets | 列出本账号上传过且尚未过期的数据集,可以直接通过 key 复用。 | |
| login | 登录:打开浏览器授权这台机器;加 --email 则改用邮箱验证码。 | --no-browser--email ADDR--code NNNNNN--role … |
| logout | 删除本机保存的令牌。 | |
| keys create|list|revoke | 管理供 CI 和脚本使用的 API key。 | create NAME --scopes read,submit,unlock --expires-in-days N |
| install-skill | 将 Claude Code 技能安装到本机的 skills 目录,详见下文。 | --dest DIR |
Claude Code 技能
技能随命令行一起发布,无需另外下载。安装并登录后,一条命令即可把它装进 Claude Code 的 skills 目录:
$ pipx install autooptm $ autooptm login $ autooptm install-skill installed autooptm-optimize -> ~/.claude/skills/autooptm-optimize/SKILL.md # somewhere else, e.g. a project-level skills directory $ autooptm install-skill --dest ./.claude/skills
然后在 Claude Code 中打开你的仓库,直接说「用 AutoOptm 优化这个仓库」,或调用 /autooptm-optimize。技能会引导 Claude Code 完成整个流程:
找到端到端运行训练或推理的那条命令;不确定时会先问你。
--dry-run 给你看清单agent 没有交互终端,所以会先列出哪些内容会上传、哪些默认不传,经你同意后才带上 --include 和 --yes 提交。
只有你明确同意,才会执行 decide continue;否则任务停在免费估算阶段。
汇报加速比和报价,经你同意后再 unlock,然后 git apply。
pipx install autooptm、autooptm login、autooptm install-skill;令牌不会随技能迁移。
MCP
Claude Code、Cursor 以及任何 MCP 客户端都可以直接调用。安装带 mcp extra 的包,再把 autooptm-mcp 加入客户端配置:
$ pipx install 'autooptm[mcp]' $ autooptm login
{
"mcpServers": {
"autooptm": { "command": "autooptm-mcp" }
}
}工具:optimize_submit、optimize_estimate、optimize_decide、optimize_status、optimize_wait、optimize_cancel、unlock_patch、download_patch、account_balance。规则与命令行一致:optimize_submit 停在免费估算,optimize_decide 才扣押金,unlock_patch 必须经用户明确确认。提交本地目录时,返回值中的 upload 会列出已打包和未上传的分组,再次提交时可用 include 补充进去。
环境变量与脚本
| AUTOOPTM_TOKEN | API key 或登录令牌;设置后不再读取本机保存的令牌文件。 |
| AUTOOPTM_API | 接口地址,默认 https://api.autooptm.com。 |
| XDG_CONFIG_HOME | 令牌文件所在目录的上一级,默认为 ~/.config。 |
非交互环境下的行为
凡是会产生费用或上传文件的步骤,都需要一次明确同意,脚本中用 --yes 表示。不带 --yes 时:本地目录的 run 只打印清单,退出码 1,不上传;估算出来后 run 打印 parked at the estimate,退出码 0,任务免费停在那里,之后用 decide 答复;unlock 直接拒绝。限流、网络抖动等临时性错误会自动重试;提交这类不能重复执行的请求,只有在服务器明确返回「稍后再试」时才会重发。