parallel-python

Guidance for choosing Python's parallel-work tools—such as threads, separate processes, queues, and Slurm job arrays—on Yale SOM's shared high-performance computing cluster.

In plain words
What is it for?
Running CPU-heavy Python code, handling many independent files or years, making concurrent network or database requests, and sizing workers for cluster jobs.
Why use it?
It helps match the method to the work, avoid conflicting layers of parallelism, and keep worker counts within the CPUs Slurm assigned to the job.

Skill for Claude CodeCodex

Part of the hpc plugin — 23 skills, 3 commands shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/yale-som-hpc/claude-code-marketplace/parallel-python
Any agent
npx skills add yale-som-hpc/claude-code-marketplace --skill parallel-python
Clone the repo
git clone --depth 1 https://github.com/yale-som-hpc/claude-code-marketplace

Made for: Claude Code, Codex.

Or install hpc, the plugin that ships this one along with the rest of its 23 skills, 3 commands.

Per session 61 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,852 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00061 $0.03852
Opus 5 $0.00030 $0.01926
Sonnet 5 $0.00012 $0.00770
Haiku 4.5 $0.00006 $0.00385

Measured 2d ago against content hash cb035aed64bd, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

parallel-python scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/hpc/skills/parallel-python/SKILL.md · 350 lines

How it starts

The opening of the file, as written. The whole thing — 350 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Parallel Python

Rule: pick one main layer of parallelism, match it to the bottleneck, and size workers from the Slurm allocation. If one process is too slow, first check accelerating Python.

Choose the right tool

Workload Use Avoid
Independent tasks across files/years/specs Slurm array or GNU parallel One giant Python process
CPU-bound pure Python ProcessPoolExecutor or multiprocessing Threads, because of the GIL
I/O-bound HTTP/API/database work threads or async Too many processes
Variable-duration tasks imap_unordered or as_completed Static equal chunks
Large numeric kernels BLAS/NumPy/Polars/DuckDB threads Extra Python processes unless needed
GPU training/inference one process per GPU pattern CPU preprocessing inside GPU allocation

Respect the Slurm allocation

SLURM_CPUS_PER_TASK is set inside Slurm jobs and unset on your laptop. Use a small helper so the same script works in both places:

import os

def available_workers() -> int:
    """Match the Slurm allocation when running under sbatch/srun, fall back
    to the local machine's CPU count for laptop / login-node testing."""
    slurm = os.environ.get("SLURM_CPUS_PER_TASK")
    if slurm:
        return int(slurm)
    # cgroup-aware fallback. Do NOT use os.cpu_count(): inside a small allocation
    # it returns the whole node (e.g. 32) — verified on this cluster — so a job
    # with SLURM_CPUS_PER_TASK unset would oversubscribe massively.
    return len(os.sched_getaffinity(0))

If Slurm gives you 4 CPUs, do not start 32 workers. If each worker calls BLAS/NumPy, also set thread environment variables in the Slurm script.

Avoid nested parallelism

This is the single biggest waste pattern on the cluster.

Bad: 500 Slurm array tasks × 16 Python processes × 8 BLAS threads = 64,000 runnable threads.

Good: 50 concurrent Slurm tasks × 1 Python process × 1 BLAS thread; or: 1 Slurm job × 16 Python processes × 1 BLAS thread

Read the full file on GitHub · 350 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 350 lines · 61 tokens per session scan A cb035aed64bd

Subscribe to this mod's changes

parallel-python is a skill published in the GitHub repository yale-som-hpc/claude-code-marketplace (5 stars, last pushed 1mo ago), licensed Unlicense. It adds 61 tokens to every session and 3,852 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

bump-dependency

Bumps a Python package dependency across Home Assistant Core integrations, regenerates core requirement files, runs verification tests and prek lint, and prepares a pull request with proper release/compare links.

home-assistant/core · 42 tokens

biopython

Comprehensive molecular biology toolkit. Use for sequence manipulation, file parsing (FASTA/GenBank/PDB), phylogenetics, and programmatic NCBI/PubMed access (Bio.Entrez). Best for batch processing, custom bioinformatics pipelines, BLAST automation. For quick lookups use gget; for multi-service integration use…

K-Dense-AI/scientific-agent-skills · 76 tokens

marimo-pair

Work inside the user's live marimo notebook from the code editor: run Python in the same kernel the user does, inspect live notebook state, and commit durable notebook changes through code mode. Use whenever you create, analyze, or improve the user's marimo notebook.

marimo-team/marimo · 57 tokens

adk-style

Python style and codebase conventions for ADK (Agent Development Kit): private-by-default file visibility, imports, type hints, Pydantic v2 models, formatting, docstrings, logging, async I/O, file and test layout, and unit test structure. Use when writing or editing ADK source or tests, deciding whether a new file or…

google/adk-python · 187 tokens

coding

编写并运行 Python 代码,验证脚本逻辑和输出。.

bojieli/ai-agent-book · 18 tokens

ax-python-agent

Use when writing Python code with axllm for agents, child delegation, tools, MCP, citations, persistent playbook learning, stage instructions, runtime state, final typed responses, and direct-respond executor skipping.

ax-llm/ax · 49 tokens