Skip to content

[Autotuner] Add crash recovery bash script for unrecoverable CUDA errors#1921

Closed
yf225 wants to merge 1 commit intoyf225/stack/90from
yf225/stack/91
Closed

[Autotuner] Add crash recovery bash script for unrecoverable CUDA errors#1921
yf225 wants to merge 1 commit intoyf225/stack/90from
yf225/stack/91

Conversation

@yf225
Copy link
Copy Markdown
Contributor

@yf225 yf225 commented Apr 2, 2026

Stacked PRs:


[Autotuner] Add crash recovery bash script for unrecoverable CUDA errors

Add scripts/autotune_with_crash_recovery.sh — a bash wrapper that
automatically recovers from CUDA errors (illegal memory access,
misaligned address, etc.) that poison the GPU context and kill the
autotuning process.

How it works:

  • Before each benchmark, the autotuner writes the current config to a
    pending file (_pending_config.txt) in the checkpoint directory
  • If a CUDA error kills the process, the pending file survives on disk
  • The bash script detects it, appends the poison config to
    _bad_configs.txt, and re-launches the command from scratch
  • On re-launch, the autotuner loads its checkpoint + bad configs list,
    skips the poison config, and continues searching

Usage:
scripts/autotune_with_crash_recovery.sh
--checkpoint-dir /tmp/ckpt -- python train.py

yf225 added a commit that referenced this pull request Apr 2, 2026
…ning

Run the entire autotuner in a spawned subprocess. When the subprocess
crashes due to an unrecoverable CUDA error (illegal memory access,
misaligned address, etc.), the parent detects the crash, records the
poison config in a _bad_configs.txt file, and respawns a new child that
resumes from the latest checkpoint while skipping the bad config.

Key components:
- New settings: autotune_auto_recover_from_cuda_error (env var
  HELION_AUTOTUNE_AUTO_RECOVER_FROM_CUDA_ERROR) and
  autotune_subprocess_max_attempts (env var
  HELION_AUTOTUNE_SUBPROCESS_MAX_ATTEMPTS, default 10)
- subprocess_runner.py: spawn-based subprocess worker, parent monitor
  loop with bounded retries, _pending_config.txt/_bad_configs.txt file I/O
- Worker catches only TritonUnrecoverableRuntimeError (exits without
  writing result so parent recovers via pending file); other exceptions
  propagate naturally with traceback visible in stderr
- benchmark_function() writes _pending_config.txt before each benchmark
  and clears it after; the file is only left behind on process crash
- Bad config tracking uses Config.__str__() (sorted keys, deterministic)
  as the canonical config identity
- Parent raises immediately on non-CUDA crashes (no pending file) and
  after exceeding max_attempts on CUDA crashes

Requires autotune_checkpoint_dir to be set. The kernel function must be
in an importable module (not __main__).

stack-info: PR: #1921, branch: yf225/stack/91
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Apr 2, 2026
yf225 added a commit that referenced this pull request Apr 2, 2026
…ning

Run the entire autotuner in a spawned subprocess. When the subprocess
crashes due to an unrecoverable CUDA error (illegal memory access,
misaligned address, etc.), the parent detects the crash, records the
poison config in a _bad_configs.txt file, and respawns a new child that
resumes from the latest checkpoint while skipping the bad config.

Key components:
- New settings: autotune_auto_recover_from_cuda_error (env var
  HELION_AUTOTUNE_AUTO_RECOVER_FROM_CUDA_ERROR) and
  autotune_subprocess_max_attempts (env var
  HELION_AUTOTUNE_SUBPROCESS_MAX_ATTEMPTS, default 10)
- subprocess_runner.py: spawn-based subprocess worker, parent monitor
  loop with bounded retries, _pending_config.txt/_bad_configs.txt file I/O
- Worker catches only TritonUnrecoverableRuntimeError (exits without
  writing result so parent recovers via pending file); other exceptions
  propagate naturally with traceback visible in stderr
- benchmark_function() writes _pending_config.txt before each benchmark
  and clears it after; the file is only left behind on process crash
- Bad config tracking uses Config.__str__() (sorted keys, deterministic)
  as the canonical config identity
- Parent raises immediately on non-CUDA crashes (no pending file) and
  after exceeding max_attempts on CUDA crashes

Requires autotune_checkpoint_dir to be set. The kernel function must be
in an importable module (not __main__).

stack-info: PR: #1921, branch: yf225/stack/91
@yf225 yf225 changed the title [Autotuner] Auto-recover from unrecoverable CUDA errors during autotuning [Autotuner] Add crash recovery bash script for unrecoverable CUDA errors Apr 2, 2026
yf225 added a commit that referenced this pull request Apr 2, 2026
Add scripts/autotune_with_crash_recovery.sh — a bash wrapper that
automatically recovers from CUDA errors (illegal memory access,
misaligned address, etc.) that poison the GPU context and kill the
autotuning process.

How it works:
- Before each benchmark, the autotuner writes the current config to a
  pending file (_pending_config.txt) in the checkpoint directory
- If a CUDA error kills the process, the pending file survives on disk
- The bash script detects it, appends the poison config to
  _bad_configs.txt, and re-launches the command from scratch
- On re-launch, the autotuner loads its checkpoint + bad configs list,
  skips the poison config, and continues searching

Usage:
  scripts/autotune_with_crash_recovery.sh \
      --checkpoint-dir /tmp/ckpt -- python train.py

stack-info: PR: #1921, branch: yf225/stack/91
@yf225 yf225 changed the base branch from yf225/stack/90 to main April 2, 2026 06:21
@yf225 yf225 changed the base branch from main to yf225/stack/90 April 2, 2026 06:21
yf225 added a commit that referenced this pull request Apr 2, 2026
Add scripts/autotune_with_crash_recovery.sh — a bash wrapper that
automatically recovers from CUDA errors (illegal memory access,
misaligned address, etc.) that poison the GPU context and kill the
autotuning process.

How it works:
- Before each benchmark, the autotuner writes the current config to a
  pending file (_pending_config.txt) in the checkpoint directory
- If a CUDA error kills the process, the pending file survives on disk
- The bash script detects it, appends the poison config to
  _bad_configs.txt, and re-launches the command from scratch
- On re-launch, the autotuner loads its checkpoint + bad configs list,
  skips the poison config, and continues searching

Usage:
  scripts/autotune_with_crash_recovery.sh \
      --checkpoint-dir /tmp/ckpt -- python train.py

stack-info: PR: #1921, branch: yf225/stack/91
yf225 added a commit that referenced this pull request Apr 2, 2026
Add scripts/autotune_with_crash_recovery.sh — a bash wrapper that
automatically recovers from CUDA errors (illegal memory access,
misaligned address, etc.) that poison the GPU context and kill the
autotuning process.

How it works:
- Before each benchmark, the autotuner writes the current config to a
  pending file (_pending_config.txt) in the checkpoint directory
- If a CUDA error kills the process, the pending file survives on disk
- The bash script detects it, appends the poison config to
  _bad_configs.txt, and re-launches the command from scratch
- On re-launch, the autotuner loads its checkpoint + bad configs list,
  skips the poison config, and continues searching

Usage:
  scripts/autotune_with_crash_recovery.sh \
      --checkpoint-dir /tmp/ckpt -- python train.py

stack-info: PR: #1921, branch: yf225/stack/91
yf225 added a commit that referenced this pull request Apr 2, 2026
Add scripts/autotune_with_crash_recovery.sh — a bash wrapper that
automatically recovers from CUDA errors (illegal memory access,
misaligned address, etc.) that poison the GPU context and kill the
autotuning process.

How it works:
- Before each benchmark, the autotuner writes the current config to a
  pending file (_pending_config.txt) in the checkpoint directory
- If a CUDA error kills the process, the pending file survives on disk
- The bash script detects it, appends the poison config to
  _bad_configs.txt, and re-launches the command from scratch
- On re-launch, the autotuner loads its checkpoint + bad configs list,
  skips the poison config, and continues searching

Usage:
  scripts/autotune_with_crash_recovery.sh \
      --checkpoint-dir /tmp/ckpt -- python train.py

stack-info: PR: #1921, branch: yf225/stack/91
yf225 added a commit that referenced this pull request Apr 2, 2026
Add scripts/autotune_with_crash_recovery.sh — a bash wrapper that
automatically recovers from CUDA errors (illegal memory access,
misaligned address, etc.) that poison the GPU context and kill the
autotuning process.

How it works:
- Before each benchmark, the autotuner writes the current config to a
  pending file (_pending_config.txt) in the checkpoint directory
- If a CUDA error kills the process, the pending file survives on disk
- The bash script detects it, appends the poison config to
  _bad_configs.txt, and re-launches the command from scratch
- On re-launch, the autotuner loads its checkpoint + bad configs list,
  skips the poison config, and continues searching

Usage:
  scripts/autotune_with_crash_recovery.sh \
      --checkpoint-dir /tmp/ckpt -- python train.py

stack-info: PR: #1921, branch: yf225/stack/91
@yf225 yf225 changed the base branch from yf225/stack/90 to main April 2, 2026 06:59
@yf225 yf225 changed the base branch from main to yf225/stack/90 April 2, 2026 06:59
yf225 added a commit that referenced this pull request Apr 2, 2026
Add scripts/autotune_with_crash_recovery.sh — a bash wrapper that
automatically recovers from CUDA errors (illegal memory access,
misaligned address, etc.) that poison the GPU context and kill the
autotuning process.

How it works:
- Before each benchmark, the autotuner writes the current config to a
  pending file (_pending_config.txt) in the checkpoint directory
- If a CUDA error kills the process, the pending file survives on disk
- The bash script detects it, appends the poison config to
  _bad_configs.txt, and re-launches the command from scratch
- On re-launch, the autotuner loads its checkpoint + bad configs list,
  skips the poison config, and continues searching

Usage:
  scripts/autotune_with_crash_recovery.sh \
      --checkpoint-dir /tmp/ckpt -- python train.py

stack-info: PR: #1921, branch: yf225/stack/91
yf225 added a commit that referenced this pull request Apr 2, 2026
Add scripts/autotune_with_crash_recovery.sh — a bash wrapper that
automatically recovers from CUDA errors (illegal memory access,
misaligned address, etc.) that poison the GPU context and kill the
autotuning process.

How it works:
- Before each benchmark, the autotuner writes the current config to a
  pending file (_pending_config.txt) in the checkpoint directory
- If a CUDA error kills the process, the pending file survives on disk
- The bash script detects it, appends the poison config to
  _bad_configs.txt, and re-launches the command from scratch
- On re-launch, the autotuner loads its checkpoint + bad configs list,
  skips the poison config, and continues searching

Usage:
  scripts/autotune_with_crash_recovery.sh \
      --checkpoint-dir /tmp/ckpt -- python train.py

stack-info: PR: #1921, branch: yf225/stack/91
yf225 added a commit that referenced this pull request Apr 2, 2026
Add scripts/autotune_with_crash_recovery.sh — a bash wrapper that
automatically recovers from CUDA errors (illegal memory access,
misaligned address, etc.) that poison the GPU context and kill the
autotuning process.

How it works:
- Before each benchmark, the autotuner writes the current config to a
  pending file (_pending_config.txt) in the checkpoint directory
- If a CUDA error kills the process, the pending file survives on disk
- The bash script detects it, appends the poison config to
  _bad_configs.txt, and re-launches the command from scratch
- On re-launch, the autotuner loads its checkpoint + bad configs list,
  skips the poison config, and continues searching

Usage:
  scripts/autotune_with_crash_recovery.sh \
      --checkpoint-dir /tmp/ckpt -- python train.py

stack-info: PR: #1921, branch: yf225/stack/91
yf225 added a commit that referenced this pull request Apr 2, 2026
Add scripts/autotune_with_crash_recovery.sh — a bash wrapper that
automatically recovers from CUDA errors (illegal memory access,
misaligned address, etc.) that poison the GPU context and kill the
autotuning process.

How it works:
- Before each benchmark, the autotuner writes the current config to a
  pending file (_pending_config.txt) in the checkpoint directory
- If a CUDA error kills the process, the pending file survives on disk
- The bash script detects it, appends the poison config to
  _bad_configs.txt, and re-launches the command from scratch
- On re-launch, the autotuner loads its checkpoint + bad configs list,
  skips the poison config, and continues searching

Usage:
  scripts/autotune_with_crash_recovery.sh \
      --checkpoint-dir /tmp/ckpt -- python train.py

stack-info: PR: #1921, branch: yf225/stack/91
@yf225 yf225 changed the base branch from yf225/stack/90 to main April 2, 2026 07:25
@yf225 yf225 changed the base branch from main to yf225/stack/90 April 2, 2026 07:25
Add scripts/autotune_with_crash_recovery.sh — a bash wrapper that
automatically recovers from CUDA errors (illegal memory access,
misaligned address, etc.) that poison the GPU context and kill the
autotuning process.

How it works:
- Before each benchmark, the autotuner writes the current config to a
  pending file (_pending_config.txt) in the checkpoint directory
- If a CUDA error kills the process, the pending file survives on disk
- The bash script detects it, appends the poison config to
  _bad_configs.txt, and re-launches the command from scratch
- On re-launch, the autotuner loads its checkpoint + bad configs list,
  skips the poison config, and continues searching

Usage:
  scripts/autotune_with_crash_recovery.sh \
      --checkpoint-dir /tmp/ckpt -- python train.py

stack-info: PR: #1921, branch: yf225/stack/91
@yf225 yf225 changed the base branch from yf225/stack/90 to main April 2, 2026 07:30
@yf225 yf225 changed the base branch from main to yf225/stack/90 April 2, 2026 07:30
@yf225 yf225 closed this Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant