Commit 3b40ee8
Summary:
This PR adds support for reproducing kernel launches by kernel name and launch ID, eliminating the need to manually find line numbers in trace files.
## Changes
- **`reproducer/cli.py`**:
- Added `--kernel` argument (str, default=None)
- Added `--launch-id` argument (int, default=0, 0-based)
- Updated `--line` help text to indicate mutual exclusivity
- **`reproducer/orchestrator.py`**:
- Extended `reproduce()` function signature:
- `line_index: int` (required, maintains backward compatibility)
- `out_dir: str` (required, no default value)
- `template: str` (required, no default value)
- `kernel_name: Optional[str] = None` (new, placed after required params)
- `launch_id: int = 0` (new)
- Implemented kernel lookup logic: if `kernel_name` is provided, uses `find_launch_index_by_kernel()` to find the actual `line_index`
- Updated docstring to document support for `.ndjson`, `.ndjson.gz`, and `.bin.ndjson` formats
- **`cli.py`**:
- Added mutual exclusivity check: error if both `--kernel` and `--line` (non-zero) are provided
- Updated `reproduce()` call to pass new parameters using unified calling pattern
- **`tests/test_tritonparse.py`**:
- Added helper methods to `TestTritonparseCPU` class:
- `_get_test_ndjson_file()`: Get test file path
- `setup_temp_reproduce_dir()`: Create temporary directory
- `cleanup_temp_reproduce_dir()`: Cleanup temporary directory
- Added 5 unit tests:
- `test_reproduce_mutual_exclusivity()`: Test parameter mutual exclusivity
- `test_reproduce_kernel_default_launch_id()`: Test default launch_id
- `test_reproduce_kernel_launch_id()`: End-to-end integration test
- `test_reproduce_kernel_not_found()`: Test error handling
- `test_reproduce_launch_id_out_of_range()`: Test boundary conditions
- Refactored tests to use helper methods, following `TestTritonparseCUDA` pattern
- Added imports at module level: `Path` and `tritonparse.reproducer.orchestrator`
## Usage
```bash
# Existing: use line number (0-based)
tritonparseoss reproduce trace.ndjson --line 4
# NEW: use kernel name + launch id (0-based)
tritonparseoss reproduce trace.ndjson --kernel matmul_kernel --launch-id 2
# Also works with .ndjson.gz and .bin.ndjson files
tritonparseoss reproduce trace.ndjson.gz --kernel matmul_kernel --launch-id 0
```
## Testing
Tests use real data from `tests/example_output/parsed_output_complex/dedicated_log_triton_trace_findhao__mapped.ndjson.gz` when possible, mock data for edge cases.
## Notes
- All indices are 0-based for consistency with Python conventions
- Kernel name matching is case-sensitive (exact match only)
- Backward compatible: existing `--line` usage continues to work
- Error messages include helpful hints (valid range, similar kernel suggestions)
Pull Request resolved: #209
Reviewed By: wychi
Differential Revision: D88171118
Pulled By: FindHao
fbshipit-source-id: 3f82ddd3ee3d5298acabede98ca689ae233d2f6f
1 parent f2b3a7b commit 3b40ee8
File tree
4 files changed
+183
-5
lines changed- tests
- tritonparse
- reproducer
4 files changed
+183
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| |||
138 | 140 | | |
139 | 141 | | |
140 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
141 | 163 | | |
142 | 164 | | |
143 | 165 | | |
| |||
482 | 504 | | |
483 | 505 | | |
484 | 506 | | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
485 | 617 | | |
486 | 618 | | |
487 | 619 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
71 | 75 | | |
72 | 76 | | |
73 | 77 | | |
| |||
77 | 81 | | |
78 | 82 | | |
79 | 83 | | |
80 | | - | |
| 84 | + | |
81 | 85 | | |
82 | 86 | | |
| 87 | + | |
| 88 | + | |
83 | 89 | | |
84 | 90 | | |
85 | 91 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
18 | 37 | | |
19 | 38 | | |
20 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| 24 | + | |
| 25 | + | |
23 | 26 | | |
24 | 27 | | |
25 | 28 | | |
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
29 | 36 | | |
30 | | - | |
31 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
32 | 40 | | |
33 | 41 | | |
| 42 | + | |
| 43 | + | |
34 | 44 | | |
35 | 45 | | |
36 | 46 | | |
37 | | - | |
38 | 47 | | |
39 | 48 | | |
40 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
41 | 62 | | |
42 | 63 | | |
43 | 64 | | |
| |||
0 commit comments