Skip to content

Conversation

mirza-halilcevic
Copy link
Contributor

Motivation

Refactor of tuningRunner.py so that the winning configs are immediately written to the output file instead of waiting for the entire tuning process to finish, so we avoid situations where a crash forces us to start all over.

Technical Details

Code changes to the tuningRunner.py script to implement said functionality.

Resolves https://github.com/ROCm/rocMLIR-internal/issues/2017

Test Plan

Manually tested.

Test Result

Tuning results persist after the process is interrupted.

Submission Checklist


winners, allData = tuneMLIRKernels(configs, confClass, paths, options)

if winners is None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was a weird check, maybe we should still check len(entries ) > 0 inside tuneMLIRKernels()?

Copy link
Member

@umangyadav umangyadav Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should keep this check if winner is none inside tuneMLIRKernels.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In your opinion, should we abort the entire loop in case this happens, or just continue with the rest of the configs? Same goes for when verification fails?

Copy link
Member

@umangyadav umangyadav Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it is possible to continue with rest of tuning and print error message about config that is failing to pick any winning perfConfig. That would be better IMO

if options.tflops:
winners[testVector] = (winningConfig,maxTFlops)
if not headerWritten:
print(f"# arch\tnumCUs\ttestVector\tperfConfig\tTFlops ({options.tuningSpaceKind})", file=outFile)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to create list out of header columns and then do pd.DataFrame.to_csv(sep='\t)` instead of directly putting print inside the file itself.

if not headerWritten:
print(f"# arch\tnumCUs\ttestVector\tperfConfig\tTFlops ({options.tuningSpaceKind})", file=outFile)
headerWritten = True
print(f"{options.arch}\t{options.numCU}\t{testVector}\t{winningConfig}\t{maxTFlops}", file=outFile)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to create list and use pd.DataFrame.to_csv here too.

@umangyadav umangyadav requested a review from Copilot October 10, 2025 13:15
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the tuning process to write winning configurations to the output file immediately after each test vector is tuned, rather than waiting for the entire tuning process to complete. This prevents loss of tuning results if the process crashes or is interrupted.

  • Modified tuneMLIRKernels to accept output file handles and write results immediately
  • Changed getWinningConfig to return collected entries instead of appending to a global list
  • Restructured main function to open files upfront and use try/finally for proper cleanup

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants