You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Summary:
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.
Pull Request resolved: #38
Test Plan:
```bash
% python -m unittest tests.test_tritonparse.TestTritonparseCUDA.test_complex_kernels -v
test_complex_kernels (tests.test_tritonparse.TestTritonparseCUDA.test_complex_kernels)
A more complex test case involving two distinct Triton kernels, one of which uses autotuning. ... Temporary directory: /tmp/tmp35ksprrc
--- Testing Matmul Kernel (3 launches) ---
WARNING:tritonparse.structured_logging:fn JitFunctionInfo(module='tests.test_tritonparse', name='TestTritonparseCUDA.test_complex_kernels.<locals>.matmul_kernel', jit_function=JITFunction(tests.test_tritonparse:TestTritonparseCUDA.test_complex_kernels.<locals>.matmul_kernel)) launch_metadata is not None: <function add_launch_metadata at 0x7f9a504e05e0>. It will be overridden by tritonparse.
WARNING:tritonparse.structured_logging:fn JitFunctionInfo(module='tests.test_tritonparse', name='TestTritonparseCUDA.test_complex_kernels.<locals>.matmul_kernel', jit_function=JITFunction(tests.test_tritonparse:TestTritonparseCUDA.test_complex_kernels.<locals>.matmul_kernel)) launch_metadata is not None: <function add_launch_metadata at 0x7f9a504e05e0>. It will be overridden by tritonparse.
Matmul Launch 1 (16x16 @ 16x16) done.
Matmul Launch 2 (32x16 @ 16x32) done.
Matmul Launch 3 (16x32 @ 32x16) done.
--- Testing Fused Op Kernel (4 launches) ---
Fused Op Launch 1: scale=1.0, activation=None
Fused Op Launch 2: scale=2.5, activation=None
Fused Op Launch 3: scale=1.0, activation='relu'
WARNING:tritonparse.structured_logging:fn JitFunctionInfo(module='tests.test_tritonparse', name='TestTritonparseCUDA.test_complex_kernels.<locals>.fused_op_kernel', jit_function=JITFunction(tests.test_tritonparse:TestTritonparseCUDA.test_complex_kernels.<locals>.fused_op_kernel)) launch_metadata is not None: <function add_launch_metadata at 0x7f9a504e05e0>. It will be overridden by tritonparse.
Fused Op Launch 4: scale=1.0, activation='relu', different size
All kernels executed.
tritonparse log file list: /tmp/tmpowi_t2et/log_file_list.json
INFO:tritonparse:Copying parsed logs from /tmp/tmpowi_t2et to /tmp/tmp35ksprrc/parsed_output_complex
✓ Generated 1 log files
✓ Generated 2 parsed files
✓ Found 1 .json files and 1 .ndjson.gz files
Checking launch_diff events in dedicated_log_triton_trace_yhao__mapped.ndjson.gz
Line 591: Found launch_diff event (count: 1)
Line 1315: Found launch_diff event (count: 2)
Line 2033: Found launch_diff event (count: 3)
Line 2037: Found launch_diff event (count: 4)
Line 2041: Found launch_diff event (count: 5)
✓ Total launch_diff events found: 5
✓ Verified 5 launch_diff events in parsed output
✓ Cleaned up temporary directory
ok
----------------------------------------------------------------------
Ran 1 test in 8.305s
OK
```
Reviewed By: davidberard98
Differential Revision: D78667083
Pulled By: FindHao
fbshipit-source-id: 8c3b38793fedf1cf40658fca3c3548988b389b6a
0 commit comments