hpc-runtime-doctor
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseHPC Runtime Doctor
HPC运行时诊断器
Goal
目标
Turn cluster symptoms into a resource-layout diagnosis, environment checklist, and safe retry plan.
将集群作业的异常症状转化为资源布局诊断结果、环境检查清单及安全重试方案。
Requirements
要求
- Python 3.10+
- No external dependencies
- Works on Linux, macOS, and Windows
- Python 3.10+
- 无外部依赖
- 支持Linux、macOS和Windows系统
Inputs to Gather
需要收集的输入信息
| Input | Description | Example |
|---|---|---|
| Scheduler | SLURM, PBS, LSF, local | |
| Nodes/tasks/threads | Runtime layout | |
| GPUs | Total (whole-job) GPUs via | |
| Symptoms | Observed failure | |
| MPI/OpenMP/GPU use | Parallel modes | |
| Walltime | Requested time | |
| Scratch | Whether scratch is used | |
| 输入项 | 描述 | 示例 |
|---|---|---|
| 调度器(Scheduler) | SLURM、PBS、LSF、本地调度器 | |
| 节点/任务/线程数 | 运行时布局 | |
| GPU配置 | 通过 | |
| 异常症状 | 观察到的失败现象 | |
| MPI/OpenMP/GPU使用情况 | 并行模式 | |
| 作业时长(Walltime) | 请求的运行时长 | |
| 临时存储(Scratch) | 是否使用临时存储 | |
Decision Guidance
决策指导
- Check resource layout before changing physics settings.
- Confirm module/compiler/MPI/CUDA consistency before debugging solver behavior.
- Treat missing restart files and scratch cleanup as workflow failures, not physics failures.
- For GPU jobs, confirm the executable was built with the requested accelerator backend.
- 在修改物理模拟设置前,先检查资源布局。
- 在调试求解器行为前,确认模块/编译器/MPI/CUDA的一致性。
- 将缺失重启文件和临时存储清理问题视为工作流失败,而非物理模拟失败。
- 对于GPU作业,确认可执行文件是基于指定的加速器后端编译的。
Script Outputs
脚本输出
scripts/hpc_runtime_doctor.py- (includes
resource_layout,tasks_per_node, totaltotal_cpus, andgpus)gpus_per_node diagnosesenvironment_checksretry_planscheduler_notes- (layout flags such as ranks-per-GPU oversubscription, OpenMP/thread mismatch, and uneven task placement)
warnings
In default (non-JSON) mode the script also prints the resource-layout summary, any
, environment checks, and retry plan, so the most actionable items are never hidden.
warningsscripts/hpc_runtime_doctor.py- (包含
resource_layout、tasks_per_node、总total_cpus及gpus)gpus_per_node - (诊断结果)
diagnoses - (环境检查项)
environment_checks - (重试方案)
retry_plan - (调度器说明)
scheduler_notes - (布局警告,如单GPU上MPI进程数过载、OpenMP/线程不匹配、任务分布不均等)
warnings
在默认(非JSON)模式下,脚本还会打印资源布局摘要、所有、环境检查项及重试方案,确保最具操作性的信息不会被隐藏。
warningsWorkflow
工作流程
--gpus--gpus-per-node--gres=gpu:Ngpus_per_node * nodes--gpusbash
python3 skills/hpc-deployment/hpc-runtime-doctor/scripts/hpc_runtime_doctor.py \
--scheduler slurm \
--nodes 2 \
--tasks 128 \
--cpus-per-task 2 \
--gpus 4 \
--symptoms oom,slow-gpu \
--uses-mpi \
--uses-openmp \
--uses-gpu \
--jsonThe example above shares 128 ranks across 4 GPUs (32 ranks/GPU), so the
list surfaces The ranks-per-GPU check uses total ranks over total GPUs, so it fires
correctly on multi-node jobs (the threshold is 16 ranks/GPU).
warningsMany MPI ranks per GPU (32.0 ranks/GPU) may reduce GPU efficiency.--gpus--gpus-per-node--gres=gpu:Ngpus_per_node * nodes--gpusbash
python3 skills/hpc-deployment/hpc-runtime-doctor/scripts/hpc_runtime_doctor.py \
--scheduler slurm \
--nodes 2 \
--tasks 128 \
--cpus-per-task 2 \
--gpus 4 \
--symptoms oom,slow-gpu \
--uses-mpi \
--uses-openmp \
--uses-gpu \
--json上述示例将128个进程分配到4个GPU上(每个GPU 32个进程),因此列表会显示(单GPU上MPI进程数过多(32.0个/ GPU)可能降低GPU效率)。单GPU进程数检查基于总进程数除以总GPU数,因此在多节点作业中也能正确触发(阈值为16个进程/GPU)。
warningsMany MPI ranks per GPU (32.0 ranks/GPU) may reduce GPU efficiency.Error Handling
错误处理
Invalid resource counts stop with exit code 2. Unknown symptoms are preserved as custom items for human review.
无效的资源计数会导致脚本以退出码2终止。未知症状会被保留为自定义项,供人工审核。
Limitations
局限性
This skill does not query a live scheduler. It diagnoses from the submitted layout and symptoms.
本工具不会查询实时调度器,仅基于提交的布局和症状进行诊断。
Verification checklist
验证清单
- Recorded the script's block and confirmed
resource_layoutis an integer (no fractional value) andtasks_per_nodeequalstotal_cpus; iftasks * cpus_per_taskis fractional, the uneven-placement warning was triaged before retrying.tasks_per_node - For GPU jobs, recorded the resolved total (and
gpuswhen set) and computed ranks/GPU =gpus_per_node, confirming it is at or below the 16 ranks/GPU threshold or that the resultingtasks / gpuswarning was deliberately accepted.Many MPI ranks per GPU - Reviewed every entry in the list (OpenMP-with-
warnings, GPU-requested-but-zero-GPUs,cpus_per_task=1, uneven placement, scratch-for-heavy-I/O) and resolved or justified each one rather than ignoring it.tasks < nodes - Completed the items as real artifacts: captured the module list, executable path/version, MPI launcher-vs-library match, accelerator build flags (CUDA/Kokkos/OpenMP), and scheduler stdout/stderr.
environment_checks - Mapped each observed symptom to a entry and verified no symptom landed in the
diagnosescategory unaddressed (everycustomitem had stderr/stdout/module list/command line collected for human review).custom - Followed the : reran the smallest reproducing case, changed exactly one resource variable, enabled restart/checkpoint, and saved the scheduler script plus environment snapshot alongside the results.
retry_plan
- 记录脚本的块,确认
resource_layout为整数(无小数)且tasks_per_node等于total_cpus;若tasks * cpus_per_task为小数,需先处理任务分布不均的警告,再重试作业。tasks_per_node - 对于GPU作业,记录解析后的总(以及设置的
gpus),计算单GPU进程数 =gpus_per_node,确认该值等于或低于16个进程/GPU的阈值,或已明确接受tasks / gpus警告。Many MPI ranks per GPU - 审核列表中的每一项(如OpenMP搭配
warnings、请求GPU但实际分配为0、cpus_per_task=1、任务分布不均、高IO场景使用临时存储等),并逐一解决或说明理由,而非忽略。tasks < nodes - 完成中的所有项:捕获模块列表、可执行文件路径/版本、MPI启动器与库的匹配情况、加速器编译标志(CUDA/Kokkos/OpenMP)及调度器的标准输出/错误输出。
environment_checks - 将每个观察到的症状映射到中的条目,确认没有症状被归入未处理的
diagnoses类别(每个custom项都已收集调度器的标准错误/输出、模块列表及命令行信息供人工审核)。custom - 遵循:运行最小复现案例,每次仅修改一个资源变量,启用重启/checkpoint功能,并将调度器脚本及环境快照与结果一起保存。
retry_plan
Common pitfalls & rationalizations
常见误区与合理化解释
| Tempting shortcut | Why it's wrong / what to do |
|---|---|
| "It ran without crashing, so the layout is fine." | Run completion is not correctness. Review the |
| "Per-node ranks fit the GPUs, so there's no oversubscription." | Oversubscription is total ranks over total GPUs, not per-node. The script computes |
"I passed | |
| "The job was killed, so it's a physics/solver bug." | |
| "An unknown symptom isn't in the rules, so I can skip it." | Unknown symptoms become |
| "Just change ranks, threads, and the build together to fix it faster." | Changing multiple variables at once makes the failure undiagnosable. The |
| 诱人的捷径 | 错误原因及正确做法 |
|---|---|
| "作业没有崩溃,所以布局没问题。" | 作业完成不代表结果正确。请审核 |
| "单节点进程数适配GPU,所以没有过载。" | 资源过载是基于总进程数除以总GPU数,而非单节点。脚本会计算 |
"我已经指定了 | |
| "作业被终止了,所以是物理模拟/求解器的bug。" | |
| "未知症状不在规则中,所以我可以跳过它。" | 未知症状会被标记为 |
| "同时修改进程数、线程数和编译配置,这样能更快修复问题。" | 同时修改多个变量会导致无法定位失败原因。 |
Security
安全性
Input Validation
输入验证
- Inputs are scalar CLI values and booleans only; there is no free-form code path.
- Resource counts (,
--nodes,--tasks,--cpus-per-task,--gpus) are validated as integers (booleans rejected), required to be non-negative and finite, and capped at 1,000,000.--gpus-per-node,--nodes, and--tasksmust additionally be at least 1. Out-of-range, non-integer, or zero values exit with code 2.--cpus-per-task - The string is capped at 64 comma-separated entries of at most 64 characters each;
--symptomsis capped at 32 characters. Oversized input exits with code 2.--walltime - Symptoms are split, trimmed, and lower-cased. Unknown symptoms are not rejected: they are
preserved as diagnoses for human review.
custom - is accepted as a free-form string and is not checked against an allowlist; it is only echoed back in the resource layout.
--scheduler
- 输入仅为标量CLI值和布尔值;不存在自由格式代码路径。
- 资源计数(、
--nodes、--tasks、--cpus-per-task、--gpus)会被验证为整数(拒绝布尔值),要求非负且有限,上限为1,000,000。--gpus-per-node、--nodes和--tasks必须至少为1。超出范围、非整数或零值会导致脚本以退出码2终止。--cpus-per-task - 字符串最多包含64个逗号分隔的条目,每个条目最多64个字符;
--symptoms最多32个字符。超出限制的输入会导致脚本以退出码2终止。--walltime - 症状会被拆分、修剪并转为小写。未知症状不会被拒绝:它们会被保留为诊断项供人工审核。
custom - 接受自由格式字符串,不会与允许列表进行检查;仅会在资源布局中回显。
--scheduler
File Access
文件访问
- The script reads and writes no files. All I/O is CLI args in and stdout out
(indented JSON with , otherwise a human-readable summary); errors go to stderr.
--json - Because no paths are accepted or opened, there is no filesystem traversal surface and no path-sandboxing concern.
- 脚本不读取或写入任何文件。所有I/O均为CLI输入和标准输出(使用时为缩进格式的JSON,否则为人类可读的摘要);错误信息输出到标准错误。
--json - 由于不接受或打开任何路径,因此不存在文件系统遍历风险,也无需考虑路径沙箱限制。
Tool Restrictions
工具限制
- is
allowed-tools.Read, Bash, Write, Grep, Glob - is used only to run the bundled
Bash.scripts/hpc_runtime_doctor.py - ,
Read, andGrepare used to inspect the skill's own files and any logs or submission scripts the user points at;Globis used to record diagnosis notes or a retry plan when asked.Write
- 为
allowed-tools。Read, Bash, Write, Grep, Glob - 仅用于运行捆绑的
Bash。scripts/hpc_runtime_doctor.py - 、
Read和Grep用于检查工具自身的文件以及用户指定的日志或提交脚本;Glob用于在需要时记录诊断笔记或重试方案。Write
Safety Measures
安全措施
- No ,
eval,exec, oros.system; the script does not launch a scheduler or any external process and does not inspect environment variables.subprocess - Argument parsing is handled by , and machine-readable output is emitted as JSON.
argparse - DoS exposure is bounded by the resource-count cap (1,000,000), the symptom caps (64 entries x 64 characters), and the walltime cap (32 characters).
- 不使用、
eval、exec或os.system;脚本不会启动调度器或任何外部进程,也不会检查环境变量。subprocess - 参数解析由处理,机器可读输出以JSON格式生成。
argparse - 拒绝服务(DoS)风险受限于资源计数上限(1,000,000)、症状限制(64个条目×64字符)及作业时长限制(32字符)。
References
参考资料
- See for scheduler and runtime diagnosis patterns.
references/hpc_runtime_patterns.md
- 调度器和运行时诊断模式请参考。
references/hpc_runtime_patterns.md
Version History
版本历史
- 1.1.3: Added a Verification checklist (evidence-based items tied to
,
resource_layout, ranks/GPU,warnings,environment_checks, and thediagnoses) and a Common pitfalls & rationalizations table.retry_plan - 1.1.1: Discriminating evals -- each case now pins the script's specific output
(exact ranks-per-GPU warning, diagnosis categories, resource-layout fields) via
deterministic .
script_checks - 1.1.0: Unit-consistent ranks-per-GPU warning (total ranks / total GPUs), new
argument, integer
--gpus-per-nodewith an uneven-placement warning, full human-readable (non-JSON) output, and input caps for resource counts, symptoms, and walltime.tasks_per_node - 1.0.0: Initial HPC runtime diagnosis skill.
- 1.1.3:新增验证清单(与、
resource_layout、单GPU进程数、warnings、environment_checks及diagnoses相关的循证项)和常见误区与合理化解释表格。retry_plan - 1.1.1:差异化评估——每个案例现在通过确定性的固定脚本的特定输出(如精确的单GPU进程数警告、诊断类别、资源布局字段)。
script_checks - 1.1.0:基于统一单位的单GPU进程数警告(总进程数/总GPU数)、新增参数、整数型
--gpus-per-node及任务分布不均警告、完整的人类可读(非JSON)输出,以及资源计数、症状和作业时长的输入限制。tasks_per_node - 1.0.0:初始版本的HPC运行时诊断工具。