[Feature] Add launch_diff event #36
Closed
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.
This pull request introduces a major enhancement to the trace parsing functionality. Instead of treating each event in isolation, it now intelligently groups compilation and launch events by kernel. The key feature is the generation of a
launch_diff
event, which provides a concise summary of how different launches of the same kernel vary in their parameters. This is extremely useful for debugging, as it highlights what changes between calls. The changes instructured_logging.py
support this by ensuring that all necessary metadata is correctly serialized.Detailed Changes
triton_trace/parser.py
parse_single_trace_content
: The logic is now wrapped in a check forentry.get("event_type") == "compilation"
. This ensures that parsing logic for IR files and source mappings only runs for compilation events.parse_single_file
:compilation
andlaunch
events.compilation
events and their associatedlaunch
events are grouped under a kernel hash.launch_diff
event is generated for each kernel, summarizing the differences and similarities between all its launch events. This helps in understanding how kernel launches vary.frame_id
andframe_compile_id
, similar to before, but the content is now more structured._flatten_dict
,_unflatten_dict
: Utilities to handle nested dictionaries._to_ranges
: Converts a list of indices into a list of continuous ranges, used for summarizing which launches share a particular parameter value._generate_launch_diff
: The core of the new diffing logic. It compares a list of launch events and produces a summary of common and differing parameters. It also has special handling forextracted_args
to provide detailed diffs for kernel arguments.tritonparse/structured_logging.py
convert
: Added special handling fornamedtuple
to convert it to a dictionary, ensuring field names are preserved during JSON serialization.add_launch_metadata
: Themetadata
object (which is anamedtuple
) is now converted to a dictionary using_asdict()
before being returned.LaunchHookImpl.post_launch
: The key for the compilation metadata in the trace data has been changed from"metadata"
to"compilation_metadata"
.