一、安装教程(面向用户)
方式一:一键安装(推荐)
Step 1:打开安装页面
Step 2:点击绿色的 "Install" 按钮
Step 3:选择安装范围
- All repositories:所有仓库都会自动审计(推荐)
- Only select repositories:只审计你选择的仓库
Step 4:点击 "Install" 确认
✅ 完成!下次你在安装的仓库中提 PR(且代码包含 LLM 量化配置),Bot 会自动发审计评论。
方式二:从仓库 Settings 安装
如果你更习惯从仓库内操作:
- 进入你的仓库页面
- 点击 Settings → 左侧 Integrations → GitHub Apps
- 搜索
ecocompute-energy-auditor - 点击 Install
二、安装后会发生什么?
自动触发条件
Bot 会在以下事件时自动运行:
| 事件 | 触发动作 |
|---|---|
| PR 创建(opened) | 扫描 diff 中的 .py 文件 |
| PR 更新(synchronize) | 重新扫描新的 diff |
| PR 无 .py 文件 | 不做任何操作 |
| .py 文件无量化代码 | 不做任何操作 |
Bot 评论内容
当检测到能源浪费模式时,Bot 会发一条 PR Review Comment:
## ⚡ EcoCompute Energy Audit
Scanned 1 Python file(s) in this PR. 1 critical issue(s) found.
### 🔴 Critical Issues
**Default INT8 (bitsandbytes mixed-precision decomposition)**
> load_in_8bit=True without llm_int8_threshold=0.0 causes
> 17–147% energy waste...
**Fix:** Add llm_int8_threshold=0.0
### 🟡 Warnings
**Sequential single-request processing (BS=1)**
> Processing prompts in a loop wastes up to 95.7% energy.
不会打扰你的情况
- PR 中没有 Python 文件 → 完全静默
- Python 文件中没有量化代码(
BitsAndBytesConfig等) → 完全静默 - 代码配置正确 → 不发评论
三、常见问题
Q1:安装后没看到 Bot 评论?
可能原因:
-
PR 中没有量化相关代码
- Bot 只扫描包含
BitsAndBytesConfig、load_in_8bit、load_in_4bit等关键字的 Python 文件 - 如果 PR 没有这些代码,Bot 不会评论
- Bot 只扫描包含
-
Webhook 服务未运行
- 当前 Bot 后端运行在 Cloudflare Tunnel 上,如果服务未启动,Bot 无法响应
- 可以联系仓库维护者确认服务状态
-
权限不足
- 确认 Bot 安装时授予了 Pull requests: Read & Write 权限
Q2:可以安装到 Organization 仓库吗?
可以。安装时选择 Organization 账号即可。需要 Organization 管理员权限。
Q3:Bot 会修改我的代码吗?
不会。 Bot 只发评论,不会推送 commit 或修改代码。所有修复建议需要你手动采纳。
Q4:安装免费吗?
完全免费。 开源项目,开源数据,开源 Bot。
Q5:怎么卸载?
- 进入 github.com/settings/in…
- 找到
ecocompute-energy-auditor - 点击 Configure → 页面底部 Uninstall
Q6:我的代码安全吗?
- Bot 只读取 PR 的 diff(代码变更部分),不会读取整个仓库
- 不会存储任何代码
- 所有处理在审计完成后立即丢弃
- Bot 完全开源,可以审查源码
Q7:打开安装链接显示 404 或"Private App"?
这是因为 App 还未设置为 Public。请联系 Bot 维护者将 App 改为 Public。
维护者操作步骤:
- 打开 github.com/settings/ap…
- 点击左侧边栏 "Advanced"
- 在 "Danger zone" 点击 "Make public"
四、支持的检测模式
| # | 模式 | 严重级别 | 浪费程度 |
|---|---|---|---|
| 1 | INT8 默认配置(无 threshold) | 🔴 Critical | 17-147% |
| 2 | NF4 用在小模型上(<3B) | 🟡 Warning | 视模型而定 |
| 3 | batch_size=1 顺序处理 | 🟡 Warning | 最高 95.7% |
| 4 | 混合精度配置冲突 | 🔴 Critical | 不确定 |
| 5 | 未指定 device_map | 🟠 Info | 潜在浪费 |
| 6 | 冗余量化参数 | 🟠 Info | 代码质量 |
完整数据和交互式图表:hongping-zh.github.io/ecocompute-…
五、测试 Bot 是否正常工作
安装后,可以创建一个测试 PR 验证:
- 在已安装的仓库中,创建新分支:
git checkout -b test-ecocompute-bot
- 新建一个测试文件
test_energy.py:
from transformers import AutoModelForCausalLM, BitsAndBytesConfig
# This should trigger the bot
bnb_config = BitsAndBytesConfig(
load_in_8bit=True,
)
model = AutoModelForCausalLM.from_pretrained(
"mistralai/Mistral-7B-Instruct-v0.3",
quantization_config=bnb_config,
)
# This should also trigger a warning
prompts = ["Hello", "World", "Test"]
for prompt in prompts:
output = model.generate(prompt)
- 提交并创建 PR:
git add test_energy.py
git commit -m "test: verify ecocompute bot"
git push origin test-ecocompute-bot
-
在 GitHub 上创建 Pull Request,等待 Bot 评论
-
预期结果:
- 🔴 Critical:检测到
load_in_8bit=True无llm_int8_threshold - 🟡 Warning:检测到
for prompt in prompts循环调用
- 🔴 Critical:检测到
-
验证完毕后,可以关闭并删除测试 PR
六、相关链接
| 资源 | 链接 |
|---|---|
| 🤖 Bot 安装页 | github.com/apps/ecocom… |
| 📊 交互式数据面板 | hongping-zh.github.io/ecocompute-… |
| ⭐ GitHub 仓库 | github.com/hongping-zh… |
| 🧠 AI Skill(OpenClaw) | clawhub.ai/hongping-zh… |
| 📧 问题反馈 | hello@ecocompute.ai |
有任何安装问题,欢迎在 GitHub 仓库提 Issue 或联系维护者。