-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: pierre.delaunay <[email protected]>
- Loading branch information
Showing
26 changed files
with
402 additions
and
57 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
|
@@ -47,3 +47,8 @@ dry/ | |
|
||
stderr.txt | ||
stdout.txt | ||
|
||
base/ | ||
|
||
benchmarks/simple | ||
benchmarks/voir |
This file contains 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,4 @@ | ||
tests: | ||
milabench install --config dev.yaml --base base | ||
milabench prepare --config dev.yaml --base base | ||
milabench run --config dev.yaml --base base |
2 changes: 1 addition & 1 deletion
2
benchmarks/_template/README.md → benchmarks/_templates/simple/README.md
This file contains 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
|
||
# {{STEM}} | ||
# Template | ||
|
||
Rewrite this README to explain what the benchmark is! |
This file contains 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
2 changes: 1 addition & 1 deletion
2
benchmarks/_template/dev.yaml → benchmarks/_templates/simple/dev.yaml
This file contains 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
|
||
{{STEM}}: | ||
template: | ||
inherits: _defaults | ||
definition: . | ||
install-variant: unpinned | ||
|
This file contains 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
File renamed without changes.
1 change: 1 addition & 0 deletions
1
benchmarks/_template/requirements.in → benchmarks/_templates/simple/requirements.in
This file contains 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 |
---|---|---|
@@ -1 +1,2 @@ | ||
voir>=0.2.9,<0.3 | ||
torch |
This file contains 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 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,4 @@ | ||
tests: | ||
milabench install --config dev.yaml --base base | ||
milabench prepare --config dev.yaml --base base | ||
milabench run --config dev.yaml --base base |
This file contains 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,4 @@ | ||
|
||
# Template | ||
|
||
Rewrite this README to explain what the benchmark is! |
This file contains 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,42 @@ | ||
from milabench.pack import Package | ||
|
||
|
||
SOURCE_DIR = "src" | ||
REPO_URL = "https://github.com/Delaunay/extern_example.git" | ||
BRANCH = "a524286ab6364bca6729dd6ef4936e175a87c7e4" | ||
|
||
|
||
class Template(Package): | ||
# Requirements file installed by install(). It can be empty or absent. | ||
base_requirements = "requirements.in" | ||
|
||
# The preparation script called by prepare(). It must be executable, | ||
# but it can be any type of script. It can be empty or absent. | ||
prepare_script = "prepare.py" | ||
|
||
# The main script called by run(). It must be a Python file. It has to | ||
# be present. | ||
main_script = f"{SOURCE_DIR}/main.py" | ||
|
||
# You can remove the functions below if you don't need to modify them. | ||
|
||
def make_env(self): | ||
# Return a dict of environment variables for prepare_script and | ||
# main_script. | ||
return super().make_env() | ||
|
||
async def install(self): | ||
await super().install() | ||
|
||
source_destination = self.dirs.code / SOURCE_DIR | ||
if not source_destination.exists(): | ||
source_destination.clone_subtree( | ||
REPO_URL, BRANCH | ||
) | ||
|
||
async def prepare(self): | ||
await super().prepare() # super() call executes prepare_script | ||
|
||
|
||
|
||
__pack__ = Template |
This file contains 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,7 @@ | ||
|
||
template: | ||
inherits: _defaults | ||
definition: . | ||
install-variant: unpinned | ||
plan: | ||
method: per_gpu |
This file contains 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,16 @@ | ||
#!/usr/bin/env python | ||
|
||
import os | ||
|
||
if __name__ == "__main__": | ||
# If you need the whole configuration: | ||
# config = json.loads(os.environ["MILABENCH_CONFIG"]) | ||
|
||
data_directory = os.environ["MILABENCH_DIR_DATA"] | ||
|
||
# Download (or generate) the needed dataset(s). You are responsible | ||
# to check if it has already been properly downloaded or not, and to | ||
# do nothing if it has been. | ||
print("Hello I am doing some data stuff!") | ||
|
||
# If there is nothing to download or generate, just delete this file. |
This file contains 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,2 @@ | ||
voir>=0.2.9,<0.3 | ||
torch |
This file contains 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,69 @@ | ||
from dataclasses import dataclass | ||
|
||
from voir.phase import StopProgram | ||
from voir import configurable | ||
from voir.instruments import dash, early_stop, log | ||
from benchmate.monitor import monitor_monogpu | ||
from benchmate.observer import BenchObserver | ||
|
||
|
||
@dataclass | ||
class Config: | ||
"""voir configuration""" | ||
|
||
# Whether to display the dash or not | ||
dash: bool = False | ||
|
||
# How often to log the rates | ||
interval: str = "1s" | ||
|
||
# Number of rates to skip before logging | ||
skip: int = 5 | ||
|
||
# Number of rates to log before stopping | ||
stop: int = 20 | ||
|
||
# Number of seconds between each gpu poll | ||
gpu_poll: int = 3 | ||
|
||
|
||
@configurable | ||
def instrument_main(ov, options: Config): | ||
yield ov.phases.init | ||
|
||
|
||
yield ov.phases.load_script | ||
|
||
if options.dash: | ||
ov.require(dash) | ||
|
||
ov.require( | ||
log("value", "progress", "rate", "units", "loss", "gpudata", context="task"), | ||
early_stop(n=options.stop, key="rate", task="train"), | ||
monitor_monogpu(poll_interval=options.gpu_poll), | ||
) | ||
|
||
# | ||
# Insert milabench tools | ||
# | ||
observer = BenchObserver( | ||
earlystop=options.stop + options.skip, | ||
batch_size_fn=lambda x: 1 | ||
) | ||
|
||
probe = ov.probe("//my_dataloader_creator() as loader", overridable=True) | ||
probe['loader'].override(observer.loader) | ||
|
||
probe = ov.probe("//my_criterion_creator() as criterion", overridable=True) | ||
probe['criterion'].override(observer.criterion) | ||
|
||
probe = ov.probe("//my_optimizer_creator() as optimizer", overridable=True) | ||
probe['optimizer'].override(observer.optimizer) | ||
|
||
# | ||
# Run the benchmark | ||
# | ||
try: | ||
yield ov.phases.run_script | ||
except StopProgram: | ||
print("early stopped") |
This file contains 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 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 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
Oops, something went wrong.