Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LLaMA-2 #101

Merged
merged 7 commits into from
Jul 21, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
skip llama2 with old transformers
  • Loading branch information
BlackSamorez committed Jul 21, 2023
commit a66f23b94382a3566f54f1a5007cbdbeb0efb701
43 changes: 23 additions & 20 deletions tests/test_transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,39 +72,42 @@ def all_equal(iterator):
) # basically asserting that all of those have the same config


def prepare_model(model_name, use_lora):
if model_name == "BlackSamorez/falcon-40b-tiny-testing" and torch.__version__ < "2.0":
pytest.skip(f"Not testing {model_name} with torch=={torch.__version__}")
if model_name == "BlackSamorez/llama-2-tiny-testing" and transformers.__version__ < "4.31":
pytest.skip(f"Not testing {model_name} with transformers=={transformers.__version__}")

try:
model = AutoModelForCausalLM.from_pretrained(model_name, low_cpu_mem_usage=True, trust_remote_code=True).float()
except KeyError as err:
pytest.skip(f"Could not create model {model_name} with error {err}")
if use_lora:
if model_name == "gpt2":
pytest.skip("Not testing LoRA for gpt2")
model = add_lora(model, model_name)
return model


@pytest.mark.parametrize("use_lora", [False, True])
@pytest.mark.parametrize("use_config", [False, True])
@pytest.mark.parametrize("devices", [("cpu",) * 2, ("cpu",) * 3])
@pytest.mark.parametrize(
"model_name",
[
"bigscience/bloom-560m",
"gpt2",
"trl-internal-testing/tiny-random-GPTNeoXForCausalLM",
"Salesforce/codegen-350M-mono",
# "bigscience/bloom-560m",
# "gpt2",
# "trl-internal-testing/tiny-random-GPTNeoXForCausalLM",
# "Salesforce/codegen-350M-mono",
"Bingsu/llama-190m-arch",
"BlackSamorez/llama-2-tiny-testing",
"BlackSamorez/falcon-40b-tiny-testing",
# "BlackSamorez/falcon-40b-tiny-testing",
],
)
def test_forward_gpt2_like(use_lora, use_config, devices, model_name):
torch.manual_seed(0)

if model_name == "BlackSamorez/falcon-40b-tiny-testing" and torch.__version__ < "2.0":
pytest.skip(f"Not testing {model_name} with torch=={torch.__version__}")

try:
model = (
AutoModelForCausalLM.from_pretrained(model_name, low_cpu_mem_usage=True, trust_remote_code=True)
.float()
.to(devices[0])
)
except KeyError as err:
pytest.skip(f"Could not create model {model_name} with error {err}")
if use_lora:
if model_name == "gpt2":
pytest.skip("Not testing LoRA for gpt2")
model = add_lora(model, model_name)
model = prepare_model(model_name, use_lora)

inp1 = torch.randint(1, 1000, size=(2, 3), device=devices[0])
inp2 = torch.randint(1, 1000, size=(2, 1), device=devices[0])
Expand Down
Loading