Skip to content

Commit 74f92ee

Browse files
committed
Basic evaluate CLI command / codepath (#2188)
* basic evaluate CLI command / codepath * tests for evaluate CLI command * fixes and cleanup * review comments; slightly DRYing up things --------- Co-authored-by: Dan Saunders <danjsaund@gmail.com>
1 parent 307cf7c commit 74f92ee

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

outputs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/workspace/data/axolotl-artifacts

src/axolotl/train.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from axolotl.utils.dict import DictDefault
2727
from axolotl.utils.freeze import freeze_layers_except
2828
from axolotl.utils.models import load_model, load_processor, load_tokenizer
29-
from axolotl.utils.trainer import setup_trainer
29+
from axolotl.utils.trainer import set_pytorch_cuda_alloc_conf, setup_trainer
3030

3131
try:
3232
from optimum.bettertransformer import BetterTransformer

src/axolotl/utils/trainer.py

+11
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,17 @@ def prepare_opinionated_env(cfg):
512512
os.environ["TOKENIZERS_PARALLELISM"] = "false"
513513

514514

515+
def set_pytorch_cuda_alloc_conf():
516+
"""Set up CUDA allocation config if using PyTorch >= 2.2"""
517+
torch_version = torch.__version__.split(".")
518+
torch_major, torch_minor = int(torch_version[0]), int(torch_version[1])
519+
if torch_major == 2 and torch_minor >= 2:
520+
if os.getenv("PYTORCH_CUDA_ALLOC_CONF") is None:
521+
os.environ[
522+
"PYTORCH_CUDA_ALLOC_CONF"
523+
] = "expandable_segments:True,roundup_power2_divisions:16"
524+
525+
515526
def setup_trainer(
516527
cfg, train_dataset, eval_dataset, model, tokenizer, processor, total_num_steps
517528
):

0 commit comments

Comments
 (0)