MCP HubMCP Hub
스킬 목록으로 돌아가기

slurm-job-script-generator

HeshamFS
업데이트됨 2 days ago
3 조회
40
3
40
GitHub에서 보기
메타automation

정보

이 스킬은 HPC 자원 요청에 대한 자동 검증 기능을 갖춘 SLURM sbatch 작업 스크립트를 생성합니다. 개발자가 MPI/OpenMP 레이아웃 구성, GPU 작업 설정 및 실행 문제 디버깅을 지원하면서 지시문 충돌을 방지합니다. 클러스터 작업 제출 준비, 팀 스크립트 표준화, 실패한 작업 문제 해결 시 사용하세요.

빠른 설치

Claude Code

추천
기본
npx skills add HeshamFS/materials-simulation-skills -a claude-code
플러그인 명령대체
/plugin add https://github.com/HeshamFS/materials-simulation-skills
Git 클론대체
git clone https://github.com/HeshamFS/materials-simulation-skills.git ~/.claude/skills/slurm-job-script-generator

Claude Code에서 이 명령을 복사하여 붙여넣어 스킬을 설치하세요

문서

SLURM Job Script Generator

Goal

Generate a correct, copy-pasteable SLURM job script (.sbatch) for running a simulation, and surface common configuration mistakes (bad walltime format, conflicting memory flags, oversubscription hints).

Requirements

  • Python 3.8+
  • No external dependencies (Python standard library only)
  • Works on Linux, macOS, and Windows (script generation only)

Inputs to Gather

InputDescriptionExample
Job nameShort identifier for the jobphasefield-strong-scaling
WalltimeSLURM time limit00:30:00
PartitionCluster partition/queue (if required)compute
AccountProject/account (if required)matsim
NodesNumber of nodes to allocate2
MPI tasksTotal tasks, or tasks per node128 or 64 per node
ThreadsCPUs per task (OpenMP threads)2
Memory--mem or --mem-per-cpu (cluster policy dependent)32G
GPUsGPUs per node (optional)4
Working directoryWhere the run should execute$SLURM_SUBMIT_DIR
ModulesEnvironment modules to load (optional)gcc/12, openmpi/4.1
Run commandThe command to launch under SLURM./simulate --config cfg.json

Decision Guidance

MPI vs MPI+OpenMP layout

Does the code use OpenMP / threading?
├── NO  → Use MPI-only: cpus-per-task=1
└── YES → Use hybrid: set cpus-per-task = threads per MPI rank
          and export OMP_NUM_THREADS = cpus-per-task

Rule of thumb: if you see diminishing strong-scaling efficiency at high MPI ranks, try fewer ranks with more threads per rank (and measure).

Memory flag selection

  • Use either --mem (per node) or --mem-per-cpu (per CPU), not both.
  • Follow your cluster’s documentation; some sites enforce one style.
  • SLURM --mem units are integer MB by default, or an integer with suffix K/M/G/T (and --mem=0 commonly means “all memory on node”).

Script Outputs (JSON Fields)

ScriptKey Outputs
scripts/slurm_script_generator.pyresults.script, results.directives, results.derived, results.warnings

Workflow

  1. Gather cluster constraints (partition/account, GPU policy, memory policy).
  2. Choose a process layout (MPI-only vs hybrid MPI+OpenMP).
  3. Generate the script with slurm_script_generator.py.
  4. Inspect warnings (conflicts, suspicious layouts).
  5. Save the generated script as job.sbatch.
  6. Submit with sbatch job.sbatch and monitor with squeue.

CLI Examples

# Preview a job script (prints to stdout)
python3 skills/hpc-deployment/slurm-job-script-generator/scripts/slurm_script_generator.py \
  --job-name phasefield \
  --time 00:10:00 \
  --partition compute \
  --nodes 1 \
  --ntasks-per-node 8 \
  --cpus-per-task 2 \
  --mem 16G \
  --module gcc/12 \
  --module openmpi/4.1 \
  -- \
  ./simulate --config config.json

# Write to a file and also emit structured JSON
python3 skills/hpc-deployment/slurm-job-script-generator/scripts/slurm_script_generator.py \
  --job-name phasefield \
  --time 00:10:00 \
  --nodes 1 \
  --ntasks 16 \
  --cpus-per-task 1 \
  --out job.sbatch \
  --json \
  -- \
  /bin/echo hello

Conversational Workflow Example

User: I need an sbatch script for my MPI simulation. I want 2 nodes, 64 ranks per node, 2 OpenMP threads per rank, and 2 hours.

Agent workflow:

  1. Confirm partition/account and whether GPUs are needed.
  2. Generate a hybrid job script:
    python3 scripts/slurm_script_generator.py --job-name run --time 02:00:00 --nodes 2 --ntasks-per-node 64 --cpus-per-task 2 -- -- ./simulate
    
  3. Explain the mapping:
    • Total ranks = 128
    • Threads per rank = 2 (OMP_NUM_THREADS=2)
  4. If the user provides node core counts, sanity-check oversubscription using --cores-per-node.

Error Handling

ErrorCauseResolution
time must be HH:MM:SS or D-HH:MM:SSBad walltime formatUse 00:30:00 or 1-00:00:00
nodes must be positiveNon-positive nodesProvide --nodes >= 1
Provide either --mem or --mem-per-cpu, not bothConflicting memory directivesChoose one memory style
Provide a run command after --Missing launch commandAdd -- ./simulate ...

Security

Input Validation

  • --time is validated against strict HH:MM:SS or D-HH:MM:SS format via regex
  • --nodes, --ntasks, --ntasks-per-node, --cpus-per-task, --gpus are validated as positive integers with upper bounds
  • --mem and --mem-per-cpu are validated against SLURM's accepted format (<int>[K|M|G|T]); providing both simultaneously is rejected
  • --job-name is validated against [a-zA-Z0-9_.-]+ (no shell metacharacters)
  • --partition and --account are validated against safe-character allowlists
  • --module values are validated to prevent shell injection (no ;, |, &, backticks, or $)

File Access

  • The script reads no external files; all inputs are provided via CLI arguments
  • --out writes the generated sbatch script to a single specified file path
  • The generated script is a plain-text shell script with #SBATCH directives; it contains no dynamically generated code

Tool Restrictions

  • Read: Used to inspect script source, references, and existing job scripts
  • Bash: Used to execute slurm_script_generator.py with explicit argument lists; the generated script itself is NOT executed by the agent
  • Write: Used to save the generated .sbatch file; writes are scoped to the user's working directory
  • Grep/Glob: Used to locate existing scripts, configs, and cluster documentation

Safety Measures

  • No eval(), exec(), or dynamic code generation
  • All subprocess calls use explicit argument lists (no shell=True)
  • The run command (after --) is included verbatim in the generated script but is never executed by the skill itself
  • Module names are sanitized to prevent injection into module load directives
  • Generated scripts use set -euo pipefail for safe shell execution on the cluster

Limitations

  • Does not query cluster hardware or site policies; it can only validate internal consistency.
  • SLURM installations vary (GPU directives, QoS rules, partitions). Adjust directives for your site.

References

  • references/slurm_directives.md - Common #SBATCH directives and mapping tips

Version History

  • v1.0.0 (2026-02-25): Initial SLURM job script generator

GitHub 저장소

HeshamFS/materials-simulation-skills
경로: skills/hpc-deployment/slurm-job-script-generator
0
agent-skillsagentscli-toolscomputational-sciencellmmaterials-science

연관 스킬

content-collections

메타

이 스킬은 콘텐츠 콜렉션(Content Collections)을 위한 프로덕션 검증된 설정을 제공합니다. 콘텐츠 콜렉션은 Markdown/MDX 파일을 Zod 검증이 포함된 타입 안전한 데이터 콜렉션으로 변환해주는 TypeScript 최우선 도구입니다. 블로그, 문서 사이트 또는 콘텐츠 중심의 Vite + React 애플리케이션을 구축할 때 타입 안전성과 자동 콘텐츠 검증을 보장하기 위해 사용하세요. Vite 플러그인 구성과 MDX 컴파일부터 배포 최적화 및 스키마 검증에 이르기까지 모든 것을 다룹니다.

스킬 보기

polymarket

메타

이 스킬은 개발자들이 Polymarket 예측 시장 플랫폼을 활용한 애플리케이션을 구축할 수 있도록 지원하며, 거래 및 시장 데이터를 위한 API 통합 기능을 포함합니다. 또한 WebSocket을 통한 실시간 데이터 스트리밍을 제공하여 실시간 거래와 시장 활동을 모니터링할 수 있습니다. 이를 통해 거래 전략을 구현하거나 실시간 시장 업데이트를 처리하는 도구를 생성하는 데 활용할 수 있습니다.

스킬 보기

creating-opencode-plugins

메타

이 스킬은 개발자들이 명령어, 파일, LSP 작업 등 25개 이상의 이벤트 유형에 연결되는 OpenCode 플러그인을 만들 수 있도록 돕습니다. JavaScript/TypeScript 모듈을 위한 플러그인 구조, 이벤트 API 명세, 구현 패턴을 제공합니다. OpenCode AI 어시스턴트의 라이프사이클을 사용자 정의 이벤트 기반 로직으로 가로채거나, 모니터링하거나, 확장해야 할 때 사용하세요.

스킬 보기

sglang

메타

SGLang은 RadixAttention 프리픽스 캐싱을 활용하여 JSON, 정규식, 에이전트 워크플로우를 위한 고속 구조화 생성에 특화된 고성능 LLM 서빙 프레임워크입니다. 특히 반복되는 프리픽스가 있는 작업에서 상당히 빠른 추론 속도를 제공하여 복잡한 구조화 출력 및 다중 턴 대화에 이상적입니다. 제약 디코딩이 필요하거나 광범위한 프리픽스 공유가 있는 애플리케이션을 구축할 때는 vLLM과 같은 대안보다 SGLang을 선택하십시오.

스킬 보기