-
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.
- Loading branch information
pierre.delaunay
committed
Sep 5, 2024
1 parent
ea44ea6
commit e5505ee
Showing
9 changed files
with
196 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from milabench.pack import Package | ||
from milabench.commands import AccelerateAllNodes | ||
|
||
|
||
class Llava(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 = "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() # super() call installs the requirements | ||
|
||
async def prepare(self): | ||
await super().prepare() # super() call executes prepare_script | ||
|
||
def build_run_plan(self): | ||
from milabench.commands import PackCommand | ||
|
||
main = self.dirs.code / self.main_script | ||
plan = PackCommand(self, *self.argv, lazy=True) | ||
|
||
if False: | ||
plan = VoirCommand(plan, cwd=main.parent) | ||
|
||
return AccelerateAllNodes(plan).use_stdout() | ||
|
||
|
||
__pack__ = Llava |
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,22 @@ | ||
#!/usr/bin/env python | ||
|
||
import torch | ||
from datasets import load_dataset | ||
from transformers import AutoProcessor, LlavaForConditionalGeneration | ||
|
||
|
||
def main(): | ||
# Load LLaVA model and processor with device_map="auto" | ||
_ = LlavaForConditionalGeneration.from_pretrained( | ||
"llava-hf/llava-1.5-7b-hf", | ||
torch_dtype=torch.float32, # Change to float32 | ||
device_map="auto", | ||
) | ||
_ = AutoProcessor.from_pretrained("llava-hf/llava-1.5-7b-hf") | ||
|
||
# Load dataset and create DataLoader | ||
_ = load_dataset("HuggingFaceM4/the_cauldron", "aokvqa")["train"] | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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 @@ | ||
voir>=0.2.19,<0.3 | ||
torch | ||
numpy | ||
accelerate | ||
pillow | ||
datasets | ||
transformers |
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,38 @@ | ||
from dataclasses import dataclass | ||
|
||
from voir import configurable | ||
from voir.instruments import dash, early_stop, log, rate | ||
from benchmate.monitor import monitor_monogpu | ||
|
||
@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 | ||
|
||
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), | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
"""This file is generated, do not modify""" | ||
|
||
__tag__ = "v0.1.0-28-g8069946" | ||
__commit__ = "8069946d331fb92090057d7eedd598515249521d" | ||
__date__ = "2024-08-01 12:39:13 -0400" | ||
|
||
__tag__ = "v0.1.0-82-gea44ea63" | ||
__commit__ = "ea44ea63be161bea2dd22c6dd23b1386474f09a7" | ||
__date__ = "2024-09-05 12:03:19 -0400" |
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