Skip to content

[HIP] [OPUS] [JIT] fix(jit): baton liveness is undecidable from pid+host under --network host - #5269

Open
ThomasNing wants to merge 20 commits into
ROCm:mainfrom
ThomasNing:thomas/baton-liveness-across-pid-namespaces
Open

[HIP] [OPUS] [JIT] fix(jit): baton liveness is undecidable from pid+host under --network host#5269
ThomasNing wants to merge 20 commits into
ROCm:mainfrom
ThomasNing:thomas/baton-liveness-across-pid-namespaces

Conversation

@ThomasNing

Copy link
Copy Markdown
Contributor

Fixes #5266.

The bug

FileBaton records its holder as pid + hostname. A container started with docker run --network host — the normal way to run a tuner — reports the host's hostname while keeping its own PID namespace, and every container has a pid 1 and low worker pids (100-104).

So when a tuner container is killed mid-build, the next container reads the leaked lock, sees a matching hostname, checks os.kill(103, 0), finds its own worker at pid 103, and concludes the dead holder is alive. Its workers then wait forever:

[pid=101 pname=SpawnPoolWorker-1] waiting for baton release at
    .../lock_module_gemm_a8w8_bpreshuffle_cktile_tune

With a host-mounted build cache the leak survives container restarts, so the wedge is permanent until someone deletes the file by hand. "Delete the lock files first" became a required step in our tuning runbook.

The fix

Record the PID namespace (/proc/self/ns/pid) and the holder's start time (/proc/<pid>/stat field 22) alongside pid and host:

holder decision
same namespace pid alive and start time matches → live. This also closes the pid-reuse hole on any host.
other namespace the pid is meaningless here, so decide on a heartbeat: the holder touches the lock every heartbeat_seconds while it works; a lock untouched for heartbeat_stale_seconds (default 60 s) is stale.
different host unchanged — never steal.

Locks written by an older AITER carry two lines; they parse with empty ns/start-time and keep exactly the previous behaviour.

Checked

Self-held lock never looks stale · foreign-namespace holder with a live local pid is respected while heartbeating and goes stale when it stops · recycled pid caught via start time · dead pid · legacy 2-line locks (live and dead) · 0-byte orphan grace unchanged · wait() returns False after breaking a stale lock · heartbeat observed touching the file.

Same campaign as #5262 / #5268 / #5263#5265.

🤖 Generated with Claude Code

… host

FileBaton records the holder as pid + hostname. A container started with
--network host reports the HOST's hostname while keeping its own PID
namespace, and every container has a pid 1 and low worker pids (100-104). So
when a tuner container is killed mid-build, the next container reads the leaked
lock, sees a matching hostname, checks os.kill(103, 0) -- finds its OWN worker
at pid 103 -- and concludes the dead holder is alive. Its workers then wait
forever:

  [pid=101 pname=SpawnPoolWorker-1] waiting for baton release at
      .../lock_module_gemm_a8w8_bpreshuffle_cktile_tune

With a host-mounted build cache the leak survives container restarts, so the
wedge is permanent until someone deletes the file by hand. We lost hours to
this before finding it, and 'delete the lock files' became a required step in
our tuning runbook.

Record the PID namespace (/proc/self/ns/pid) and the holder's start time
(/proc/<pid>/stat field 22) alongside pid and host:

  * same namespace  -> pid liveness AND start time must match, which also
                       closes the pid-reuse hole on any host;
  * other namespace -> the pid is meaningless here, so decide on the holder's
                       heartbeat: the holder now touches the lock every
                       heartbeat_seconds while it works, and a lock untouched
                       for heartbeat_stale_seconds (default 60s) is stale.

Locks written by an older AITER carry two lines; they parse with empty ns and
start time and keep exactly the previous behaviour.

Checked: self-held lock never looks stale; foreign-namespace holder with a live
local pid is respected while heartbeating and goes stale when it stops;
recycled pid detected via start time; dead pid; legacy 2-line locks both live
and dead; 0-byte orphan grace unchanged; wait() returns False after breaking a
stale lock; heartbeat observed to touch the file.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ThomasNing
ThomasNing requested a review from a team September 3, 2026 23:56
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-04T21:08:39.981675Z bcccec6 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter op tests (gfx942 + gfx950)
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs; main branch always runs both MI35X and MI300X
multigpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 5269 --add-label <label>

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to opt this PR out.

@github-actions github-actions Bot changed the title fix(jit): baton liveness is undecidable from pid+host under --network host [JIT] fix(jit): baton liveness is undecidable from pid+host under --network host Sep 3, 2026
@github-actions github-actions Bot added the JIT label Sep 3, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 13c88607f7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread aiter/jit/utils/file_baton.py Outdated
@ThomasNing

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8508b6de91

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread aiter/jit/utils/file_baton.py Outdated
Comment thread aiter/jit/utils/file_baton.py Outdated
@github-actions github-actions Bot changed the title [JIT] fix(jit): baton liveness is undecidable from pid+host under --network host [HIP] [OPUS] [JIT] fix(jit): baton liveness is undecidable from pid+host under --network host Sep 4, 2026
@ThomasNing

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

try:
os.remove(self.lock_file_path)

P1 Badge Preserve the replacement lock when an expired holder resumes

If a foreign-namespace holder is paused or otherwise misses heartbeats for more than 60 seconds, a waiter can legitimately classify its lease as stale and replace the lock; when the original process resumes, this unconditional pathname removal deletes the new holder's lock rather than its own unlinked file. That exposes the replacement build to additional concurrent builders and possible artifact corruption. Before unlinking, verify that the path still identifies this instance's lock (for example, by comparing it with the still-open descriptor or an ownership token).

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ThomasNing

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 92e813185f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread aiter/jit/utils/file_baton.py Outdated
@ThomasNing

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8d7a802e66

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread aiter/jit/utils/file_baton.py Outdated
@ThomasNing

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 01ca846e14

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread aiter/jit/utils/file_baton.py Outdated
@ThomasNing

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 077336737c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread aiter/jit/utils/file_baton.py Outdated
@ThomasNing

Copy link
Copy Markdown
Contributor Author

@codex review

@ThomasNing

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fba58ebe82

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread aiter/jit/utils/file_baton.py Outdated
@ThomasNing

Copy link
Copy Markdown
Contributor Author

@codex review

@ThomasNing

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b7fe959b84

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread aiter/jit/utils/file_baton.py
@ThomasNing

Copy link
Copy Markdown
Contributor Author

@codex review

@ThomasNing

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a8d5a3a21b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread aiter/jit/utils/file_baton.py Outdated
@ThomasNing

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 195309bb26

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread aiter/jit/utils/file_baton.py
Comment thread aiter/jit/utils/file_baton.py
@ThomasNing

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fdc7f4ca8c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread aiter/jit/utils/file_baton.py Outdated
@ThomasNing

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bdfd08a1fe

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread aiter/jit/utils/file_baton.py Outdated
@ThomasNing

Copy link
Copy Markdown
Contributor Author

@codex review

@ThomasNing

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fde5d07a69

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread aiter/jit/utils/file_baton.py Outdated
@ThomasNing

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: bcccec6b77

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@zufayu
zufayu requested a review from yzhou103 September 4, 2026 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JIT baton dead-holder check is ambiguous under --network host (pid + hostname collide across containers)

1 participant