text stringlengths 1 1.02k | class_index int64 0 10.8k | source stringlengths 85 188 |
|---|---|---|
if self.inprogress_constraint is not None:
# In the middle of fulfilling a constraint. If the `token_id` *does* makes an incremental progress to current
# job, simply update the state
stepped, complete, reset = self.inprogress_constraint.update(token_id)
if reset:
... | 10,774 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/beam_constraints.py |
if complete:
# 2. If the next token completes the constraint, move it to completed list, set
# inprogress to None. If there are no pending constraints either, then this full list of constraints
# is complete.
self.complete_constraints.append(self.... | 10,774 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/beam_constraints.py |
if not stepped:
raise Exception(
"`constraint.update(token_id)` is not yielding incremental progress, "
"even though `constraint.does_advance(token_id)` is true."
)
if complete:
... | 10,774 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/beam_constraints.py |
if len(self.pending_constraints) == 0 and self.inprogress_constraint is None:
# If there's no longer any pending after this and no inprogress either, then we must be
# complete.
self.completed = True
break # p... | 10,774 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/beam_constraints.py |
if stateful:
new_state.complete_constraints = [
constraint.copy(stateful=True) for constraint in self.complete_constraints
]
if self.inprogress_constraint is not None:
new_state.inprogress_constraint = self.inprogress_constraint.copy(stateful=True)
... | 10,774 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/beam_constraints.py |
class SageMakerTrainer(Trainer):
def __init__(self, args=None, **kwargs):
warnings.warn(
"`SageMakerTrainer` is deprecated and will be removed in v5 of Transformers. You can use `Trainer` "
"instead.",
FutureWarning,
)
super().__init__(args=args, **kwargs) | 10,775 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/sagemaker/trainer_sm.py |
class SageMakerTrainingArguments(TrainingArguments):
mp_parameters: str = field(
default="",
metadata={"help": "Used by the SageMaker launcher to send mp-specific args. Ignored in SageMakerTrainer"},
)
def __post_init__(self):
super().__post_init__()
warnings.warn(
... | 10,776 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/sagemaker/training_args_sm.py |
@cached_property
def _setup_devices(self) -> "torch.device":
logger.info("PyTorch: setting up devices")
if torch.distributed.is_available() and torch.distributed.is_initialized() and self.local_rank == -1:
logger.warning(
"torch.distributed process group is initialized, b... | 10,776 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/sagemaker/training_args_sm.py |
torch.distributed.init_process_group(backend="smddp", timeout=self.ddp_timeout_delta)
self.local_rank = int(os.getenv("SMDATAPARALLEL_LOCAL_RANK"))
device = torch.device("cuda", self.local_rank)
self._n_gpu = 1
elif self.local_rank == -1:
# if n_gpu is > 1 we'll u... | 10,776 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/sagemaker/training_args_sm.py |
# the default value.
self._n_gpu = torch.cuda.device_count()
else:
# Here, we'll use torch.distributed.
# Initializes the distributed backend which will take care of synchronizing nodes/GPUs
if not torch.distributed.is_initialized():
torch.distribu... | 10,776 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/sagemaker/training_args_sm.py |
if device.type == "cuda":
torch.cuda.set_device(device)
return device
@property
def world_size(self):
if is_sagemaker_model_parallel_available():
return smp.dp_size()
return super().world_size
@property
def place_model_on_device(self):
return n... | 10,776 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/sagemaker/training_args_sm.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.