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

Issue with phi-3 on Long Sequences with Batches > 1 #481

Open
Samoed opened this issue May 16, 2024 · 1 comment
Open

Issue with phi-3 on Long Sequences with Batches > 1 #481

Samoed opened this issue May 16, 2024 · 1 comment
Labels
currently fixing Am fixing now!

Comments

@Samoed
Copy link

Samoed commented May 16, 2024

Hi! I'm encountering an issue while tuning phi-3 on long sequences with batch sizes greater than 1. Below is the code to reproduce the problem:

Working Code:

tokenized = tokenizer(
    ["Very long prompt\n" * 3000],  # *2,
    max_length=3000,
    return_tensors="pt",
    truncation=True,
).to("cuda")

res = model.generate(
    **tokenized,
    max_length=4096,
)

Code with Error:

RuntimeError: The expanded size of the tensor (2047) must match the existing size (3001) at non-singleton dimension 3. Target sizes: [2, 32, 1, 2047]. Tensor sizes: [2, 1, 1, 3001]
tokenized = tokenizer(
    ["Very long prompt\n" * 3000] * 2,
    max_length=3000,
    return_tensors="pt",
    truncation=True,
).to("cuda")

res = model.generate(
    **tokenized,
    max_length=4096,
)

Notebook with example.

Any insights on how to resolve this issue would be greatly appreciated!

@danielhanchen
Copy link
Contributor

Oh interesting I'll check this and get back to you - sorry!

@danielhanchen danielhanchen added the currently fixing Am fixing now! label May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
currently fixing Am fixing now!
Projects
None yet
Development

No branches or pull requests

2 participants