Skip to content

Commit

Permalink
add configs_dir
Browse files Browse the repository at this point in the history
  • Loading branch information
youran-qi committed Oct 30, 2024
1 parent f9c1167 commit ace341e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/cohere_finetune/configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,13 @@ def __init__(self, finetune_name: str) -> None:
self.input_train_dir = os.path.join(self.root_dir, "input/data/training")
self.input_eval_dir = os.path.join(self.root_dir, "input/data/evaluation")

# Finetune: paths of the preprocessed train & eval data and directories of checkpoints, logs, metrics (optional)
# Finetune: paths of the preprocessed train & eval data and directories of checkpoints, logs, configs, metrics (optional)
self.finetune_dir = os.path.join(self.root_dir, "finetune")
self.finetune_train_path = os.path.join(self.finetune_dir, "data/train.csv")
self.finetune_eval_path = os.path.join(self.finetune_dir, "data/eval.csv")
self.checkpoints_dir = os.path.join(self.finetune_dir, "checkpoints")
self.logs_dir = os.path.join(self.finetune_dir, "logs")
self.configs_dir = os.path.join(self.finetune_dir, "configs")
self.metrics_dir = os.path.join(self.finetune_dir, "metrics")

# Output: directories of trained merged weights, trained adapter weights (optional), inference engine (optional)
Expand All @@ -184,10 +185,9 @@ def __init__(self, finetune_name: str) -> None:
super().__init__(finetune_name)

self.finetune_backends_parent_dir = os.path.dirname(__file__)
self.peft_template_parallel_configs_dir = \
f"{self.finetune_backends_parent_dir}/finetune_backends/cohere_peft/template_parallel_configs"
self.peft_parallel_config_dir = \
f"{self.finetune_backends_parent_dir}/finetune_backends/cohere_peft/parallel_config"
self.peft_template_parallel_configs_dir = os.path.join(
self.finetune_backends_parent_dir, "finetune_backends/cohere_peft/template_parallel_configs"
)


def get_path_config(finetune_name: str) -> PathConfig:
Expand Down
8 changes: 4 additions & 4 deletions src/cohere_finetune/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,25 @@ def train_with_peft(path_config: CoherePeftPathConfig, hyperparameters: Hyperpar
use_postprocessed_model = False
config_file_path = create_parallel_config_from_template(
os.path.join(path_config.peft_template_parallel_configs_dir, "fsdp_config.yaml"),
path_config.peft_parallel_config_dir,
path_config.configs_dir,
)
elif hyperparameters.parallel_strategy == "fsdp" and hyperparameters.use_4bit_quantization:
use_postprocessed_model = False
config_file_path = create_parallel_config_from_template(
os.path.join(path_config.peft_template_parallel_configs_dir, "fsdp_qlora_config.yaml"),
path_config.peft_parallel_config_dir,
path_config.configs_dir,
)
elif hyperparameters.parallel_strategy == "deepspeed" and not hyperparameters.use_4bit_quantization:
use_postprocessed_model = True
config_file_path = create_parallel_config_from_template(
os.path.join(path_config.peft_template_parallel_configs_dir, "deepspeed_z3_config.yaml"),
path_config.peft_parallel_config_dir,
path_config.configs_dir,
)
else:
use_postprocessed_model = True
config_file_path = create_parallel_config_from_template(
os.path.join(path_config.peft_template_parallel_configs_dir, "deepspeed_z3_qlora_config.yaml"),
path_config.peft_parallel_config_dir,
path_config.configs_dir,
)
peft_cmd = ["accelerate", "launch", "--config_file", config_file_path]
else:
Expand Down

0 comments on commit ace341e

Please sign in to comment.