Skip to content

Commit

Permalink
create HF repo once, outside try/except
Browse files Browse the repository at this point in the history
  • Loading branch information
jettjaniak committed May 24, 2024
1 parent f154b81 commit c18682e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 5 additions & 3 deletions delphi/train/training.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from pathlib import Path

import torch
from huggingface_hub import HfApi
from tqdm import tqdm
from transformers import AutoTokenizer

Expand All @@ -27,14 +28,15 @@ def setup_training(config: TrainingConfig):
logging.info("Setting up training...")
os.makedirs(config.out_dir, exist_ok=True)

# torch misc - TODO: check if this is actually needed
torch.backends.cuda.matmul.allow_tf32 = True # allow tf32 on matmul
torch.backends.cudnn.allow_tf32 = True # allow tf32 on cudnn

# determinism
setup_determinism(config.torch_seed)

# wandb setup
if config.out_repo:
api = HfApi()
api.create_repo(config.out_repo, exist_ok=True)

if config.wandb:
init_wandb(config)

Expand Down
2 changes: 0 additions & 2 deletions delphi/train/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

from .config import TrainingConfig
from .run_context import RunContext
from .shuffle import shuffle_list


@dataclass
Expand Down Expand Up @@ -228,7 +227,6 @@ def save_results(
if config.out_repo:
try:
api = HfApi()
api.create_repo(config.out_repo, exist_ok=True)
api.create_branch(config.out_repo, branch=iter_name, exist_ok=True)
api.upload_folder(
folder_path=results_path,
Expand Down

0 comments on commit c18682e

Please sign in to comment.