Skip to content

[CONSAN] Model ConSan mbarrier expect semantics#9958

Merged
pawelszczerbuk merged 3 commits into
mainfrom
consan_expect
Apr 8, 2026
Merged

[CONSAN] Model ConSan mbarrier expect semantics#9958
pawelszczerbuk merged 3 commits into
mainfrom
consan_expect

Conversation

@lezcano
Copy link
Copy Markdown
Contributor

@lezcano lezcano commented Apr 8, 2026

We do so by following the PTX docs and our LLVM lowerings

  1. In PTX, a barrier flips when both arrivals == 0 and tx-count == 0
  2. In PTX, an expect implies a commit of 1.
  3. In triton, we lower ttng.expect as an expect on the leader CTA and as a commit of 1

We model all these points in consan.

We do so by following the PTX docs and our LLVM lowerings
1. In PTX, a barrier flips when both `arrivals == 0` and `tx-count == 0`
2. In PTX, an expect implies a commit of 1.
3. In triton, we lower `ttng.expect` as an expect on the leader CTA and as a commit of 1

We model all these points in consan.
Copy link
Copy Markdown

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

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: fb2364b4f9

ℹ️ 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 lib/Dialect/TritonInstrument/Transforms/ConcurrencySanitizer.cpp Outdated
result = run_in_process(test_async_tma_expect_bytes_mismatch,
(EXPECT_DELTA, device, False, monkeypatch, num_ctas))
assert_expected_cuda_failure(result.exc)
assert "Deadlock detected" in result.driver_stderr_output
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why do we expect deadlock in the case of "under"? We should end up with negative tx-count, right? Should this be flagged as an error rather than causing a deadlock on wait?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So, this is a bit of a techinicality, but it's correct as-is.
The issue is that expect increments tx-count and complete-tx decrements it. The tx-count is defined to be in the range (-220, 220), and things are well defined there. I agree it's a weird program to first complete and then expect, but it's legal in theory...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ah, got it! Thanks for the explanation!

@pawelszczerbuk pawelszczerbuk merged commit beee355 into main Apr 8, 2026
9 checks passed
@pawelszczerbuk pawelszczerbuk deleted the consan_expect branch April 8, 2026 20:07
plognjen pushed a commit to plognjen/triton that referenced this pull request Apr 14, 2026
We do so by following the PTX docs and our LLVM lowerings
1. In PTX, a barrier flips when both `arrivals == 0` and `tx-count == 0`
2. In PTX, an expect implies a commit of 1.
3. In triton, we lower `ttng.expect` as an expect on the leader CTA and
as a commit of 1

We model all these points in consan.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants