diff --git a/tests/models/mamba2/test_modeling_mamba2.py b/tests/models/mamba2/test_modeling_mamba2.py index 770a59b5157f..c9ca5f1d8a8f 100644 --- a/tests/models/mamba2/test_modeling_mamba2.py +++ b/tests/models/mamba2/test_modeling_mamba2.py @@ -404,6 +404,8 @@ class Mamba2IntegrationTest(unittest.TestCase): def setUp(self): self.model_id = "mistralai/Mamba-Codestral-7B-v0.1" self.tokenizer = AutoTokenizer.from_pretrained(self.model_id, from_slow=True, legacy=False) + if torch.cuda.is_available(): + torch.cuda.empty_cache() self.prompt = ("[INST]Write a hello world program in C++.",) @slow @@ -418,7 +420,7 @@ def test_simple_generate(self): tokenizer = self.tokenizer tokenizer.pad_token_id = tokenizer.eos_token_id - model = Mamba2ForCausalLM.from_pretrained(self.model_id, dtype=torch.bfloat16) + model = Mamba2ForCausalLM.from_pretrained(self.model_id, torch_dtype=torch.bfloat16) model.to(torch_device) input_ids = tokenizer("[INST]Write a hello world program in C++.[/INST]", return_tensors="pt")["input_ids"].to( torch_device @@ -450,7 +452,7 @@ def test_batched_equivalence_with_cache(self): "[INST] Write a simple Fibonacci number computation function in Rust that does memoization, with comments, in safe Rust.[/INST]", ] - model = Mamba2ForCausalLM.from_pretrained(self.model_id, dtype=torch.bfloat16).to(torch_device) + model = Mamba2ForCausalLM.from_pretrained(self.model_id, torch_dtype=torch.bfloat16).to(torch_device) tokenizer.pad_token_id = tokenizer.eos_token_id # batched generation tokenized_prompts = tokenizer(prompt, return_tensors="pt", padding="longest").to(torch_device) @@ -480,7 +482,7 @@ def test_batched_equivalence_without_cache(self): "[INST] Write a simple Fibonacci number computation function in Rust that does memoization, with comments, in safe Rust.[/INST]", ] - model = Mamba2ForCausalLM.from_pretrained(self.model_id, dtype=torch.bfloat16).to(torch_device) + model = Mamba2ForCausalLM.from_pretrained(self.model_id, torch_dtype=torch.bfloat16).to(torch_device) tokenizer.pad_token_id = tokenizer.eos_token_id # batched generation tokenized_prompts = tokenizer(prompt, return_tensors="pt", padding="longest").to(torch_device) @@ -501,7 +503,7 @@ def test_mamba2_mixer_train_vs_eval_equivalence(self): # Based on https://github.com/sustcsonglin/flash-linear-attention/issues/63 # Credit to zhixuan-lin - B, T, D = 4, 512, 768 + B, T, D = 4, 128, 768 dtype = torch.bfloat16 config = Mamba2Config(num_heads=24, head_dim=64, hidden_size=768, expand=2, n_groups=1)