awsome-distributed-ai / slinky-slurm
AGENTS.md484 starsChanged 3 months agoMIT-0View on GitHub
Guidelines for AI coding agents operating in the slinky-slurm subdirectory of awsome-distributed-ai. This is an infrastructure-as-code project for deploying Slurm on Amazon SageMaker HyperPod EKS via the Slinky Project (SchedMD). This project contains Helm values, Kubernetes manifests, Dockerfiles, Terraform/CloudFormation parameters, Slurm batch scripts, deployment automation scripts, and documentation. There is no application source code (no Python/Go/TS modules). Sbatch scripts are organized by workload type under sbatch/ (e.g., sbatch/fsdp/) with hardware-profile prefixes (g5, p5). Infrastructure config files (params.json, custom.tfvars) are consolidated…
- Deletes or force-pushes
- Installs packages
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,736 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository12 other files it gives its agents.
- AGENTS.mdAGENTS.md
- architectures/sagemaker-hyperpod-eks/terraform-modules/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- bash-testingSkill
- build-slurm-imageSkill
- deploy-infrastructureSkill
- deployment-preflightSkill
- deploy-slurm-clusterSkill
- validate-deploymentSkill
- hyperpod-devops-agent-solutionSkill
- hyperpod-incident-rcaSkill
- hyperpod-incident-triageSkill
The file
We split this AGENTS.md into the rules it gives an agent
8 rules. About 0 are common, 2 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 134
When adding new bash scripts, follow this pattern:
- Very specific: line 138
Add fixture data to tests/fixtures/
- Very specific: line 139
Write tests in tests/test_<script>.bats
- Very specific: line 178
Use YAML anchors (&anchorName) and aliases (*anchorName) for repeated config blocks (e.g., commonAffinity)
- Very specific: line 224
Use ${VAR} brace syntax in compound expressions: ${EFA_PATH}/lib
- Very specific: line 240
Use ARG for parameterized versions
- Very specific: line 265
Use ### for primary section headings
- Distinctive: line 292
All other structure and configuration patterns should remain consistent between the two profiles.
≈ “Common” is an estimate: at least 1 in 5 of the 16,597 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md — slinky-slurm
Guidelines for AI coding agents operating in the
slinky-slurmsubdirectory ofawsome-distributed-ai. This is an infrastructure-as-code project for deploying Slurm on Amazon SageMaker HyperPod EKS via the Slinky Project (SchedMD).
Project Overview
This project contains Helm values, Kubernetes manifests, Dockerfiles, Terraform/CloudFormation
parameters, Slurm batch scripts, deployment automation scripts, and documentation. There is
no application source code (no Python/Go/TS modules). Sbatch scripts are organized by
workload type under sbatch/ (e.g., sbatch/fsdp/) with hardware-profile prefixes (g5, p5).
Infrastructure config files (params.json, custom.tfvars) are consolidated at the
project root with ml.g5.8xlarge defaults; deploy.sh overrides values for any user-specified
instance type via --instance-type and --instance-count.
Key automation scripts:
deploy.sh— Infrastructure deployment via CloudFormation or Terraform; supports--training-plan <name>for reserved capacity (auto-resolves ARN and AZ); CFN path is idempotent (create or update based on stack status)setup.sh— Container image build (CodeBuild/local), SSH keys, Helm values generationinstall.sh— cert-manager, AWS LB Controller (Pod Identity), subnet tagging, FSx PVC, MariaDB, Slurm operator, Slurm cluster Helm installs, NLB config; supports--skip-cert-manager,--skip-lb-controller,--skip-ebs-csifor pre-installed components and--cluster-name/--vpc-idfor bring-your-own-cluster; useshelm upgrade --installfor idempotent operationsdestroy.sh— Reverse teardown of all deployed resources (including LB Controller Pod Identity + IAM, cert-manager, and FSx PVC); warns whenEKS_CLUSTER_NAMEis unset and Pod Identity / addon cleanup is skipped; warns whenAWS_ACCOUNT_IDis unavailable and IAM cleanup is skipped; preserves ECR repository and S3 build context bucket with manual cleanup commands printed at end of runlib/deploy_helpers.sh— Extracted testable functions sourced bydeploy.shandsetup.shparams.json— CloudFormation parameters (40 params, g5 defaults)custom.tfvars— Terraform variables (g5 defaults)slurm-values.yaml.template— Consolidated Helm values with shell template variables
Build / Validate / Test Commands
There is no traditional build system (no Makefile, package.json, or pyproject.toml).
Docker Image Build
# Authenticate to ECR (required for DLC base image)
aws ecr get-login-password --region us-east-1 | \
docker login --username AWS --password-stdin 763104351884.dkr.ecr.us-east-1.amazonaws.com
# Build the Slurm compute node image
docker buildx build -t dlc-slurmd:latest -f dlc-slurmd.Dockerfile .Helm Chart Validation
# Lint a values file against the upstream chart
helm lint <chart-path> -f slurm-values.yaml
helm template <release-name> <chart-path> -f slurm-values.yamlYAML Validation
# Validate Kubernetes manifests
kubectl apply --dry-run=client -f lustre-pvc-slurm.yaml
kubectl apply --dry-run=client -f lustre-storageclass.yamlMarkdown Linting
The repo root has .markdownlint.jsonc with these rules:
- MD041 (first-line heading): disabled
- MD013 (line length): 100 chars, code blocks excluded
- MD033 (inline HTML): disabled
# From repo root
npx markdownlint-cli2 "architectures/sagemaker-hyperpod-eks/slinky-slurm/**/*.md"CI Static Analysis (PR workflow)
The GitHub Actions workflow pr-review-and-slurm-test.yml runs on PRs to main:
pylintandflake8on any.pyfilesbash -nsyntax checking on.shfiles- Secrets scanning via grep patterns
Tests
Bash scripts are tested using bats-core with
bats-assert and bats-support helper libraries. The repo root conftest.py provides legacy
pytest fixtures for Docker-based tests but should not be used as a reference for new tests.
# One-time setup: install bats-core
brew install bats-core # macOS
# OR: sudo apt-get install -y bats # Debian/Ubuntu
# OR: npm install -g bats # cross-platform
# One-time setup: install bats helper libraries
bash tests/install_bats_libs.sh
# Run all bats tests
bats tests/
# Run a specific test file
bats tests/test_deploy.bats
# Verbose output (show test names)
bats --verbose-run tests/test_deploy.batsTest structure:
tests/test_deploy.bats— 72 unit tests fordeploy.shandlib/deploy_helpers.shtests/test_setup.bats— 13 unit tests forsetup.shargument parsing, profile resolution, and template substitutiontests/test_install.bats— 49 unit tests forinstall.shargument parsing, version constants, install order, skip flags, existing cluster support,helm upgrade --install, IAM idempotency,env_vars.shdependency validation, and EBS CSI/gp3 phasestests/test_destroy.bats— 20 unit tests fordestroy.shargument parsing, teardown order, IAM cleanup, EKS_CLUSTER_NAME warnings, and CodeBuild TF destroytests/fixtures/— Independent copies ofparams.json,custom.tfvars, andslurm-values.yaml.templatefor test isolationtests/helpers/setup.bash— Common bats setup/teardown (loads helpers, creates temp dir, sourceslib/deploy_helpers.sh, activates AWS CLI mock)tests/helpers/mock_aws.bash— AWS CLI mock function that interceptsawscalls with canned responsestests/install_bats_libs.sh— Clones bats-assert and bats-support intotests/bats/(gitignored, not committed)
When adding new bash scripts, follow this pattern:
- Extract testable functions into
lib/<script>_helpers.sh - Source the helpers file from the main script
- Add fixture data to
tests/fixtures/ - Write tests in
tests/test_<script>.bats - Load
helpers/setupat the top of each.batsfile
Code Style Guidelines
EditorConfig (repo-wide)
Defined in /.editorconfig:
- Line endings: LF (Unix)
- Charset: UTF-8
- Trailing whitespace: trimmed
- Final newline: required
- YAML/JSON indent: 2 spaces
- Makefile indent: tabs
File Naming
- Lowercase with hyphens:
lustre-pvc-slurm.yaml,openzfs-storageclass.yaml - Instance-type prefix for profile-specific files:
g5-values.yaml,p5-values.yaml - Dockerfile uses PascalCase extension:
dlc-slurmd.Dockerfile - Model names in sbatch files may use underscores:
g5-llama2_7b-training.sbatch
YAML Conventions (Helm Values)
- 2-space indentation throughout (Kubernetes/Helm standard)
helm-docs type annotations above every configurable value:
# -- (string) # Set the image pull policy. imagePullPolicy: IfNotPresent- WARNING: prefix for destructive/important caveats
- NOTE: prefix for informational notes
- Ref: prefix linking to upstream documentation
@ignoredtag to exclude values from helm-docs- Empty defaults:
{}for maps,[]for lists,""for strings - Use YAML anchors (
&anchorName) and aliases (*anchorName) for repeated config blocks (e.g.,commonAffinity) Commented-out examples for optional/disabled values:
resources: {} # requests: # cpu: 1 # memory: 1Gi
Kubernetes Manifest YAML
- Resource names: lowercase with hyphens (
fsx-claim,openzfs-sc) - Standard key ordering:
apiVersion,kind,metadata,spec - Quoted string values for StorageClass parameters:
"0","true","LZ4"
JSON Conventions
- 2-space indentation
- Standard JSON (no trailing commas)
- CloudFormation parameter keys use PascalCase per AWS convention
Terraform Variables (.tfvars)
- snake_case for all variable names (standard Terraform convention)
- String values quoted, numbers and booleans unquoted
- One assignment per line
Shell / Slurm Batch Scripts (.sbatch)
- Shebang:
#!/bin/bash - Error handling:
set -exat the top of every sbatch script- For automation scripts (
deploy.sh,setup.sh,install.sh,destroy.sh), preferset -euo pipefail - For prolog/epilog scripts, prefer
set -euo pipefail
- For automation scripts (
- Environment variables:
SCREAMING_SNAKE_CASE Group variables by category with decorative section headers:
########################### ###### User Variables ##### ###########################- Quote paths and string values in exports:
export CUDA_HOME="/usr/local/cuda" - Use
${VAR}brace syntax in compound expressions:${EFA_PATH}/lib Bash arrays with
declare -aand 4-space indentation inside:declare -a TORCHRUN_ARGS=( --nproc_per_node=$GPUS_PER_NODE --nnodes=$SLURM_JOB_NUM_NODES )- Expand arrays with proper quoting:
"${TORCHRUN_ARGS[@]}" - Right-align inline comments for visual consistency
Dockerfile Conventions
- Multi-stage builds: name stages with
AS <name>forCOPY --from=<name> - Use
ARGfor parameterized versions - Group
ENVdeclarations with\continuation by functional area - APT pattern:
apt-get update && apt-get install -y --no-install-recommends ... && rm -rf /var/lib/apt/lists/* && apt-get cleanin a singleRUNlayer - Sort package lists alphabetically, one per line
- Section comments above each logical block of
COPY/RUNinstructions - Minimize layers: chain related commands with
&&
License Headers
Helm values (SchedMD origin): SPDX format
# SPDX-FileCopyrightText: Copyright (C) SchedMD LLC. # SPDX-License-Identifier: Apache-2.0Sbatch scripts (Amazon origin):
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: MIT-0
Markdown Documentation
- Use
###for primary section headings - Max line length: 100 characters (code blocks excluded)
- Inline HTML (
<u>, etc.) is permitted (MD033 disabled) - Backtick-wrap commands, file names, and environment variables
- Tables for structured component descriptions
- Link format:
[text](url)
Keeping g5 and p5 Sbatch Files in Sync
Sbatch scripts are organized under sbatch/ by workload type (e.g., sbatch/fsdp/), with
hardware-profile prefixes (g5-, p5-). When modifying one profile's sbatch, check whether
the same change should be applied to the other. The two files within each workload directory
are structurally aligned (same section ordering, same environment variable blocks) so they
diff cleanly. The params.json and custom.tfvars files have been consolidated to the
project root (g5 defaults); deploy.sh overrides values for any instance type at deploy time.
Helm values files have been consolidated into slurm-values.yaml.template at the project root.
Known intentional differences between g5 and p5 sbatch scripts (GPU/EFA/GRES values are
auto-discovered from the instance type via aws ec2 describe-instance-types):
- Instance types (
ml.g5.8xlargevsml.p5.48xlarge) - GPU counts (1 vs 8) and EFA interface counts (1 vs 32)
- Compute node replicas (4 vs 2)
- GRES configuration (
gpu:a10g:1vsgpu:h100:8) - SBATCH directives (
--ntasks-per-node,--cpus-per-task) - EFA/NCCL environment variables specific to the network topology
All other structure and configuration patterns should remain consistent between the two profiles.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

