Fix Reproducer Line Index Bug: 1-based to 0-based Conversion #185
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes a critical bug in the reproducer functionality where the
--lineCLI argument was not properly converted from 1-based user input to 0-based array indexing, causing users to reproduce the wrong kernel launch event.Problem
The reproducer's
--lineparameter was documented as 1-based (where line 1 is the first line), but the implementation was using it directly as a 0-based array index:Before:
tritonparseoss reproduce trace.ndjson --line 1This mismatch meant users were consistently reproducing the wrong kernel launch event.
Root Cause
In
tritonparse/cli.py, the CLI argumentargs.linewas passed directly toreproduce()without conversion:The internal implementation in
ndjson.pyuses 0-based indexing:Changes Made
1. Fixed CLI Conversion (
tritonparse/cli.py)2. Updated Documentation
orchestrator.py: Clarified thatline_indexparameter is "0-based index"ingestion/ndjson.py: Updated docstrings forget_launch_and_compilation_events()andbuild_context_bundle()to specify "0-based index"README.md: Fixed Python API example fromline_index=1toline_index=0with clear commentBehavior After Fix
CLI (1-based for user convenience)
Python API (0-based, Pythonic)
Testing
The fix maintains consistency with existing test code which already uses 0-based indexing:
Impact
--line 1correctly processes the first launch eventFiles Changed
tritonparse/cli.py- Added conversion logictritonparse/reproducer/orchestrator.py- Updated docstringtritonparse/reproducer/ingestion/ndjson.py- Updated docstringsREADME.md- Fixed example code and comments