-
Notifications
You must be signed in to change notification settings - Fork 410
[Autotuner] CI Smoke Test - Resume #2097
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
Merged
vvbandeira
merged 13 commits into
The-OpenROAD-Project:master
from
luarss:autotuner_ci_level_4
Jan 15, 2025
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
6a49817
scaffold for resume smoke test
luarss bd83523
some helpers
luarss 43913d0
fix bug for multiple iterations
luarss bbf85d3
remove date to ensure args.resume work
luarss 9441f69
working test for args resume
luarss 6f3dd19
check in robustify test
luarss 1bead2c
remove unneeded files
luarss e59097a
fix lint
luarss 55d5018
remove resources per trial
luarss bb0e6d4
fix black
luarss 8b81f80
update test_autotuner.sh
luarss b7058ea
fix test helper scripts
luarss ae488eb
remove unstable tests
luarss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| import unittest | ||
| import subprocess | ||
| import os | ||
| import time | ||
|
|
||
| from contextlib import contextmanager | ||
|
|
||
| cur_dir = os.path.dirname(os.path.abspath(__file__)) | ||
| src_dir = os.path.join(cur_dir, "../src/autotuner") | ||
| orfs_dir = os.path.join(cur_dir, "../../../flow") | ||
| os.chdir(src_dir) | ||
|
|
||
|
|
||
| @contextmanager | ||
| def managed_process(*args, **kwargs): | ||
| """ | ||
| Runs process and ensures it is killed when the context is exited. | ||
| """ | ||
| proc = subprocess.Popen(*args, **kwargs) | ||
| try: | ||
| yield proc | ||
| finally: | ||
| if proc.poll() is None: # If the process is still running | ||
| proc.kill() # Forcefully kill it | ||
|
|
||
|
|
||
| class ResumeCheck(unittest.TestCase): | ||
| # only test 1 platform/design. | ||
| platform = "asap7" | ||
| design = "gcd" | ||
| samples = 5 | ||
| iterations = 2 | ||
|
|
||
| def setUp(self): | ||
| self.config = os.path.join( | ||
| orfs_dir, "designs", self.platform, self.design, "autotuner.json" | ||
| ) | ||
| self.jobs = self.samples | ||
| self.num_cpus = os.cpu_count() | ||
|
|
||
| # How it works: Say we have 5 samples and 5 iterations. | ||
| # If we want to limit to only 5 trials (and avoid any parallelism magic by Ray) | ||
| # We can set resources_per_trial = NUM_CORES/5 = 3.2 (fractional resources_per_trial are allowed!) | ||
|
|
||
| # Cast to 1 decimal place | ||
| res_per_trial = float("{:.1f}".format(self.num_cpus / self.samples)) | ||
| options = ["", "--resume"] | ||
| self.commands = [ | ||
| f"python3 distributed.py" | ||
| f" --design {self.design}" | ||
| f" --platform {self.platform}" | ||
| f" --config {self.config}" | ||
| f" --jobs {self.jobs}" | ||
| f" --experiment test_resume" | ||
| f" tune --iterations {self.iterations} --samples {self.samples}" | ||
| f" --resources_per_trial {res_per_trial}" | ||
| f" {c}" | ||
| for c in options | ||
| ] | ||
|
|
||
| def test_tune_resume(self): | ||
| # Goal is to first run the first config (without resume) and then run the second config (with resume) | ||
| # and check if the run is able to complete. | ||
|
|
||
| # Run the first config asynchronously. | ||
| print("Running the first config") | ||
| with managed_process(self.commands[0], shell=True) as proc: | ||
| time.sleep(120) | ||
|
|
||
| # Keep trying to stop the ray cluster until it is stopped | ||
| while 1: | ||
| proc = subprocess.run("ray status", shell=True) | ||
| no_nodes = proc.returncode != 0 | ||
| proc = subprocess.run("ray stop", shell=True) | ||
| successful = proc.returncode == 0 | ||
|
|
||
| if no_nodes and successful: | ||
| break | ||
| time.sleep(10) | ||
|
|
||
| # Run the second config to completion | ||
| print("Running the second config") | ||
| proc = subprocess.run(self.commands[1], shell=True) | ||
| successful = proc.returncode == 0 | ||
| self.assertTrue(successful) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.