Remove old code for PyTorch, Accelerator and tokenizers (#37234)
* Remove unneeded library version checks Signed-off-by: cyy <cyyever@outlook.com> * Remove PyTorch condition Signed-off-by: cyy <cyyever@outlook.com> * Remove PyTorch condition Signed-off-by: cyy <cyyever@outlook.com> * Fix ROCm get_device_capability Signed-off-by: cyy <cyyever@outlook.com> * Revert "Fix ROCm get_device_capability" This reverts commit 0e756434bd7e74ffd73de5500476072b096570a6. * Remove unnecessary check Signed-off-by: cyy <cyyever@outlook.com> * Revert changes Signed-off-by: cyy <cyyever@outlook.com> --------- Signed-off-by: cyy <cyyever@outlook.com>
This commit is contained in:
@@ -99,7 +99,6 @@ from transformers.testing_utils import (
|
||||
require_torch_tensorrt_fx,
|
||||
require_torch_tf32,
|
||||
require_torch_up_to_2_accelerators,
|
||||
require_torchdynamo,
|
||||
require_vision,
|
||||
require_wandb,
|
||||
run_first,
|
||||
@@ -3994,10 +3993,9 @@ class TrainerIntegrationTest(TestCasePlus, TrainerIntegrationCommon):
|
||||
|
||||
@require_non_xpu
|
||||
@require_torch_non_multi_gpu
|
||||
@require_torchdynamo
|
||||
@require_torch_tensorrt_fx
|
||||
def test_torchdynamo_full_eval(self):
|
||||
import torchdynamo
|
||||
from torch import _dynamo as torchdynamo
|
||||
|
||||
# torchdynamo at the moment doesn't support DP/DDP, therefore require a single gpu
|
||||
n_gpus = get_gpu_count()
|
||||
@@ -4017,30 +4015,35 @@ class TrainerIntegrationTest(TestCasePlus, TrainerIntegrationCommon):
|
||||
del trainer
|
||||
|
||||
# 2. TorchDynamo eager
|
||||
trainer = get_regression_trainer(a=a, b=b, eval_len=eval_len, torchdynamo="eager", output_dir=tmp_dir)
|
||||
trainer = get_regression_trainer(
|
||||
a=a, b=b, eval_len=eval_len, torch_compile_backend="eager", output_dir=tmp_dir
|
||||
)
|
||||
metrics = trainer.evaluate()
|
||||
self.assertAlmostEqual(metrics["eval_loss"], original_eval_loss)
|
||||
del trainer
|
||||
torchdynamo.reset()
|
||||
|
||||
# 3. TorchDynamo nvfuser
|
||||
trainer = get_regression_trainer(a=a, b=b, eval_len=eval_len, torchdynamo="nvfuser", output_dir=tmp_dir)
|
||||
trainer = get_regression_trainer(
|
||||
a=a, b=b, eval_len=eval_len, torch_compile_backend="nvfuser", output_dir=tmp_dir
|
||||
)
|
||||
metrics = trainer.evaluate()
|
||||
self.assertAlmostEqual(metrics["eval_loss"], original_eval_loss)
|
||||
torchdynamo.reset()
|
||||
|
||||
# 4. TorchDynamo fx2trt
|
||||
trainer = get_regression_trainer(a=a, b=b, eval_len=eval_len, torchdynamo="fx2trt", output_dir=tmp_dir)
|
||||
trainer = get_regression_trainer(
|
||||
a=a, b=b, eval_len=eval_len, torch_compile_backend="fx2trt", output_dir=tmp_dir
|
||||
)
|
||||
metrics = trainer.evaluate()
|
||||
self.assertAlmostEqual(metrics["eval_loss"], original_eval_loss)
|
||||
torchdynamo.reset()
|
||||
|
||||
@unittest.skip(reason="torch 2.0.0 gives `ModuleNotFoundError: No module named 'torchdynamo'`.")
|
||||
@require_torch_non_multi_gpu
|
||||
@require_torchdynamo
|
||||
@require_torch_gpu
|
||||
def test_torchdynamo_memory(self):
|
||||
# torchdynamo at the moment doesn't support DP/DDP, therefore require a single gpu
|
||||
import torchdynamo
|
||||
from torch import _dynamo as torchdynamo
|
||||
|
||||
class CustomTrainer(Trainer):
|
||||
def compute_loss(self, model, inputs, return_outputs=False):
|
||||
@@ -4085,7 +4088,7 @@ class TrainerIntegrationTest(TestCasePlus, TrainerIntegrationCommon):
|
||||
with tempfile.TemporaryDirectory() as tmp_dir:
|
||||
a = torch.ones(1024, 1024, device="cuda", requires_grad=True)
|
||||
a.grad = None
|
||||
args = TrainingArguments(output_dir=tmp_dir, torchdynamo="nvfuser")
|
||||
args = TrainingArguments(output_dir=tmp_dir, torch_compile_backend="nvfuser")
|
||||
trainer = CustomTrainer(model=mod, args=args)
|
||||
# warmup
|
||||
for _ in range(10):
|
||||
|
||||
Reference in New Issue
Block a user