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

[BPT] Question about the Scaling Factor in Equation from the Paper #22

Open
Xiaoming-Zhao opened this issue Oct 24, 2024 · 0 comments
Open

Comments

@Xiaoming-Zhao
Copy link

Hi, BPT and RingAttention are awesome works! Thanks a lot for open-sourcing the code.

I have a question about the 2nd equation in the following snapshot taken from the paper. I am having difficulty deriving the LHS and RHS as equal.

Screenshot 2024-10-23 at 23 19 40
  1. Should the scaling factor be $$\exp(max(Q_i K_j^T) - \max_i)$$ instead of $$\exp(Q_i K_j^T - \max_i)$$, i.e., the maximum symbol is missing?

  2. Even fixing the above issue, following Online Normalizer Calculation for Softmax, should the scaling factor be applied to both the numerator and the denominator as done in both the pseudo-code in the paper (L43-45) as well as the implementation in the following?

    correction = rearrange(jnp.exp(prev_max_score_chunk - max_score_chunk), 'b h q -> b q h')[..., None]
    numerator_chunk = numerator_chunk * correction + exp_values
    denominator_chunk = denominator_chunk * jnp.exp(prev_max_score_chunk - max_score_chunk) + exp_weights.sum(axis=-1)

But I may miss something in the paper. Any guidance would be much appreciated.

Thanks a lot in advance.

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

No branches or pull requests

1 participant