Skip to content
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

[Autotuner] Plotting utility + test #2394

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

luarss
Copy link
Contributor

@luarss luarss commented Sep 29, 2024

  • Plotting utility
  • README

@luarss luarss requested a review from vvbandeira September 29, 2024 05:16
@luarss luarss self-assigned this Oct 8, 2024
@luarss luarss added the autotuner Flow autotuner label Oct 8, 2024
docs/user/InstructionsForAutoTuner.md Outdated Show resolved Hide resolved
tools/AutoTuner/src/autotuner/utils/plot.py Outdated Show resolved Hide resolved
Copy link
Member

@vvbandeira vvbandeira left a comment

Choose a reason for hiding this comment

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

Please add a call to this script in the test_helper.py so we test this script.

@luarss luarss changed the title [Autotuner] Plotting utility [Autotuner] Plotting utility + test Oct 11, 2024
@luarss luarss requested a review from vvbandeira October 11, 2024 14:58
@luarss luarss marked this pull request as draft October 16, 2024 09:30
@luarss luarss marked this pull request as ready for review October 17, 2024 00:35
@luarss luarss marked this pull request as draft January 10, 2025 17:36
@luarss luarss marked this pull request as ready for review January 11, 2025 12:55
flow/test/test_autotuner.sh Outdated Show resolved Hide resolved
Comment on lines 31 to 57
except Exception as e:
print(f"Error in {fname}: {e}")
continue
Copy link
Member

Choose a reason for hiding this comment

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

Should we keep a list of the files that were not processed so we can print them at the very end in order for the error not to be buried in the logs? And should the script fail silently in this case?

Copy link
Contributor Author

@luarss luarss Jan 11, 2025

Choose a reason for hiding this comment

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

And should the script fail silently in this case?

Just to clarify, this exception happens when any Autotuner run does not proceed to the "finish" stage, it does not fail silently

Should we keep a list of the files that were not processed so we can print them at the very end in order for the error not to be buried in the logs?

Sure I can add that.

Comment on lines 72 to 73
z = np.polyfit(df["timestamp"], df[key], 1)
p = np.poly1d(z)
Copy link
Member

Choose a reason for hiding this comment

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

z I assume is the z-axis; what is p?

Copy link
Contributor Author

@luarss luarss Jan 11, 2025

Choose a reason for hiding this comment

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

z is the np array of polynomial (ax+b) coefficients, and p is the actual polynomial function.

Copy link
Member

Choose a reason for hiding this comment

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

Then let's use more descriptive names, maybe:
z --> coeff
p --> poly_func

plt.boxplot(df[key])
plt.ylabel(key)
plt.title(f"{key} Boxplot")
plt.savefig(f"images/{key}-boxplot.png")
Copy link
Member

Choose a reason for hiding this comment

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

Let's also parametrize the output folder to save images from CI into the reports folder for the design. This way it will be automatically saved to the build artifacts.

@luarss luarss requested a review from vvbandeira January 12, 2025 14:19
Comment on lines +39 to +34
--platform ${PLATFORM} \
--design ${DESIGN_NAME} \
Copy link
Member

Choose a reason for hiding this comment

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

At the beginning of this script, you are casting these values to be uppercase, which does not match the path since Linux is case-sensitive. From the CI:

02:32:36  Running Autotuner plotting smoke test
02:32:36  ls: cannot access './flow/logs/SKY130HD/gcd/*/': No such file or directory
02:32:36  No experiments found for plotting
02:32:36  + exit 0

Copy link
Member

Choose a reason for hiding this comment

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

If we call the plot script and do not find data to plot, this should be an error, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, these are 2 separate errors, will fix them.

@luarss luarss requested a review from vvbandeira January 14, 2025 02:44
@@ -20,28 +22,23 @@ python3 -m unittest tools.AutoTuner.test.smoke_test_sweep.${PLATFORM}SweepSmokeT
echo "Running Autotuner smoke tests for --sample and --iteration."
python3 -m unittest tools.AutoTuner.test.smoke_test_sample_iteration.${PLATFORM}SampleIterationSmokeTest.test_sample_iteration

if [ "$PLATFORM" == "asap7" ] && [ "$DESIGN" == "gcd" ]; then
if [ "$PLATFORM" == "asap7" ] && [ "$DESIGN_NAME" == "gcd" ]; then
Copy link
Member

Choose a reason for hiding this comment

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

The first check will never be true because you are casting to uppercase on line 14.
Would it be simpler/easier if we just use the platform name everywhere and just remove the dashes if that is not supported by the unittest Python lib?

Copy link
Contributor Author

@luarss luarss Jan 16, 2025

Choose a reason for hiding this comment

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

The main concern is that I prefer name of smoke tests to be capitalized. We could also do something like asap7SampleIterationSmokeTest, but might be less readable

Perhaps a UPPERCASE_PLATFORM would make the distinction clearer?

Copy link
Member

Choose a reason for hiding this comment

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

Modifying PLATFORM or another variable already in use somewhere else in the code can easily lead to confusion. Other options could be PLATFORM_UT where UT is 'under test' or TEST_PLATFORM. That said, I don't see any issue with asap7SampleIterationSmokeTest.

Comment on lines 33 to 34
echo "No experiments found for plotting"
exit 0
Copy link
Member

Choose a reason for hiding this comment

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

This is still exiting with a success code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is returning 0 because I didn't want to error out for smoke tests that are not suitable for plotting. I will modify it to only run plot.py for valid smoke tests then.

Copy link
Member

Choose a reason for hiding this comment

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

We could then change line 31 to list either manually the tests we want or use a better regex in the experiment names to differentiate whether the plot is available or not.

tools/AutoTuner/src/autotuner/utils/plot.py Outdated Show resolved Hide resolved
tools/AutoTuner/src/autotuner/utils/plot.py Outdated Show resolved Hide resolved
tools/AutoTuner/src/autotuner/utils/plot.py Outdated Show resolved Hide resolved
- run plot.py for all log files in the autotuner supported design/platforms
- parameterised img_dir, so we can store all AT image runs in build artifacts
- argparse interface now takes in platform, design, experiment for easier usage
- chdir before running plot.py
- add docstrings
- more error handling

Signed-off-by: Jack Luar <[email protected]>
Signed-off-by: Jack Luar <[email protected]>
Signed-off-by: Jack Luar <[email protected]>
Signed-off-by: Jack Luar <[email protected]>
Signed-off-by: Jack Luar <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autotuner Flow autotuner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants