-
Notifications
You must be signed in to change notification settings - Fork 7
#8 - Add support for multiple metrics in @nsight.analyze.kernel #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#8 - Add support for multiple metrics in @nsight.analyze.kernel #9
Conversation
|
@Alok-Joshi Hi Alok, could we set up basic CI (lint/build documentation) to run automatically on push? Since fixing lint errors often requires multiple attempts. |
That is unfortunately not possible due to organisation policy. You can run the lint, doc-build locally to verify the fixing of issues - hatch run lint:check # To run lint
hatch run docs:build # To build docs |
f08074f to
893166d
Compare
|
Added missing Signed-off-by signatures for all commits. |
|
/ok to test 0fcf91c |
|
@ConvolutedDog the dataframe with multiple metrics looks like this -
For every
|
|
@ConvolutedDog As you have filled #12 and #11, the TODOs you have added in the code can be removed. |
|
OK, I'll add a transformation it and delete the TODOs. |
|
@ConvolutedDog Can you please merge the main branch of upstream into this feature branch? We have added tests in the CI |
OK. |
This commit fixes the data aggregation issue when specifying comma-separated metrics in the @nsight.analyze.kernel decorator. Users can now collect multiple related metrics in a single profiling run, which is essential for performance analysis. For example, comparing both load and store operations (smsp__sass_inst_executed_op_shared_ld.sum and smsp__sass_inst_executed_op_shared_st.sum) in one run is much more convenient than running separate profiling sessions for each metric. Instead of needing separate profiling sessions for each metric: @nsight.analyze.kernel(runs=1, metric=smsp__sass_inst_executed_op_shared_ld.sum) def profile1(...): ... @nsight.analyze.kernel(runs=1, metric=smsp__sass_inst_executed_op_shared_st.sum) def profile2(...): ... All metrics can now be specified with comma separation: @nsight.analyze.kernel(runs=1, metric=smsp__sass_inst_executed_op_shared_ld.sum,smsp__sass_inst_executed_op_shared_st.sum) def profile1(...): ... Key changes: - Support comma-separated metric specification in @nsight.analyze.kernel - Merge results into unified DataFrame with 'Metric' column - Add example demonstrating shared memory load/store profiling - Add validation to prevent @plot usage with multiple metrics - Extend data aggregation to handle multiple metric DataFrames Signed-off-by: ConvolutedDog <[email protected]>
This commit introduces significant improvements to the nsight-python API, particularly around metrics collection and data handling: 1. Multiple Metrics Support: - Changed `metric` parameter to `metrics` (now accepts sequence of strings) - Updated all examples/tests to use `metrics=["metric1", "metric2"]` format - Modified `derive_metric` to `derive_metrics` for consistency 2. Enhanced Data Aggregation: - Improved `_value_aggregator` factory function with better data aggragation - Added support for np.array for multiple metrics in aggregation 3. Plotting Improvements: - Enhanced `_validate_metric()` to check for complex data structures - Better error messages when plotting multiple metrics - Support for scalar-only visualization 4. New Examples: - Added `09_advanced_metric_custom.py`: Custom metrics from multiple metrics - Added `10_combine_kernel_metrics.py`: Combining metrics from multiple kernels - Added `11_output_csv.py`: CSV output control example 5. API Consistency: - Updated documentation and examples to reflect new parameter names - Better handling of edge cases in data transformation - `metric` parameter renamed to `metrics` (now accepts list) - `derive_metric` parameter renamed to `derive_metrics` - Multiple metrics now stored as tuples in DataFrame - Modified: `.gitignore`, docs, examples, README - Added: examples/09*, examples/10*, examples/11* - Modified core modules: `analyze.py`, `collection/core.py`, `collection/ncu.py`, `exceptions.py`, `extraction.py`, `transformation.py`, `utils.py` - Updated tests to reflect API changes This update provides more flexible metrics collection while maintaining backward compatibility for single-metric use cases. Signed-off-by: ConvolutedDog <[email protected]>
Signed-off-by: ConvolutedDog <[email protected]>
Signed-off-by: ConvolutedDog <[email protected]>
Signed-off-by: ConvolutedDog <[email protected]>
- Add _explode_dataframe() to flatten metric columns into rows - Fix metric error message formatting Signed-off-by: ConvolutedDog <[email protected]>
0fcf91c to
7c778cb
Compare
|
@Alok-Joshi @bastianhagedorn Could you please review the latest commit? |
Signed-off-by: ConvolutedDog <[email protected]>
Signed-off-by: ConvolutedDog <[email protected]>
nsight/collection/core.py
Outdated
|
|
||
| return wrapper | ||
|
|
||
| def _explode_dataframe(self, df: pd.DataFrame) -> pd.DataFrame: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function should be part of the nsight/extraction.py module, and should be called in the extract_df_from_report function. If the raw_df is exploded once, we will not have to explode the processed df. The nsight/transformation.py module can work with the exploded raw df instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've refactored the code.
And also fix a bug:
nsight-python/nsight/transformation.py
Lines 146 to 147 in 64f60bf
| # Normalize the AvgValue by the values of the normalization annotation | |
| agg_df["AvgValue"] = agg_df["NormalizationValue"] / agg_df["AvgValue"] |
Changed to:
agg_df["AvgValue"] = agg_df["AvgValue"] / agg_df["NormalizationValue"]|
Can you please extend the |
…ization From agg_df["AvgValue"] = agg_df["AvgValue"] / agg_df["NormalizationValue"] To agg_df["AvgValue"] = agg_df["NormalizationValue"] / agg_df["AvgValue"] Signed-off-by: ConvolutedDog <[email protected]>
Signed-off-by: ConvolutedDog <[email protected]>
Done. Add the test_parameter_normalize_against_multiple_metrics to handle multiple metrics scenarios. |
|
Overall this change looks good to me. Only thing remaining is -
|
Signed-off-by: ConvolutedDog <[email protected]>
Signed-off-by: ConvolutedDog <[email protected]>
|
/ok to test 481ca2b |
Signed-off-by: ConvolutedDog <[email protected]>
|
/ok to test f32cc7b |
|
@Alok-Joshi Please rerun the CI. |
|
@Alok-Joshi I'm a bit confused about this CI error (https://github.com/NVIDIA/nsight-python/actions/runs/20237826873/job/58097206975#step:5:1698). Could it be because many |
The triton example is failing because of the following error - Not sure about the error; do not really have a root cause, but it can be ignored as it seems unrelated to your change. I re-ran the CI job and now it passes. Also the intermediate |
Signed-off-by: ConvolutedDog <[email protected]>
bastianhagedorn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for your efforts
|
/ok to test 64df1e6 |
|
Merging. Thanks @ConvolutedDog ! |


Support multiple metrics and improve data aggregation
Intro
This commit introduces significant improvements to the nsight-python API, particularly around metrics collection and data handling.
Users can now collect multiple related metrics in a single profiling run, which is essential for performance analysis. For example, comparing both load and store operations (
smsp__sass_inst_executed_op_shared_ld.sumandsmsp__sass_inst_executed_op_shared_st.sum) in one run is much more convenient than running separate profiling sessions for each metric.Instead of needing separate profiling sessions for each metric:
All metrics can now be specified with a sequence of metric names:
Key Changes:
Multiple Metrics Support:
metricparameter tometrics(now accepts a sequence of strings)metrics=["metric1", "metric2"]formatEnhanced Data Aggregation:
_value_aggregatorfactory function with better data aggragationPlotting Improvements:
_validate_metric()to check for complex data structuresNew Examples:
09_advanced_metric_custom.py: Custom metrics from multiple metrics10_combine_kernel_metrics.py: Combining metrics from multiple kernels11_output_csv.py: CSV output control exampleAPI Consistency:
Breaking Changes:
metricparameter renamed tometrics(now accepts list)Files Updated:
.gitignore, docs, examples, READMEexamples/09*,examples/10*,examples/11*analyze.py,collection/core.py,collection/ncu.py,exceptions.py,extraction.py,transformation.py,utils.pyThis update provides more flexible metrics collection while maintaining backward compatibility for single-metric use cases.
Signed-off-by: ConvolutedDog [email protected]