Skip to content

Bug in RoPE #10

@gvlassis

Description

@gvlassis

Hello!

I think your RoPE implementation is wrong. The get_sinusoidal_embeddings() function looks correct, but there are two problems with the apply_rotary_position_embeddings() function:

  1. sinusoidal_emb contains sines in even indices and cosines in odd indices. But sin, cos = sinusoidal_pos.chunk(2, dim=-1) extracts the first and second half of sinusoidal_emb, not the even and odd indices (i.e. there is a problem with the unpacking)
  2. I understand all the tensor manipulations you are doing, but you still never add cosines with sines (which you should do at some point in the canonical RoPE implementation)

ChatGPT seems to agree with me (detects the same two problems even when I do not hint them), but it could be a misunderstanding on my part.

@sashkboos
@iloshchilov
@borisgin

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions