You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fast Rotary Position Embedding value different to transformers? #837
Thanks for the investigation! The trick with Unsloth is we overwrite Q and K to converse VRAM, so the 2nd time you call transformers after Unsloth's function call, the Q and K matrices were already changed. The code snippet below will be correct:
Thanks for the investigation! The trick with Unsloth is we overwrite Q and K to converse VRAM, so the 2nd time you call transformers after Unsloth's function call, the Q and K matrices were already changed. The code snippet below will be correct:
@fahadh4ilyas The discrepancy came from the comparison script: at the time, fast_rope_embedding rotated Q and K in place, so the transformers reference ran on already-rotated tensors.
Regenerating them gives a ~1e-4 difference, which is ordinary float32 error. Closing as answered.
Activity
danielhanchen commentedon Jul 31, 2024
Thanks for the investigation! The trick with Unsloth is we overwrite Q and K to converse VRAM, so the 2nd time you call transformers after Unsloth's function call, the Q and K matrices were already changed. The code snippet below will be correct:
which will print out
fahadh4ilyas commentedon Jul 31, 2024
So, fast rope embedding is change the tensor inplace?
danielhanchen commentedon Aug 2, 2024
Yes currently its in place
oobabooga commentedon Jul 28, 2026
@fahadh4ilyas The discrepancy came from the comparison script: at the time,
fast_rope_embeddingrotated Q and K in place, so the transformers reference ran on already-rotated tensors.Regenerating them gives a ~1e-4 difference, which is ordinary float32 error. Closing as answered.