agentleFS
gjbexgjbex/scientific-computing-skills/skills/scientific-parallel-debugging/SKILL.md

scientific-parallel-debugging

Skill1 starsChanged 6 months agoApache-2.0View on GitHub

Debug parallel scientific-computing and HPC software, especially

The file

Show its rules and text

We split this skill into the rules it gives an agent

20 rules. About 0 are common, 18 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈18

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill when debugging scientific, numerical, or parallel software where failures depend on thread count, rank count, scheduling, …

    line 11
  2. Distinctive:

    Use this skill when:

    line 28
  3. Distinctive:

    Do not use this skill as a substitute for general serial debugging when the bug does not depend on parallel execution.

    line 36
  4. Distinctive:

    When this skill applies:

    line 41
  5. Distinctive:

    Read the repository AGENTS.md first, if present.

    line 43
  6. Distinctive:

    Prefer reproducible minimal cases over large production runs while debugging.

    line 50
  7. Distinctive:

    Start from a known-good serial baseline.

    line 68
  8. Distinctive:

    Prefer deterministic seeds and stable inputs while isolating the issue.

    line 72
  9. Distinctive:

    If the bug disappears under logging or debugging, say so explicitly and treat that as a clue rather than a contradiction.

    line 74
  10. Distinctive:

    Check whether divergence starts at boundaries, reductions, or exchanged data.

    line 80
  11. Distinctive:

    Check for mismatched send/receive patterns, collectives, or barriers.

    line 90
  12. Distinctive:

    Look for code paths where one rank or thread can skip required synchronization.

    line 91
  13. Distinctive:

    Use timeouts, progress logging, or coarse checkpoints to locate the stall.

    line 94
  14. Very specific:

    Check reductions, nowait regions, task dependencies, and loop schedules.

    line 102
  15. Very specific:

    Test whether OMP_NUM_THREADS=1 matches the serial code path.

    line 103
  16. Distinctive:

    Verify message sizes, tags, communicators, and collective participation.

    line 112
  17. Distinctive:

    Check decomposition logic and off-by-one errors at subdomain boundaries.

    line 113
  18. Distinctive:

    Treat rank-dependent file I/O and restart logic as potential correctness hazards, not just infrastructure details.

    line 117
  19. Distinctive:

    Test whether binding, rank mapping, or oversubscription changes the failure.

    line 123
  20. Distinctive:

    When using this skill, briefly note:

    line 154

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Scientific Parallel Debugging

Use this skill when debugging scientific, numerical, or parallel software where failures depend on thread count, rank count, scheduling, communication, or runtime placement rather than purely serial logic.

Repository AGENTS.md instructions take precedence over this skill.

Purpose

Apply a pragmatic default for:

  • isolating parallel-only correctness failures;
  • debugging thread, task, OpenMP, or MPI behavior;
  • separating communication, synchronization, and numerical drift issues;
  • reporting actionable root-cause hypotheses instead of vague nondeterminism.

When To Use

Use this skill when:

  • the bug appears only with multiple threads, tasks, or ranks;
  • serial and parallel results diverge unexpectedly;
  • the program hangs, deadlocks, or stalls under parallel execution;
  • output depends suspiciously on scheduling, affinity, or launch configuration;
  • race conditions, halo exchanges, reductions, or partitioning logic are suspect.

Do not use this skill as a substitute for general serial debugging when the bug does not depend on parallel execution.

Working Approach

When this skill applies:

  1. Read the repository AGENTS.md first, if present.
  2. Reduce the failure to the smallest thread or rank count that still reproduces it.
  3. Compare serial and parallel behavior on the same input.
  4. Change one dimension at a time: threads, ranks, affinity, schedule, or input.
  5. Distinguish crash, hang, wrong answer, and performance-pathology cases.
  6. State what is observed, what is inferred, and what remains unverified.

Prefer reproducible minimal cases over large production runs while debugging.

Common Failure Classes

Look for:

  • data races and unsafely shared state;
  • deadlocks, missed notifications, or mismatched barriers;
  • reduction mistakes and non-associative drift beyond expected roundoff;
  • halo or ghost-cell exchange errors;
  • partitioning and boundary-condition mistakes;
  • rank- or thread-local initialization mismatches;
  • affinity, oversubscription, or placement-induced misbehavior.

Parallel bugs often combine logic, runtime, and numerical effects.

Reproduction Strategy

  • Start from a known-good serial baseline.
  • Reproduce on the smallest input that still exercises the bug.
  • Sweep low thread or rank counts before testing larger scales.
  • Record launch commands and environment variables exactly.
  • Prefer deterministic seeds and stable inputs while isolating the issue.

If the bug disappears under logging or debugging, say so explicitly and treat that as a clue rather than a contradiction.

Wrong-Answer Debugging

  • Compare serial and parallel outputs at multiple granularities.
  • Check whether divergence starts at boundaries, reductions, or exchanged data.
  • Validate invariants such as conservation, positivity, or residual behavior.
  • Distinguish acceptable reduction-order roundoff from real algorithmic drift.
  • Inspect data ownership and update ordering before widening tolerances.

Wrong answers in parallel code are often communication or ownership bugs before they are "just floating-point noise."

Hangs and Deadlocks

  • Check for mismatched send/receive patterns, collectives, or barriers.
  • Look for code paths where one rank or thread can skip required synchronization.
  • Inspect lock acquisition order and nested critical sections.
  • Reduce concurrency to the smallest case that still hangs.
  • Use timeouts, progress logging, or coarse checkpoints to locate the stall.

A hang is usually easier to localize when you first determine which participant stops making forward progress.

OpenMP and Threading Issues

  • Review shared versus private data clauses carefully.
  • Check reductions, nowait regions, task dependencies, and loop schedules.
  • Test whether OMP_NUM_THREADS=1 matches the serial code path.
  • Record OMP_NUM_THREADS, OMP_PROC_BIND, OMP_PLACES, and any runtime affinity settings.
  • Watch for false sharing, oversubscription, and thread-unsafe library calls.

Thread count changes that alter correctness often point to hidden shared state.

MPI and Distributed Issues

  • Verify message sizes, tags, communicators, and collective participation.
  • Check decomposition logic and off-by-one errors at subdomain boundaries.
  • Confirm that all ranks agree on global dimensions and iteration structure.
  • Separate communication bugs from local-kernel bugs by validating local states before and after exchange points.
  • Treat rank-dependent file I/O and restart logic as potential correctness hazards, not just infrastructure details.

Affinity and Runtime Configuration

  • Record launcher arguments, rank counts, thread counts, and placement settings.
  • Test whether binding, rank mapping, or oversubscription changes the failure.
  • Distinguish correctness bugs from performance-sensitive scheduling behavior.
  • Expect shared cluster environments to amplify timing-sensitive issues.

Runtime configuration is part of the bug report, not just execution trivia.

Useful Tools

Useful tools for this skill include:

  • gdb or lldb for process-level debugging;
  • valgrind tools when slowdown is acceptable;
  • compiler sanitizers such as ThreadSanitizer or AddressSanitizer when supported by the toolchain and runtime;
  • MPI launcher options and runtime diagnostics;
  • strategic logging with rank or thread identifiers;
  • perf or profiler support only when a stall or slowdown may hide the bug.

Choose the lightest tool that can confirm or refute the current hypothesis.

Anti-Patterns

  • debugging only at large scale when the bug reproduces at small scale;
  • widening tolerances before checking communication or ownership logic;
  • assuming nondeterminism means the bug is impossible to localize;
  • changing thread and rank counts at the same time during diagnosis;
  • ignoring environment variables and launcher configuration in bug reports;
  • treating a hang as a performance issue without first finding the blocked phase.

Output Expectations

When using this skill, briefly note:

  • what parallel configuration reproduces the issue;
  • whether the failure is a crash, hang, wrong answer, or configuration-sensitive pathology;
  • which thread, rank, reduction, exchange, or synchronization hypotheses were tested;
  • what observations support the leading diagnosis;
  • which uncertainty remains and what next isolation step is most justified.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.