Skip to content

Conversation

@FindHao
Copy link
Member

@FindHao FindHao commented Dec 2, 2025

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.

- Support .ndjson.gz (gzip compressed) files
- Support .bin.ndjson (gzip member concatenation) files
- Add _is_gzip_file() helper function
- Add test using existing .ndjson.gz test file
- Create tritonparse/info/ module with kernel_query.py
- Implement list_kernels() to list all kernels with launch counts
- Implement find_launch_index_by_kernel() to find launch events by kernel name and launch ID
- Add KernelSummary and LaunchInfo dataclasses
- Add 6 unit tests in TestTritonparseCPU class
- Tests use real data from example_output when possible, mock data otherwise

This is PR3 from the design doc, providing the foundation for PR4 (reproduce --kernel/--launch-id).
- Moved the import of `find_launch_index_by_kernel` to the correct location in `tritonparse/info/__init__.py`.
- Removed an unnecessary empty line in `tritonparse/info/kernel_query.py`.

This change improves code organization and maintains clarity in the module's interface.
- Add --kernel and --launch-id CLI arguments to reproducer
- Add mutual exclusivity check between --line and --kernel/--launch-id
- Extend reproduce() function to support kernel name lookup
- Use find_launch_index_by_kernel() from info module to find launch events
- Add 5 unit tests for new functionality
- Refactor tests to use helper methods following TestTritonparseCUDA pattern
- Update docstring to document support for .ndjson, .ndjson.gz, and .bin.ndjson formats

This is PR4 from the design doc, enabling users to reproduce kernels by name
and launch ID instead of manually finding line numbers.
- Add info subcommand to query kernel information from trace files
- Implement list_kernels_fast() using launch_diff events for optimization
- Implement list_launches_for_kernel() to list all launches for a kernel
- Implement find_similar_kernels() for fuzzy matching suggestions
- Add parse_and_compress_raw_log() helper to auto-parse raw logs
- Auto-detect raw logs and parse them automatically with compression
- Add 4 comprehensive tests (1 unit test + 3 integration tests)
- Reuse parse module's gzip compression functionality

This is PR5 from the design doc, enabling users to query kernel
information without manually parsing trace files.
- Change trace_processor.py to store 0-based line indices in launch_index_map
- Update website components to display 0-based indices (remove +1 conversions)
- Update KernelOverview.tsx comment from '1-based' to '0-based'
- Update DiffViewer.tsx, StackDiffViewer.tsx, ArgumentViewer.tsx to show 0-based launch indices

This makes all launch indices consistent with Python conventions and the
existing 0-based indexing used in the info module and reproduce command.

Breaking change: Website will now display 0-based line numbers and launch
indices instead of 1-based.
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Dec 2, 2025
@FindHao FindHao marked this pull request as ready for review December 2, 2025 17:08
@meta-codesync
Copy link

meta-codesync bot commented Dec 2, 2025

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

@meta-codesync
Copy link

meta-codesync bot commented Dec 3, 2025

@FindHao merged this pull request in 280d4da.

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.

3 participants