text stringlengths 1 1.02k | class_index int64 0 10.8k | source stringlengths 85 188 |
|---|---|---|
ignore_data_skip: bool = field(
default=False,
metadata={
"help": (
"When resuming training, whether or not to skip the first epochs and batches to get to the same"
" training data."
)
},
)
fsdp: Optional[Union[List[FSDPOption], str... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
metadata={
"help": (
"This parameter is deprecated. FSDP's minimum number of parameters for Default Auto Wrapping. (useful"
" only when `fsdp` field is passed)."
)
},
)
fsdp_config: Optional[Union[dict, str]] = field(
default=None,
... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
accelerator_config: Optional[Union[dict, str]] = field(
default=None,
metadata={
"help": (
"Config to be used with the internal Accelerator object initializtion. The value is either a "
"accelerator json config file (e.g., `accelerator_config.json`) or an alre... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
default_optim = "adamw_torch"
# XXX: enable when pytorch==2.0.1 comes out - we want to give it time to get all the bugs sorted out
# if is_torch_available() and version.parse(version.parse(torch.__version__).base_version) >= version.parse("2.1.0"):
# default_optim = "adamw_torch_fused"
# and update ... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
length_column_name: Optional[str] = field(
default="length",
metadata={"help": "Column name with precomputed lengths to use when grouping by length."},
)
report_to: Union[None, str, List[str]] = field(
default=None, metadata={"help": "The list of integrations to report the results and lo... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
"help": (
"When using distributed training, the value of the flag `broadcast_buffers` passed to "
"`DistributedDataParallel`."
)
},
)
dataloader_pin_memory: bool = field(
default=True, metadata={"help": "Whether or not to pin memory for DataLoader."}
... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
push_to_hub: bool = field(
default=False, metadata={"help": "Whether or not to upload the trained model to the model hub after training."}
)
resume_from_checkpoint: Optional[str] = field(
default=None,
metadata={"help": "The path to a folder with a valid checkpoint for your model."},
... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
"help": "Whether to make the repo private. If `None` (default), the repo will be public unless the organization's default is private. This value is ignored if the repo already exists."
},
)
hub_always_push: bool = field(
default=False,
metadata={"help": "Unless `True`, the Trainer will s... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
"help": "This argument is deprecated and will be removed in version 5 of 🤗 Transformers. Use `include_for_metrics` instead."
},
)
include_for_metrics: List[str] = field(
default_factory=list,
metadata={
"help": "List of strings to specify additional data to include in the `c... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
metadata={"help": "Deprecated. Use `eval_strategy` instead"},
)
push_to_hub_model_id: Optional[str] = field(
default=None, metadata={"help": "The name of the repository to which push the `Trainer`."}
)
push_to_hub_organization: Optional[str] = field(
default=None, metadata={"help": "The ... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
auto_find_batch_size: bool = field(
default=False,
metadata={
"help": (
"Whether to automatically decrease the batch size in half and rerun the training loop again each time"
" a CUDA Out-of-Memory was reached"
)
},
)
full_determini... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
'The scope to use when doing hyperparameter search with Ray. By default, `"last"` will be used. Ray'
" will then use the last checkpoint of all trials, compare those, and select the best one. However,"
" other options are also available. See the Ray documentation"
" (http... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
"help": "Which backend to use with `torch.compile`, passing one will trigger a model compilation.",
},
)
torch_compile_mode: Optional[str] = field(
default=None,
metadata={
"help": "Which mode to use with `torch.compile`, passing one will trigger a model compilation.",
... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
dispatch_batches: Optional[bool] = field(
default=None,
metadata={"help": "Deprecated. Pass {'dispatch_batches':VALUE} to `accelerator_config`."},
)
split_batches: Optional[bool] = field(
default=None,
metadata={"help": "Deprecated. Pass {'split_batches':True} to `accelerator_co... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
neftune_noise_alpha: Optional[float] = field(
default=None,
metadata={
"help": "Activates neftune noise embeddings into the model. NEFTune has been proven to drastically improve model performances for instrcution fine-tuning. Check out the original paper here: https://arxiv.org/abs/2310.0591... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
eval_on_start: bool = field(
default=False,
metadata={
"help": "Whether to run through the entire `evaluation` step at the very beginning of training as a sanity check."
},
)
use_liger_kernel: Optional[bool] = field(
default=False,
metadata={"help": "Whether ... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
def __post_init__(self):
# Parse in args that could be `dict` sent in from the CLI as a string
for field in _VALID_DICT_FIELDS:
passed_value = getattr(self, field)
# We only want to do this if the str starts with a bracket to indiciate a `dict`
# else its likely a fil... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
# expand paths, if not os.makedirs("~/bar") will make directory
# in the current directory instead of the actual home
# see https://github.com/huggingface/transformers/issues/10628
if self.output_dir is not None:
self.output_dir = os.path.expanduser(self.output_dir)
if self.l... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
if isinstance(self.eval_strategy, EvaluationStrategy):
warnings.warn(
"using `EvaluationStrategy` for `eval_strategy` is deprecated and will be removed in version 5"
" of 🤗 Transformers. Use `IntervalStrategy` instead",
FutureWarning,
)
... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
self.eval_strategy = IntervalStrategy(self.eval_strategy)
self.logging_strategy = IntervalStrategy(self.logging_strategy)
self.save_strategy = SaveStrategy(self.save_strategy)
self.hub_strategy = HubStrategy(self.hub_strategy)
self.lr_scheduler_type = SchedulerType(self.lr_scheduler_typ... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
# eval_steps has to be defined and non-zero, fallbacks to logging_steps if the latter is non-zero
if self.eval_strategy == IntervalStrategy.STEPS and (self.eval_steps is None or self.eval_steps == 0):
if self.logging_steps > 0:
logger.info(f"using `logging_steps` to initialize `eval_... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
if self.logging_strategy == IntervalStrategy.STEPS and self.logging_steps > 1:
if self.logging_steps != int(self.logging_steps):
raise ValueError(f"--logging_steps must be an integer if bigger than 1: {self.logging_steps}")
self.logging_steps = int(self.logging_steps)
if ... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
# Sanity checks for load_best_model_at_end: we require save and eval strategies to be compatible.
if self.load_best_model_at_end and self.save_strategy != SaveStrategy.BEST:
if self.eval_strategy != self.save_strategy:
raise ValueError(
"--load_best_model_at_end r... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
"steps, which cannot get guaranteed when mixing ratio and absolute steps for save_steps "
f"{self.save_steps} and eval_steps {self.eval_steps}."
)
# Work around floating point precision issues
LARGE_MULTIPLIER = 1_000_000
... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
safetensors_available = is_safetensors_available()
if self.save_safetensors and not safetensors_available:
raise ValueError(f"--save_safetensors={self.save_safetensors} requires safetensors to be installed!")
if not self.save_safetensors and safetensors_available:
logger.info(
... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
if (
self.load_best_model_at_end or self.lr_scheduler_type == SchedulerType.REDUCE_ON_PLATEAU
) and self.metric_for_best_model is None:
self.metric_for_best_model = "loss"
if self.greater_is_better is None and self.metric_for_best_model is not None:
self.greater_is_be... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
if self.bf16 or self.bf16_full_eval:
if self.use_cpu and not is_torch_bf16_cpu_available() and not is_torch_xla_available():
# cpu
raise ValueError("Your setup doesn't support bf16/(cpu, tpu, neuroncore). You need torch>=1.10")
elif not self.use_cp... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
if self.bf16:
if self.half_precision_backend == "apex":
raise ValueError(" `--half_precision_backend apex`: GPU bf16 is not supported by apex.")
if self.lr_scheduler_type == SchedulerType.REDUCE_ON_PLATEAU:
if self.eval_strategy == IntervalStrategy.NO:
ra... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
self.optim = OptimizerNames(self.optim)
if self.adafactor:
warnings.warn(
"`--adafactor` is deprecated and will be removed in version 5 of 🤗 Transformers. Use `--optim"
" adafactor` instead",
FutureWarning,
)
self.optim = Optim... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
# We need to setup the accelerator config here *before* the first call to `self.device`
if is_accelerate_available():
if not isinstance(self.accelerator_config, (AcceleratorConfig)):
if self.accelerator_config is None:
self.accelerator_config = AcceleratorConfig()... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
self.accelerator_config = AcceleratorConfig.from_json_file(self.accelerator_config) | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
if self.dispatch_batches is not None:
warnings.warn(
"Using `--dispatch_batches` is deprecated and will be removed in version 4.41 of 🤗 Transformers. Use"
" `--accelerator_config {'dispatch_batches':VALUE} instead",
FutureWarning,
... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
# Disable average tokens when using single device
if self.average_tokens_across_devices:
try:
if self.world_size == 1:
logger.warning(
"average_tokens_across_devices is set to True but it is invalid when world size is"
... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
if self.torchdynamo is not None:
warnings.warn(
"`torchdynamo` is deprecated and will be removed in version 5 of 🤗 Transformers. Use"
" `torch_compile_backend` instead",
FutureWarning,
)
self.torch_compile_backend = self.torchdynamo
... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
if self.framework == "pt" and is_torch_available() and self.torch_compile:
if is_torch_tf32_available():
if self.tf32 is None and not self.fp16 or self.bf16:
logger.info(
"Setting TF32 in CUDA backends to speedup torch compile, you won't see any im... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
raise ValueError("--tf32 requires Ampere or a newer GPU arch, cuda>=11 and torch>=1.7")
else:
if is_torch_tf32_available():
torch.backends.cuda.matmul.allow_tf32 = False
torch.backends.cudnn.allow_tf32 = False
# no need to assert on els... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
# if training args is specified, it will override the one specified in the accelerate config
if self.half_precision_backend != "apex":
mixed_precision_dtype = os.environ.get("ACCELERATE_MIXED_PRECISION", "no")
if self.fp16:
mixed_precision_dtype = "fp16"
elif ... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
if self.report_to is None:
logger.info(
"The default value for the training argument `--report_to` will change in v5 (from all installed "
"integrations to none). In v5, you will need to use `--report_to all` to get the same behavior as "
"now. You should star... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
if "codecarbon" in self.report_to and torch.version.hip:
logger.warning(
"When using the Trainer, CodeCarbonCallback requires the `codecarbon` package, which is not compatible with AMD ROCm (https://github.com/mlco2/codecarbon/pull/490). Automatically disabling the codecarbon callbac... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
if self.warmup_ratio < 0 or self.warmup_ratio > 1:
raise ValueError("warmup_ratio must lie in range [0,1]")
elif self.warmup_ratio > 0 and self.warmup_steps > 0:
logger.info(
"Both warmup_ratio and warmup_steps given, warmup_steps will override any effect of warmup_ratio"... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
if isinstance(self.fsdp, bool):
self.fsdp = [FSDPOption.FULL_SHARD] if self.fsdp else ""
if isinstance(self.fsdp, str):
self.fsdp = [FSDPOption(s) for s in self.fsdp.split()]
if self.fsdp == [FSDPOption.OFFLOAD]:
raise ValueError(
"`--fsdp offload` can... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
if self.gradient_checkpointing and (
FSDPOption.FULL_SHARD in self.fsdp or FSDPOption.HYBRID_SHARD in self.fsdp
):
logger.warning(
"When using FSDP full shard, instead of using `gradient_checkpointing` in TrainingArguments, please"
" use `activation_checkp... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
if isinstance(self.fsdp_config, str):
if len(self.fsdp) == 0:
warnings.warn("`--fsdp_config` is useful only when `--fsdp` is specified.")
with io.open(self.fsdp_config, "r", encoding="utf-8") as f:
self.fsdp_config = json.load(f)
for k in list(self... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
# if fsdp_config["transformer_layer_cls_to_wrap"] is specified as a string, convert it to a list with a single object
if isinstance(self.fsdp_config.get("transformer_layer_cls_to_wrap", None), str):
self.fsdp_config["transformer_layer_cls_to_wrap"] = [self.fsdp_config["transformer_layer_cls_to_wrap"... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
if len(self.fsdp) == 0 and self.fsdp_config.get("transformer_layer_cls_to_wrap", None) is not None:
warnings.warn("`transformer_layer_cls_to_wrap` is useful only when `--fsdp` is specified.") | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
if (
len(self.fsdp) > 0
and self.fsdp_config["min_num_params"] > 0
and self.fsdp_config.get("transformer_layer_cls_to_wrap", None) is not None
):
raise ValueError("`min_num_params` and `transformer_layer_cls_to_wrap` are mutually exclusive.")
self.fsdp_con... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
if "compute_dtype" in self.xla_fsdp_config:
self.xla_fsdp_config["compute_dtype"] = getattr(torch, self.xla_fsdp_config["compute_dtype"])
if "buffer_dtype" in self.xla_fsdp_config:
self.xla_fsdp_config["buffer_dtype"] = getattr(torch, self.xla_fsdp_config["buffer_... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
# accelerate integration for FSDP
if len(self.fsdp) > 0 and not self.fsdp_config["xla"]:
os.environ["ACCELERATE_USE_FSDP"] = "true"
from accelerate.utils.constants import (
FSDP_AUTO_WRAP_POLICY,
FSDP_SHARDING_STRATEGY,
) | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
prefix = "FSDP_"
for fsdp_option in self.fsdp:
if fsdp_option.upper() in FSDP_SHARDING_STRATEGY:
# set environment variable for FSDP sharding strategy
os.environ[f"{prefix}SHARDING_STRATEGY"] = str(
FSDP_SHARDING_STRATEGY.index(... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
os.environ[f"{prefix}TRANSFORMER_CLS_TO_WRAP"] = ",".join(
self.fsdp_config["transformer_layer_cls_to_wrap"]
)
prefetch_policy = self.fsdp_config.get("backward_prefetch", "NO_PREFETCH")
os.environ[f"{prefix}BACKWARD_PREFETCH"] = prefetch_policy... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
sync_module_states = str(self.fsdp_config.get("sync_module_states", "true")).lower()
cpu_ram_efficient_loading = str(self.fsdp_config.get("cpu_ram_efficient_loading", "false")).lower()
if sync_module_states == "false" and cpu_ram_efficient_loading == "true":
# In this case, all ... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
if self.tpu_metrics_debug:
warnings.warn(
"using `--tpu_metrics_debug` is deprecated and will be removed in version 5 of 🤗 Transformers. Use"
" `--debug tpu_metrics_debug` instead",
FutureWarning,
)
if self.debug is None:
... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
self.deepspeed_plugin = None
if self.deepspeed:
# - must be run very last in arg parsing, since it will use a lot of these settings.
# - must be run before the model is created.
if not is_accelerate_available():
raise ValueError(
f"--deepsp... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
os.environ["ACCELERATE_USE_DEEPSPEED"] = "true"
self.deepspeed_plugin = DeepSpeedPlugin(hf_ds_config=self.hf_deepspeed_config)
elif strtobool(os.environ.get("ACCELERATE_USE_DEEPSPEED", "false")):
# Accelerate DeepSpeed Plugin
from accelerate.utils import DeepSpeedPlugin
... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
if self.push_to_hub_token is not None:
warnings.warn(
"`--push_to_hub_token` is deprecated and will be removed in version 5 of 🤗 Transformers. Use "
"`--hub_token` instead.",
FutureWarning,
)
self.hub_token = self.push_to_hub_token | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
if self.push_to_hub_model_id is not None:
self.hub_model_id = get_full_repo_name(
self.push_to_hub_model_id, organization=self.push_to_hub_organization, token=self.hub_token
)
if self.push_to_hub_organization is not None:
warnings.warn(
... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
FutureWarning,
)
elif self.push_to_hub_organization is not None:
self.hub_model_id = f"{self.push_to_hub_organization}/{Path(self.output_dir).name}"
warnings.warn(
"`--push_to_hub_organization` is deprecated and will be removed in version 5 of 🤗 Transform... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
if self.eval_use_gather_object and not is_accelerate_available("0.30.0"):
raise ValueError(
"--eval_use_gather_object requires Accelerate to be version of `accelerate` > 0.30.0."
"This is not supported and we recommend you to update your version."
)
if se... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
# Remove deprecated arguments. That code should be removed once
# those deprecated arguments are removed from TrainingArguments. (TODO: v5)
del self_as_dict["per_gpu_train_batch_size"]
del self_as_dict["per_gpu_eval_batch_size"]
self_as_dict = {k: f"<{k.upper()}>" if k.endswith("_token"... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
@property
def train_batch_size(self) -> int:
"""
The actual batch size for training (may differ from `per_gpu_train_batch_size` in distributed training).
"""
if self.per_gpu_train_batch_size:
logger.warning(
"Using deprecated `--per_gpu_train_batch_size` a... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
@property
def eval_batch_size(self) -> int:
"""
The actual batch size for evaluation (may differ from `per_gpu_eval_batch_size` in distributed training).
"""
if self.per_gpu_eval_batch_size:
logger.warning(
"Using deprecated `--per_gpu_eval_batch_size` arg... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
@cached_property
def _setup_devices(self) -> "torch.device":
requires_backends(self, ["torch"])
logger.info("PyTorch: setting up devices")
if not is_sagemaker_mp_enabled():
if not is_accelerate_available():
raise ImportError(
f"Using the `Train... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
raise ValueError(
"Passing `'use_configured_state':True` to the AcceleratorConfig requires a pre-configured "
"`AcceleratorState` or `PartialState` to be defined before calling `TrainingArguments`. "
)
# We rely on `PartialState` to yell if there's iss... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
self.distributed_state = None
if not self.use_ipex and "ACCELERATE_USE_IPEX" not in os.environ:
os.environ["ACCELERATE_USE_IPEX"] = "false" | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
self._n_gpu = 1
if self.use_cpu or strtobool(os.environ.get("ACCELERATE_USE_CPU", "False")):
accelerator_state_kwargs["cpu"] = True
accelerator_state_kwargs["backend"] = self.ddp_backend
self._n_gpu = 0
elif is_sagemaker_mp_enabled():
accelerator_state_kwa... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
# Now we pop everything
if accelerator_state_kwargs.pop("enabled", False) and not accelerator_state_kwargs.pop(
"use_configured_state", False
):
# We need to patch this env var when enabling to detect deepspeed
use_deepspeed = accelerator_state_kwargs.pop("use_deepspe... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
"In order to use Torch DDP, launch your script with `python -m torch.distributed.launch"
)
if is_torch_xla_available():
device = self.distributed_state.device
self._n_gpu = 0
elif is_sagemaker_dp_enabled() or is_sagemaker_mp_enabled():
# Already set _n_gpu... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
"or current PyTorch install was not built with MPS enabled."
)
if self.use_cpu:
device = torch.device("cpu")
elif is_torch_mps_available():
device = torch.device("mps")
elif is_torch_xpu_available():
if not is_ipex_a... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
else:
# if n_gpu is > 1 we'll use nn.DataParallel.
# If you only want to use a specific subset of GPUs use `CUDA_VISIBLE_DEVICES=0`
# Explicitly set CUDA to the first (index 0) CUDA device, otherwise `set_device` will
# trigger an error that a device index... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
return device | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
@property
def device(self) -> "torch.device":
"""
The device used by this process.
"""
requires_backends(self, ["torch"])
return self._setup_devices
@property
def n_gpu(self):
"""
The number of GPUs used by this process.
Note:
Thi... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
- `ParallelMode.NOT_PARALLEL`: no parallelism (CPU or one GPU).
- `ParallelMode.NOT_DISTRIBUTED`: several GPUs in one single process (uses `torch.nn.DataParallel`).
- `ParallelMode.DISTRIBUTED`: several GPUs, each having its own process (uses
`torch.nn.DistributedDataParallel`).
- `Par... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
return ParallelMode.NOT_PARALLEL | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
@property
def world_size(self):
"""
The number of processes used in parallel.
"""
requires_backends(self, ["torch"])
if self.distributed_state is not None:
return self.distributed_state.num_processes
elif is_sagemaker_mp_enabled():
return smp.d... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
if self.distributed_state is not None:
return self.distributed_state.local_process_index
elif is_sagemaker_mp_enabled():
return smp.local_rank()
return 0
@property
def should_log(self):
"""
Whether or not the current process should produce log.
""... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
def get_process_log_level(self):
"""
Returns the log level to be used depending on whether this process is the main process of node 0, main process
of node non-0, or a non-main process.
For the main process the log level defaults to the logging level set (`logging.WARNING` if you didn't... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
log_level_main_node = logging.get_verbosity() if log_level == -1 else log_level
log_level_replica_node = logging.get_verbosity() if log_level_replica == -1 else log_level_replica
return log_level_main_node if self.should_log else log_level_replica_node
@property
def place_model_on_device(self):... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
@contextlib.contextmanager
def main_process_first(self, local=True, desc="work"):
"""
A context manager for torch distributed environment where on needs to do something on the main process, while
blocking replicas, and when it's finished releasing the replicas.
One such use is for `... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
Args:
local (`bool`, *optional*, defaults to `True`):
if `True` first means process of rank 0 of each node if `False` first means process of rank 0 of node
rank 0 In multi-node environment with a shared filesystem you most likely will want to use
`local=False`... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
"""
if is_torch_available() and self.world_size > 1:
main_process_desc = "main local process" if local else "main process"
if self.distributed_state is not None:
is_main_process = (
self.distributed_state.is_local_main_process if local else self.distri... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
if is_torch_xla_available():
xm.rendezvous(desc)
else:
dist.barrier()
yield
finally:
if is_main_process:
# the wait is over
logger.debug(f"{self.process_index}: {main_p... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
def _dict_torch_dtype_to_str(self, d: Dict[str, Any]) -> None:
"""
Checks whether the passed dictionary and its nested dicts have a *torch_dtype* key and if it's not None,
converts torch.dtype to a string of just the type. For example, `torch.float32` get converted into *"float32"*
strin... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
def to_dict(self):
"""
Serializes this instance while replace `Enum` by their values (for JSON serialization support). It obfuscates
the token values by removing their value.
"""
# filter out fields that are defined as field(init=False)
d = {field.name: getattr(self, fiel... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
def to_json_string(self):
"""
Serializes this instance to a JSON string.
"""
return json.dumps(self.to_dict(), indent=2)
def to_sanitized_dict(self) -> Dict[str, Any]:
"""
Sanitized serialization to use with TensorBoard’s hparams
"""
d = self.to_dict(... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
# The following methods are there to simplify the instantiation of `TrainingArguments`
def set_training(
self,
learning_rate: float = 5e-5,
batch_size: int = 8,
weight_decay: float = 0,
num_epochs: float = 3,
max_steps: int = -1,
gradient_accumulation_steps: i... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
Args:
learning_rate (`float`, *optional*, defaults to 5e-5):
The initial learning rate for the optimizer.
batch_size (`int` *optional*, defaults to 8):
The batch size per device (GPU/TPU core/CPU...) used for training.
weight_decay (`float`, *optional*... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
For a finite dataset, training is reiterated through the dataset (if all data is exhausted) until
`max_steps` is reached.
gradient_accumulation_steps (`int`, *optional*, defaults to 1):
Number of updates steps to accumulate the gradients for, before performing a backward/upda... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
<Tip warning={true}>
When using gradient accumulation, one step is counted as one step with backward pass. Therefore,
logging, evaluation, save will be conducted every `gradient_accumulation_steps * xxx_step` training
examples.
</Tip>
seed (... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
>>> args = TrainingArguments("working_dir")
>>> args = args.set_training(learning_rate=1e-4, batch_size=32)
>>> args.learning_rate
1e-4
```
"""
self.do_train = True
self.learning_rate = learning_rate
self.per_device_train_batch_size = batch_size
se... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
Args:
strategy (`str` or [`~trainer_utils.IntervalStrategy`], *optional*, defaults to `"no"`):
The evaluation strategy to adopt during training. Possible values are:
- `"no"`: No evaluation is done during training.
- `"steps"`: Evaluation is done (and... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
Setting a `strategy` different from `"no"` will set `self.do_eval` to `True`.
steps (`int`, *optional*, defaults to 500):
Number of update steps between two evaluations if `strategy="steps"`.
batch_size (`int` *optional*, defaults to 8):
The batch size per device ... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
jit_mode (`bool`, *optional*):
Whether or not to use PyTorch jit trace for inference. | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
Example:
```py
>>> from transformers import TrainingArguments
>>> args = TrainingArguments("working_dir")
>>> args = args.set_evaluate(strategy="steps", steps=100)
>>> args.eval_steps
100
```
"""
self.eval_strategy = IntervalStrategy(strategy)
... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
def set_testing(
self,
batch_size: int = 8,
loss_only: bool = False,
jit_mode: bool = False,
):
"""
A method that regroups all basic arguments linked to testing on a held-out dataset.
<Tip>
Calling this method will automatically set `self.do_predict`... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
>>> args = TrainingArguments("working_dir")
>>> args = args.set_testing(batch_size=32)
>>> args.per_device_eval_batch_size
32
```
"""
self.do_predict = True
self.per_device_eval_batch_size = batch_size
self.prediction_loss_only = loss_only
self.jit... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
- `"no"`: No save is done during training.
- `"epoch"`: Save is done at the end of each epoch.
- `"steps"`: Save is done every `save_steps`.
steps (`int`, *optional*, defaults to 500):
Number of updates steps before two checkpoint saves if `strategy="... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
>>> args = TrainingArguments("working_dir")
>>> args = args.set_save(strategy="steps", steps=100)
>>> args.save_steps
100
```
"""
self.save_strategy = SaveStrategy(strategy)
if self.save_strategy == SaveStrategy.STEPS and steps == 0:
raise ValueError("... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
Args:
strategy (`str` or [`~trainer_utils.IntervalStrategy`], *optional*, defaults to `"steps"`):
The logging strategy to adopt during training. Possible values are:
- `"no"`: No logging is done during training.
- `"epoch"`: Logging is done at the end... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
steps (`int`, *optional*, defaults to 500):
Number of update steps between two logs if `strategy="steps"`.
level (`str`, *optional*, defaults to `"passive"`):
Logger log level to use on the main process. Possible choices are the log levels as strings: `"debug"`,
... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
Whether to log and evaluate the first `global_step` or not.
nan_inf_filter (`bool`, *optional*, defaults to `True`):
Whether to filter `nan` and `inf` losses for logging. If set to `True` the loss of every step that is
`nan` or `inf` is filtered and the average loss of the cu... | 179 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/training_args.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.