Skip to content

[BE] Add Complex Kernel Test #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed

Conversation

FindHao
Copy link
Member

@FindHao FindHao commented Jul 20, 2025

This pull request introduces a new, comprehensive test case (tests/test_complex_kernels.py) to validate the trace parsing logic, especially for the recently added launch_diff feature.

Motivation

The existing tests were insufficient to fully validate the parser's ability to handle more realistic scenarios involving multiple, distinct kernels and varied launch parameters within a single run. This test was created to provide a robust, end-to-end validation for the kernel grouping and launch diffing functionalities.

What the Test Does

  1. Defines Two Kernels:

    • matmul_kernel: An autotuned matrix multiplication kernel designed to test the parser's handling of autotuner-generated configurations.
    • fused_op_kernel: A simpler element-wise kernel used to test basic launch parameter variations.
  2. Multiple, Varied Launches:

    • The matmul kernel is launched three times with different input tensor shapes.
    • The fused_op kernel is launched four times with different scalar arguments (scale_factor) and compile-time constants (activation).
  3. End-to-End Parsing:

    • After executing all kernel launches and generating a trace log, the test script calls tritonparse.utils.unified_parse.
    • This ensures that the entire trace, containing multiple compilations (due to autotuning) and multiple launch events, can be processed successfully into the structured, diff-summarized format.

How it Improves Testing

  • Provides a realistic test case that mimics a complex model with multiple custom kernels.
  • Specifically validates that launch events are correctly grouped with their corresponding compilation events, even when interleaved.
  • Acts as a strong regression test for the launch_diff generation, ensuring that parameter variations are correctly identified and summarized.

FindHao added 4 commits July 20, 2025 17:14
Summary:
- Updated `parse_single_trace_content` to only process compilation events, improving efficiency by skipping non-compilation events.
- Enhanced the handling of IR file mappings and bidirectional mappings between different IR types.
- Improved the organization of output lines for final writing, ensuring accurate grouping of compilation and launch events by kernel hash.
- Added new utility functions for flattening and unflattening dictionaries, and for generating launch diffs, enhancing the overall functionality of the module.

These changes aim to streamline the parsing process and improve the clarity and maintainability of the codebase.
Summary:
- Introduced `ArgumentViewer` to display argument distributions and differences in a structured format.
- Added `DiffViewer` to handle and present differing fields, integrating `ArgumentViewer` for extracted arguments.
- Created `StackDiffViewer` to visualize stack traces with collapsible sections for better user experience.
- Updated `KernelOverview` to incorporate the new components for enhanced launch analysis and metadata display.
- Enhanced `dataLoader` to support launch_diff events, improving kernel data processing.

These changes aim to improve the visualization and analysis of kernel launch data, enhancing the overall functionality of the application.
Summary:
- Added comments for clarity, including a note for the dropdown arrow icon in both `ArgumentViewer` and `StackDiffViewer`.
- Updated the `renderSimpleDiff` function in `DiffViewer` to use a more descriptive parameter name.

These changes improve code readability and maintainability across the components.
Summary:
- Introduced a new test file `test_complex_kernels.py` to validate the functionality of two distinct Triton kernels: an autotuned matrix multiplication kernel and a fused element-wise operation kernel.
- Implemented a comprehensive test plan that includes multiple launches with varied parameters for both kernels, ensuring thorough testing of their performance and correctness.
- Enhanced logging capabilities during the tests to facilitate debugging and analysis of kernel launches.

These changes aim to improve the testing framework for Triton kernels, ensuring robust validation of their functionality and performance.
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 20, 2025
@FindHao FindHao changed the title Add Complex Kernel Test [BE] Add Complex Kernel Test Jul 20, 2025
@facebook-github-bot
Copy link
Contributor

@FindHao has imported this pull request. If you are a Meta employee, you can view this in D78667083.

@facebook-github-bot
Copy link
Contributor

@FindHao merged this pull request in a87f472.

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. Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants