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

Ensure Consistency Between GPTConfig.block_size and Sequence Length T #72

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Benetti-Hub
Copy link

First and foremost, I want to express my appreciation for this tutorial. It's incredibly insightful and well-structured.

I'm submitting this PR because I noticed a potential issue related to GPTConfig.block_size not being enforced to match the sequence length T.

If I understand correctly, this discrepancy could lead to unexpected model behavior during inference if T is lower than GPTConfig.block_size . (Note that an assertion error is already raised when T exceeds GPTConfig.block_size, as seen here).

Thank you for considering this change. Please let me know if any further adjustments are needed.

@zhaziqwe
Copy link

zhaziqwe commented Aug 18, 2024

I have similar doubts about this problem. I don't know what will happen in casual mask after using flash attention.
# q * k^t / sqrt(hs) # att = (q @ k.transpose(-2, -1)) * (1.0 / math.sqrt(k.size(-1))) # att = att.masked_fill(self.bias[:, :, :T, :T] == 0, float('-inf')) # att = F.softmax(att, dim=-1) # y = att @ v y = F.scaled_dot_product_attention(q,k,v,is_causal=True)
If it is not used, I think T does not need to be strictly equal to blocksize.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants