Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 19 additions & 13 deletions SOURCE-SHA256.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
".gitignore": "1364e59c28568273da17a19c4b4fb78dd86aaed90f6b7e71d7823585bba84707",
".openai/hosting.json": "8e1049aefe1f5e5853c8bd13a3e4e1b01f9251a452bfd8b5e384a260f4a551b7",
"README.md": "15494d7b07d88e33983203077beed7b93d7105961a49cd743600a07eea28247d",
"docs/OPERATIONS.md": "0acc05e7644c18a55d764bf2559717627d953937ca60a0298cf7b1e9b7e60966",
"docs/OPERATIONS.md": "7e4e56934840395193760953f78084f068a566ef669d310e50f266183a424430",
"docs/SERVER-MONITOR.md": "f23b3412fb002fad05ebb09a435dfc430e5c33a88653c3c9d16fa2a06bc213ac",
"docs/typography-review.md": "57fc36226bcf1b0cff78acc9ce25c63a57e89ca739161f3c2e959f6ec35b4aa7",
"docs/widget-update-1.1.4.md": "e086a0cb5d7123b32aa472a9afa7c42c0c2c645224ccd67decacd93b535c3297",
Expand All @@ -17,16 +17,18 @@
"examples/acceptance.task.json": "fa53ef9a81b0a894bdf6d33ddd4326b6bab99a87b93833cf313f5b736eca4abd",
"gpuqueue/__init__.py": "852c85083667b737e5b2f4896532f7c94fa07abc4531c0b32fd37d990242fb17",
"gpuqueue/chat.py": "d469f71a3f1dab8d00253dc437d94951bbf1a8cb7510006098246f84d5a33289",
"gpuqueue/cli.py": "ac49e6093d1d696d63a4121f652d59f1adbc51f2124bda7df26edcd5b7a36e26",
"gpuqueue/cli.py": "d4b6a398c3d4862a3391638e0fd05f7bdb75fbca420fa0ff9f1b8e3d93a27037",
"gpuqueue/control.py": "29736c4703155dde45863dae6dd242eaa4d7188a17a933066178dc3ddcf134ba",
"gpuqueue/core.py": "09dbd27c46c4be54bfc8a765437ed7804797f748add1c55ae71726c2f4b190ec",
"gpuqueue/core.py": "c7005addc475b9bfb5afa3775e5079c22a77daba65f769fe0c40f2920f6e871c",
"gpuqueue/feishu.py": "87712f82f27dd58650d9d1d47e1a2ff246d8559e02d57a89692bcc81da8456b7",
"gpuqueue/host_monitor.py": "ec685be9bf9e498eefe7f9b8719b06a581853df01dd006ade239d70ef6196e4b",
"gpuqueue/platform.py": "3d265d5f9ba67c79a6219908044f4f912a50cbc92f7391063d377b6dcb1e13d1",
"gpuqueue/runner.py": "7f20c357c0df5e3c07ececa3d0a95648b5ae3c74bfd1c4ffba85e03396bf4756",
"gpuqueue/platform.py": "1d104b54adfccf8e408de1e353fe13b2dd7c9180863a24aa85d0d8db541ab5cd",
"gpuqueue/resources.py": "01b70f2d1d9f2c7814de07f8870c71b06ff9282347b8723f9d2b5c063893a8d2",
"gpuqueue/runner.py": "29d31e6ac7dca96f6ce4a846db8ee75b152dc01fdf468f145e49243ae38bfd64",
"gpuqueue/serverbox.py": "00de2db3e01a89525f69dd0c55d75d92d340c0aa552817cd255d58062f8c9c55",
"gpuqueue/service.py": "ca30ca74711882afe886062523cfc461b014ce6721692f8eade63f514534baab",
"gpuqueue/stop_control.py": "10d2241a2882dbb97605f4fcb364c6f6fbe01451b8d90137d3aed1ff859433f7",
"gpuqueue/service.py": "91be750b86dc5ce1ae7e1082ac54b458d92b2e3b3d5adf767e74457d77c37de8",
"gpuqueue/status.py": "092f8394f1522fc1ea41f4c8c63f486cafe1b5617a860d3228bdf739097a1c14",
"gpuqueue/stop_control.py": "2b28b2555a9a87927763b3793daa0f84ba9e75de7212d9473ad6efaac829e8a8",
"gpuqueue/web.py": "192aca0a92010657ab80027c8b25735b43d822b175efeae5a30163337972e8ad",
"launchers/macos/Open-GPU-Queue.command": "b3a725d7435fe75c307f63bcb9a5c04ac578893c2ec67ab2f47f5e15f3611c6d",
"launchers/macos/widget/Autostart.command": "227099796f359c9b022f6c45477e1325c1c91e8d01614f23ab40cdb7bd0c3c4e",
Expand Down Expand Up @@ -61,21 +63,25 @@
"serverbox/test/unit/app/queue_protocol_test.dart": "f80ddb23f95e2f70b6068728cf4ee1151a8e0c86dc28ae60aa21708b0fb26ee5",
"skills/inspire-queue/SKILL.md": "df9180e812f53d0ccddf655380d263f8ec4f2b298956ce94f9984a365338eecc",
"tests/browser_check.py": "f5885e5acf430749364699e81fdecf257906f898c971d39f837ae70811b14cd4",
"tests/browser_monitor_check.py": "fd9ff1273517bfeb988d75b96cfb00e288bbe692073e6e3101915526e6e527a1",
"tests/browser_monitor_check.py": "769f2324ffe7662e99a91bb5c475f0b1af494c920040a2cb76158e9559804bed",
"tests/browser_stop_check.py": "894efafabefb72dd36a725d1f2f68237b39951a87926350fe3e1331f5d6cd507",
"tests/browser_typography_check.py": "74987cb8ec7ec26a9fb7f7c615b58ba03acb32f081d06feb406870482f6c6dad",
"tests/cloud.test.js": "da8dddec4638a65bb909d192f01fea7e9ff75a3b438ae08e0b76e67396defac1",
"tests/helpers.mjs": "0fe2b5d4bc3576b1a2f0e3ca443748b5d5a2652ab3e715a5305af53279cd3ca0",
"tests/local_python_server.py": "90b43685a6a7a8af13904c40b19d1ee8d6273098d6d4578084fbc2cc6e4f29d5",
"tests/local_server.mjs": "f7b943a06fc8881d9e083a05ff556948d8f8273b6fff59bb681e6ad5633520fa",
"tests/local_server.mjs": "bc89ae93ccc0a1e325cbd408c9db5d76574ee76cfd659ef08eff80f33cdca901",
"tests/modes.test.cjs": "bf206c7368254c5fa45682e0de482a59517cae7b02bfca9bf62d20aaf088f354",
"tests/monitor.test.js": "54fa84e136fe8d9303ec0bfa873d53a402a1cdd34adfd3eb475f32678efc5e0d",
"tests/monitor.test.js": "bacfb39a197d39f58385b51cbc36f1610f3994c11b207a6c520f147a6c4d6f43",
"tests/test_chat_start.py": "4cfd7bdbe6e70ccde24e6c8a06c6af3a476365a77075f234acbc909e4f8335c2",
"tests/test_gpuqueue.py": "c657e41630e8f25e4b4c65b84eb9621f9cfc60389d7ed1290218c7437a669972",
"tests/test_gpu_handoff.py": "403575e39813323a971c892c37bcfa0a423772685e44840a2332d063c08d7d73",
"tests/test_gpuqueue.py": "04ef9661e5477097c705eb10c795ec5b79bba97e1742c3dc72b57da8bc7779c0",
"tests/test_host_monitor.py": "951bc42312a4cf24437a114cdf2881e6d6e119992d8a32d0fc4a4f73aa13c494",
"tests/test_launcher.py": "c336ce79267510501294ee1f73600b5b57ab8143469d75a8cf5d827e650e941d",
"tests/test_local.py": "2a4ceb468989430b21024dd7adf691c2ef2075dbd48fd31ee45819fc5f51b5d1",
"tests/test_native_transport.py": "1e61cbfe99b4da1ecd1e992caf9f76df6d9fbbd0d2001c2fd59c08520a4e020f",
"tests/test_request_diagnostics.py": "dc8ea0c54d6d281cf0448c8aa87bf0cc9a39b5ed5f7feb14d6f79e2d0f665bcc",
"tests/test_runner_telemetry.py": "605c9ad101e4130942bb67c35b60890ef92a59ad7413db8242c64460bc281e27",
"tests/test_scheduler_resilience.py": "25127cc69af4511b87527f7b432544d5527680f452c32820a65f4fb8aec8a936",
"tests/test_serverbox.py": "0716194806731cf4a11f33fb6fa8a163c6558404f336f8855c14188e98bb6cb3",
"tests/test_snapshot_control_boundaries.py": "95d90372efe1d6280b2710cd12593c81a4f3602d625f064de5c3ae4e90e24345",
"tests/test_stop.py": "c452e9f5b04d4272471172b7cfbe578763bcd2e2e0678c2eb36c72db61156bdc",
Expand All @@ -84,10 +90,10 @@
"tests/widget-update.test.cjs": "846ebaf0550e0899e5723f939fe9fb2965ac91030ab761f19be50a576bbe02a5",
"tests/widget.test.cjs": "21dde14aa712b8f3c814354af8a1323e6c7f92af866169e78dd9b4095f501faf",
"updates/gpu-queue-widget.json": "4ff3b46935ab67689c962cc22ceb3155960ff6de7572ff3435f15c481580a475",
"web/app.js": "0684a58c6d0a8705fb80cd922190755d4b7bc50f11c6a2ccab28be55b602476b",
"web/app.js": "383f594aafa685f51a955e6bf274f97f33b6d623d6e9428b1b347271aa92f00f",
"web/index.html": "d975543a8ecdab73d13fa0c3b372e5c8c96839fb7065caac394270fd3904faca",
"web/model.js": "ef176821a91445768078eb0e0bfd946a53b5a03feccd1d879e05e2419e4ebc9b",
"web/monitor.js": "41d58e769c1fa728600ac73a645b1d4ce1ac4ca2d49127e4e6e1bfa073bf6066",
"web/monitor.js": "865a19aac2c810bc02b3fdafbbb919571ec6a35170f591761cc54e5f9a03333f",
"web/style.css": "77a0f4993c49cd263e57bdb8fe420b18ee51eb1047b4009944aab528242b53c1",
"worker/api.js": "65ba1c1959a75f29eb03d4eaa0b4e1d8a776d3c6003985692d11417f8680dede"
}
12 changes: 10 additions & 2 deletions docs/OPERATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ gpuq status
gpuq doctor
```

提交不申请 GPU。本人可在网页对固定版本点击“开始”,或使用下文的飞书对话确认。授权后由调度服务申请或复用资源。多步任务顺序执行,失败即停。已批准且尚未投放的任务可在网页拖动排序。持续低占用、显存充足且资源兼容时,最多并行两个任务。预计小时用于申请规划,平台回收规则仍适用。
提交不申请 GPU。本人可在网页对固定版本点击“开始”,或使用下文的飞书对话确认。授权后由调度服务申请或复用资源。多步任务顺序执行,失败即停。已批准且尚未投放的任务可在网页拖动排序。设备 UUID 互不重叠,并持续满足负载、显存和资源类型要求时,最多并行两个 GPU 任务。预计小时用于申请规划,平台回收规则仍适用。

### 在飞书对话一次确认多个任务

Expand All @@ -73,6 +73,14 @@ gpuq doctor

整批核验成功后才写入授权。有任务已通过网页启动、被取消或版本及预算变化时,重新准备待启动清单。重复查询或核验已确认批次会返回原回执。回执记录队列授权时间和飞书消息编号,GPU 申请与执行进度由任务状态记录。

### GPU 验证与 CPU 收尾

步骤默认由 GPU 执行器运行。需要 GPU 的验证、导出或打包保留默认设置。可独立执行的打包步骤可在清单末尾添加 `"executor": "cpu"`。CPU 步骤须连续放在 GPU 步骤之后,GPU 阶段须声明用于交接的 `outputs`。CPU 收尾在队列服务所在的成员 CPU 节点使用相同的固定快照和共享输出目录。请使用 CPU 节点可运行的依赖和绝对可执行路径,把收尾的新产物写到独立路径。

执行器清理任务进程并写入归还记录后,队列还会核对 `mf-gpu` 的退出回执。声明了 CPU 收尾的任务还会核验共享产物。下一张已批准任务须等到归还后采集的新样本确认对应设备空闲,才可复用它们。缺少回执、设备或申请归属待核查、共享产物校验失败时,页面显示具体等待原因。

`gpuq status <任务编号>` 仍输出任务 JSON 数组。新增的 `gpu.reason` 来自队列记录,`gpu.admission` 记录调度放行时使用的设备 UUID 和采样时间。`gpu.allocations` 显示当前关联申请与等待任务可见的在途资源,以及队列占用、归属、最后一份执行器回执、释放意图和平台回收回执。字段为 `null` 时表示队列尚无相应证据。查看状态只读取已有记录。

## 服务与数据

### 已点击开始却没有新申请
Expand Down Expand Up @@ -106,7 +114,7 @@ node --test tests/cloud.test.js

## 用完释放的偏好

用户要求队列用完即释放本人新申请的卡。当前成员工具 `mf-gpu` 仅支持提交/状态/执行,GPU申请表也没有主动释放入口;因此本服务尚不能执行实例释放,不会把任务完成或连接超时报告为已释放。网页持续显示这个限制;已启动的队列结束后,服务器在 `~/.local/state/gpuq/release-intents/` 记录待释放请求,待平台提供普通成员释放接口后接通。平台仍按空闲和最长存活规则回收。
当前成员工具 `mf-gpu` 提供提交、状态、轮询与执行入口。已批准任务全部完成 GPU 阶段并确认归还后,服务将释放意图保存到 `~/.local/state/gpuq/release-intents/`,页面显示等待平台回收回执。独立 CPU 收尾可以继续。平台仍按空闲和最长存活规则回收,实例回收状态以匹配的平台注册记录或平台通知为准。

仅记录本服务新申请资源的释放意图;复用的其他资源不自动处理。排队中、执行状态未知或提交回执不明时,不将队列视为已用完。未点击开始的准备任务不占用释放等待。

Expand Down
8 changes: 4 additions & 4 deletions gpuqueue/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pathlib import Path
import sys
import subprocess
from .core import Store, HOME, SITE_URL, normalize, read_json
from .core import DEFAULT_ROOT, Store, HOME, SITE_URL, normalize, read_json

CONFIG_PATH = HOME/'.config/gpuq/connection.json'

Expand Down Expand Up @@ -65,9 +65,9 @@ def main(argv=None):
task, created = Store().submit(document, args.source.capitalize() if args.source.lower() == 'claude' else 'Codex')
print(json.dumps({'ok': True, 'task_id': task['id'], 'created': created, 'state': task['public']['state'], 'url': SITE_URL+'/?task='+task['id'], 'note': '任务已提交,等待本人启动授权。未申请 GPU。'}, ensure_ascii=False))
elif args.action == 'status':
store = Store()
tasks = [store.get(args.task_id)] if args.task_id else store.tasks()
print(json.dumps([t['public'] for t in tasks if t], ensure_ascii=False, indent=2))
from .status import task_status
tasks, resources = Store.status_snapshot(DEFAULT_ROOT)
print(json.dumps(task_status(tasks, resources, args.task_id), ensure_ascii=False, indent=2))
elif args.action == 'web':
from .web import serve as serve_web
serve_web()
Expand Down
24 changes: 23 additions & 1 deletion gpuqueue/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ def string(value, field):
if not isinstance(steps, list) or not 1 <= len(steps) <= 50:
raise ValueError('steps 需要 1–50 个有序步骤')
normalized_steps = []
cpu_only = False
runtimes = {}
source_paths = {(project / name).resolve() for name in files}
for index, raw in enumerate(steps):
Expand Down Expand Up @@ -188,8 +189,17 @@ def string(value, field):
raise ValueError('任务文件不保存凭据;使用本人私有环境配置')
if any(k in env for k in ['CUDA_VISIBLE_DEVICES', 'GPUQ_OUTPUT_DIR', 'GPUQ_TASK_ID']):
raise ValueError('GPU 设备与任务目录由执行器指定')
executor = raw.get('executor', 'gpu')
if executor not in ('gpu', 'cpu') or (executor == 'gpu' and cpu_only) or (executor == 'cpu' and not index):
raise ValueError('executor 只能为 gpu 或 cpu,且 CPU 步骤只能放在 GPU 步骤之后')
validate_step_paths(argv, cwd, project, files, source_paths, index)
normalized_steps.append({'name': name or f'步骤 {index + 1}', 'argv': argv, 'cwd': cwd, 'outputs': outputs, 'env': env})
step = {'name': name or f'步骤 {index + 1}', 'argv': argv, 'cwd': cwd, 'outputs': outputs, 'env': env}
if executor == 'cpu':
cpu_only = True
step['executor'] = 'cpu'
normalized_steps.append(step)
if cpu_only and not any(step['outputs'] for step in normalized_steps if step.get('executor') != 'cpu'):
raise ValueError('CPU 收尾需要声明 GPU 阶段交接的 outputs')
document = {'schema_version': 1, 'title': title, 'description': description, 'project': str(project), 'resources': resources, 'steps': normalized_steps, 'files': files, 'inputs': inputs, 'runtimes': list(runtimes.values()), 'submission_key': submission_key, 'runner_sha256': sha(Path(__file__).with_name('runner.py'))}
digest = document_digest(document)
return document, digest
Expand Down Expand Up @@ -218,6 +228,18 @@ def get(self, task_id):
row = connection.execute('SELECT * FROM tasks WHERE id=?', (task_id,)).fetchone()
return self.decode(row) if row else None

@classmethod
def status_snapshot(cls, root=DEFAULT_ROOT):
path = (Path(root)/'queue.sqlite3').resolve()
if not path.is_file():
return [], {}
with contextlib.closing(sqlite3.connect(path.as_uri()+'?mode=ro', uri=True, timeout=30)) as connection:
connection.row_factory = sqlite3.Row
connection.execute('BEGIN')
tasks = [cls.decode(row) for row in connection.execute('SELECT * FROM tasks ORDER BY rowid')]
row = connection.execute("SELECT value FROM meta WHERE key = 'resources'").fetchone()
return tasks, (json.loads(row[0]) or {}) if row else {}

@staticmethod
def decode(row):
return {'id': row['id'], 'digest': row['digest'], **{k: json.loads(row[k]) for k in ['doc', 'public', 'internal']}}
Expand Down
Loading
Loading