Skip to content

Commit 280d4da

Browse files
FindHaometa-codesync[bot]
authored andcommitted
Unify All Launch Indices to 0-based (#211)
Summary: This PR unifies all launch indices across the codebase to use 0-based indexing, making them consistent with Python conventions and the existing 0-based indexing used in the `info` module and `reproduce` command. ## Changes - **`tritonparse/trace_processor.py`**: - Changed `(parsed_json, i + 1)` to `(parsed_json, i)` on line 304 - `launch_index_map` now stores 0-based line indices instead of 1-based - **`website/src/pages/KernelOverview.tsx`**: - Updated comment from "(1-based line numbers)" to "(0-based line numbers)" - Display logic unchanged (already displays raw values) - **`website/src/components/DiffViewer.tsx`**: - Removed `+ 1` conversion when displaying launch ranges - Now displays 0-based launch indices directly - **`website/src/components/StackDiffViewer.tsx`**: - Removed `+ 1` conversion when displaying launch ranges - Now displays 0-based launch indices directly - **`website/src/components/ArgumentViewer.tsx`**: - Removed `+ 1` conversion when displaying launch ranges - Now displays 0-based launch indices directly ## Breaking Change **Website Display**: The website will now display 0-based line numbers and launch indices instead of 1-based. Users viewing launch information will see: - Line numbers starting from 0 instead of 1 - Launch indices starting from 0 instead of 1 ## Rationale - Consistency with Python conventions (0-based indexing) - Alignment with existing codebase (`info` module, `reproduce` command already use 0-based) - Simpler code (no need for +1/-1 conversions) - Better alignment with internal data structures ## Testing Existing tests continue to pass. The change affects display format only, not core functionality. Pull Request resolved: #211 Reviewed By: adamomainz Differential Revision: D88171144 Pulled By: FindHao fbshipit-source-id: ae0ae41aff010140510e63fada02aa89c5634496
1 parent ab34d43 commit 280d4da

File tree

5 files changed

+6
-8
lines changed

5 files changed

+6
-8
lines changed

tritonparse/trace_processor.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,7 @@ def parse_single_file(
300300
elif event_type == "launch":
301301
kernel_hash = parsed_json.get("compilation_metadata", {}).get("hash")
302302
if kernel_hash:
303-
kernels_by_hash[kernel_hash]["launches"].append(
304-
(parsed_json, i + 1)
305-
)
303+
kernels_by_hash[kernel_hash]["launches"].append((parsed_json, i))
306304

307305
# Organize lines for final output, keyed by output file path
308306
all_output_lines = defaultdict(list)

website/src/components/ArgumentViewer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const DistributionCell: React.FC<{ data: any }> = ({ data }) => {
1212
<ul className="list-none m-0 p-0 space-y-1">
1313
{data.values.map((item: any, index: number) => {
1414
const launchRanges = item.launches
15-
.map((r: any) => (r.start === r.end ? `${r.start + 1}` : `${r.start + 1}-${r.end + 1}`))
15+
.map((r: any) => (r.start === r.end ? `${r.start}` : `${r.start}-${r.end}`))
1616
.join(', ');
1717
return (
1818
<li key={index}>

website/src/components/DiffViewer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ const DiffViewer: React.FC<DiffViewerProps> = ({ diffs }) => {
3333
const launchRanges = item.launches
3434
.map((r: any) =>
3535
r.start === r.end
36-
? `${r.start + 1}`
37-
: `${r.start + 1}-${r.end + 1}`
36+
? `${r.start}`
37+
: `${r.start}-${r.end}`
3838
)
3939
.join(", ");
4040
return (

website/src/components/StackDiffViewer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const StackDiffViewer: React.FC<{ stackDiff: any }> = ({ stackDiff }) => {
5757
<div className="space-y-2">
5858
{stackDiff.values.map((item: any, index: number) => {
5959
const launchRanges = item.launches
60-
.map((r: any) => (r.start === r.end ? `${r.start + 1}` : `${r.start + 1}-${r.end + 1}`))
60+
.map((r: any) => (r.start === r.end ? `${r.start}` : `${r.start}-${r.end}`))
6161
.join(", ");
6262

6363
return (

website/src/pages/KernelOverview.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ const KernelOverview: React.FC<KernelOverviewProps> = ({
312312
<h4 className="text-md font-semibold mb-2 text-gray-800">
313313
Launch Locations in Original Trace{" "}
314314
<span className="text-sm font-normal text-gray-500">
315-
(1-based line numbers)
315+
(0-based line numbers)
316316
</span>
317317
</h4>
318318
<div className="font-mono text-sm bg-gray-100 p-2 rounded">

0 commit comments

Comments
 (0)