Skip to content

Commit

Permalink
[Core] Use Pythonic Config (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
anmolagarwalcp810 authored Jul 28, 2024
1 parent 2bb7a08 commit 60277c0
Show file tree
Hide file tree
Showing 82 changed files with 2,142 additions and 1,236 deletions.
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"cSpell.words": [
"INTERNLM",
"QWEN",
"vidur"
]
}
4 changes: 0 additions & 4 deletions data/device_configs/a100.yml

This file was deleted.

3 changes: 0 additions & 3 deletions data/device_configs/a40.yml

This file was deleted.

3 changes: 0 additions & 3 deletions data/device_configs/h100.yml

This file was deleted.

15 changes: 0 additions & 15 deletions data/model_configs/Qwen/Qwen-72B.yml

This file was deleted.

16 changes: 0 additions & 16 deletions data/model_configs/codellama/CodeLlama-34b-Instruct-hf.yml

This file was deleted.

15 changes: 0 additions & 15 deletions data/model_configs/internlm/internlm-20b.yml

This file was deleted.

15 changes: 0 additions & 15 deletions data/model_configs/internlm/internlm2-20b.yml

This file was deleted.

16 changes: 0 additions & 16 deletions data/model_configs/meta-llama/Llama-2-70b-hf.yml

This file was deleted.

16 changes: 0 additions & 16 deletions data/model_configs/meta-llama/Llama-2-7b-hf.yml

This file was deleted.

16 changes: 0 additions & 16 deletions data/model_configs/meta-llama/Meta-Llama-3-70B.yml

This file was deleted.

16 changes: 0 additions & 16 deletions data/model_configs/meta-llama/Meta-Llama-3-8B.yml

This file was deleted.

17 changes: 0 additions & 17 deletions data/model_configs/microsoft/phi-2.yml

This file was deleted.

7 changes: 0 additions & 7 deletions data/model_configs/openai/gpt3.yml

This file was deleted.

8 changes: 0 additions & 8 deletions data/model_configs/tiiuae/falcon-180B.yml

This file was deleted.

4 changes: 1 addition & 3 deletions vidur/config/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
from vidur.config.config import Config

__all__ = [Config]
from .config import *
30 changes: 30 additions & 0 deletions vidur/config/base_fixed_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from abc import ABC
from dataclasses import dataclass
from typing import Any

from vidur.config.utils import get_all_subclasses


@dataclass
class BaseFixedConfig(ABC):

@classmethod
def create_from_type(cls, type_: Any) -> Any:
for subclass in get_all_subclasses(cls):
if subclass.get_type() == type_:
return subclass()
raise ValueError(f"[{cls.__name__}] Invalid type: {type_}")

@classmethod
def create_from_name(cls, name: str) -> Any:
for subclass in get_all_subclasses(cls):
if subclass.get_name() == name:
return subclass()
raise ValueError(f"[{cls.__name__}] Invalid name: {name}")

@classmethod
def create_from_type_string(cls, type_str: str) -> Any:
for subclass in get_all_subclasses(cls):
if str(subclass.get_type()) == type_str:
return subclass()
raise ValueError(f"[{cls.__name__}] Invalid type string: {type_str}")
16 changes: 16 additions & 0 deletions vidur/config/base_poly_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from abc import ABC
from dataclasses import dataclass
from typing import Any

from vidur.config.utils import get_all_subclasses


@dataclass
class BasePolyConfig(ABC):

@classmethod
def create_from_type(cls, type_: Any) -> Any:
for subclass in get_all_subclasses(cls):
if subclass.get_type() == type_:
return subclass()
raise ValueError(f"Invalid type: {type_}")
Loading

0 comments on commit 60277c0

Please sign in to comment.