Skip to content

Conversation

@januszjah
Copy link
Contributor

Solution for #5110

@januszjah
Copy link
Contributor Author

Need to find a clean way to use __assert_fail in tritongen to llvm pass instead of llvm trap.

@januszjah januszjah force-pushed the dev/januszja/block-hw-checks branch 2 times, most recently from 6cf28c1 to 19da69b Compare October 10, 2025 09:37
@januszjah januszjah marked this pull request as ready for review October 10, 2025 09:40
@januszjah januszjah force-pushed the dev/januszja/block-hw-checks branch 3 times, most recently from e15c893 to b549ca9 Compare October 13, 2025 11:57
@januszjah januszjah requested review from Copilot, etiotto and whitneywhtsang and removed request for Copilot and etiotto October 13, 2025 11:58
@januszjah januszjah linked an issue Oct 13, 2025 that may be closed by this pull request
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements runtime hardware checks for 2D block operations in the Intel backend by adding runtime assertion validation that verifies parameter constraints when the TRITON_INTEL_2DBLOCK_ASSERT environment variable is set.

Key changes include:

  • Added LibCallEmitter utility class for generating library calls including printf and assert_fail functions
  • Integrated runtime validation into 2D block load/store/prefetch operations with parameter constraint checking
  • Added comprehensive test coverage for the new assertion functionality

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
third_party/intel/lib/Utils/LibCallEmitter.h New header defining LibCallEmitter class for library call generation
third_party/intel/lib/Utils/LibCallEmitter.cpp Implementation of LibCallEmitter with printf and assertFail methods
third_party/intel/lib/Utils/CMakeLists.txt Added LibCallEmitter.cpp to build configuration
third_party/intel/lib/TritonIntelGPUToLLVM/TargetInfo.h Updated to use LibCallEmitter instead of inline globals
third_party/intel/lib/TritonIntelGPUToLLVM/TargetInfo.cpp Refactored to delegate library calls to LibCallEmitter
third_party/intel/lib/TritonGENToLLVM/TritonGENToLLVMPass.cpp Added 2D block parameter validation with runtime checks
third_party/intel/include/TritonGENToLLVM/TritonGENToLLVMPass.h Updated function signature to accept LibCallEmitter
test/TritonGEN/tritongen-2Dblockload-to-llvm-asserts.mlir MLIR test verifying assert generation based on environment variable
python/test/unit/intel/test_block_load.py Python test ensuring assertions trigger on invalid parameters
python/test/unit/intel/block_load_helper.py Helper script for running assertion tests
include/triton/Tools/Sys/GetEnv.hpp Added TRITON_INTEL_2DBLOCK_ASSERT to cache-invalidating environment variables

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@januszjah januszjah force-pushed the dev/januszja/block-hw-checks branch 3 times, most recently from 780edb8 to feaabc0 Compare October 14, 2025 11:16
torch.testing.assert_close(result_tri, result_tor, atol=1e-2, rtol=1e-3)


@pytest.mark.parametrize("elem_size, width, height, pitch, x",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Runtime checks to see if asserts actually work.


} // namespace

//===----------------------------------------------------------------------===//
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed it because it seems to be unused and otherwise I'd have to somehow handle lifecycle of calls emitter in populate* method.

Copy link
Contributor

@whitneywhtsang whitneywhtsang left a comment

Choose a reason for hiding this comment

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

Can you try to enable the env var temporarily to see if there is any unexpected failures in our testing?

@januszjah januszjah force-pushed the dev/januszja/block-hw-checks branch from feaabc0 to ad80e6e Compare October 16, 2025 03:26
@januszjah
Copy link
Contributor Author

Can you try to enable the env var temporarily to see if there is any unexpected failures in our testing?

Yes, just added a commit that removes the check.

@januszjah januszjah force-pushed the dev/januszja/block-hw-checks branch 4 times, most recently from 5809361 to 0dede8e Compare October 16, 2025 08:20
@januszjah
Copy link
Contributor Author

@whitneywhtsang When I enabled it for all CI tests it failed in some minicore tests. I'd prefer to resolve it in follow-up issue and I also made a failing PR for reference: #5326

@januszjah januszjah force-pushed the dev/januszja/block-hw-checks branch from 0dede8e to 8d0d554 Compare October 16, 2025 10:03
Copy link
Contributor

@etiotto etiotto left a comment

Choose a reason for hiding this comment

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

nice!

@etiotto etiotto enabled auto-merge (squash) October 16, 2025 19:03
@etiotto etiotto merged commit 4911e1d into main Oct 16, 2025
23 checks passed
@etiotto etiotto deleted the dev/januszja/block-hw-checks branch October 16, 2025 19:18
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.

Create runtime verifications for 2d block IO HW restrictions

5 participants