Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion op_builder/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def get_cuda_version_in_pytorch() -> List[int]:
torch_cuda_minor = torch.version.cuda.split(".")[1]
except:
raise ValueError(
"[extension] Cannot retrive the CUDA version in the PyTorch binary given by torch.version.cuda")
"[extension] Cannot retrieve the CUDA version in the PyTorch binary given by torch.version.cuda")
return torch_cuda_major, torch_cuda_minor


Expand Down
10 changes: 5 additions & 5 deletions tests/components_to_test/albert.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def bert_model_builder(checkpoint: bool = False):
print('building AlbertForSequenceClassification model')

# adapting huggingface BertForSequenceClassification for single unitest calling interface
class ModelAaptor(AlbertForSequenceClassification):
class ModelAdaptor(AlbertForSequenceClassification):

def forward(self, input_ids, labels):
"""
Expand All @@ -37,23 +37,23 @@ def forward(self, input_ids, labels):
"""
return super().forward(input_ids=input_ids, labels=labels)[0]

model = ModelAaptor(config)
model = ModelAdaptor(config)
# if checkpoint and version.parse(transformers.__version__) >= version.parse("4.11.0"):
# model.gradient_checkpointing_enable()

return model

is_distrbuted = torch.distributed.is_initialized()
is_distributed = torch.distributed.is_initialized()
trainloader = get_bert_data_loader(n_class=vocab_size,
batch_size=2,
total_samples=10000,
sequence_length=sequence_length,
is_distrbuted=is_distrbuted)
is_distributed=is_distributed)
testloader = get_bert_data_loader(n_class=vocab_size,
batch_size=2,
total_samples=10000,
sequence_length=sequence_length,
is_distrbuted=is_distrbuted)
is_distributed=is_distributed)

criterion = None
return bert_model_builder, trainloader, testloader, torch.optim.Adam, criterion
4 changes: 2 additions & 2 deletions tests/components_to_test/beit.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def generate(self):
@non_distributed_component_funcs.register(name='beit')
def get_training_components():

def model_buider(checkpoint=False):
def model_builder(checkpoint=False):
model = Beit(img_size=DummyDataLoader.img_size,
num_classes=DummyDataLoader.num_class,
embed_dim=32,
Expand All @@ -39,4 +39,4 @@ def model_buider(checkpoint=False):
testloader = DummyDataLoader()

criterion = torch.nn.CrossEntropyLoss()
return model_buider, trainloader, testloader, torch.optim.Adam, criterion
return model_builder, trainloader, testloader, torch.optim.Adam, criterion
16 changes: 8 additions & 8 deletions tests/components_to_test/bert.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def get_bert_data_loader(
total_samples,
sequence_length,
device=torch.device('cpu:0'),
is_distrbuted=False,
is_distributed=False,
):
train_data = torch.randint(
low=0,
Expand All @@ -24,7 +24,7 @@ def get_bert_data_loader(
)
train_label = torch.randint(low=0, high=2, size=(total_samples,), device=device, dtype=torch.long)
train_dataset = torch.utils.data.TensorDataset(train_data, train_label)
if is_distrbuted:
if is_distributed:
sampler = torch.utils.data.distributed.DistributedSampler(train_dataset)
else:
sampler = SequentialSampler(train_dataset)
Expand Down Expand Up @@ -52,8 +52,8 @@ def bert_model_builder(checkpoint: bool = False):
attention_probs_dropout_prob=0.)
print('building BertForSequenceClassification model')

# adapting huggingface BertForSequenceClassification for single unitest calling interface
class ModelAaptor(BertForSequenceClassification):
# adapting huggingface BertForSequenceClassification for single unittest calling interface
class ModelAdaptor(BertForSequenceClassification):

def forward(self, input_ids, labels):
"""
Expand All @@ -62,23 +62,23 @@ def forward(self, input_ids, labels):
"""
return super().forward(input_ids=input_ids, labels=labels)[0]

model = ModelAaptor(config)
model = ModelAdaptor(config)
if checkpoint and version.parse(transformers.__version__) >= version.parse("4.11.0"):
model.gradient_checkpointing_enable()

return model

is_distrbuted = torch.distributed.is_initialized()
is_distributed = torch.distributed.is_initialized()
trainloader = get_bert_data_loader(n_class=vocab_size,
batch_size=2,
total_samples=10000,
sequence_length=sequence_length,
is_distrbuted=is_distrbuted)
is_distributed=is_distributed)
testloader = get_bert_data_loader(n_class=vocab_size,
batch_size=2,
total_samples=10000,
sequence_length=sequence_length,
is_distrbuted=is_distrbuted)
is_distributed=is_distributed)

criterion = None
return bert_model_builder, trainloader, testloader, torch.optim.Adam, criterion
8 changes: 4 additions & 4 deletions tests/components_to_test/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ def __init__(self):
def register(self, name):
assert name not in self._registry

def _regsiter(callable_):
def _register(callable_):
self._registry[name] = callable_

return _regsiter
return _register

def get_callable(self, name: str):
return self._registry[name]
Expand All @@ -34,6 +34,6 @@ def __next__(self):


non_distributed_component_funcs = Registry()
model_paralle_component_funcs = Registry()
model_parallel_component_funcs = Registry()

__all__ = ['non_distributed_component_funcs', 'model_paralle_component_funcs']
__all__ = ['non_distributed_component_funcs', 'model_parallel_component_funcs']