{"library":"rotary-embedding-torch","title":"Rotary Embedding for PyTorch","description":"This library provides a Pytorch implementation of the Rotary Positional Embedding (RoPE), a crucial component for modern transformer architectures like LLaMA, designed to improve the model's ability to handle long sequences. It offers an easy-to-use API to apply rotary embeddings to query and key tensors. The current version is 0.8.9, and it follows a rapid release cadence for bug fixes and minor improvements.","language":"python","status":"active","last_verified":"Fri May 15","install":{"commands":["pip install rotary-embedding-torch"],"cli":null},"imports":["from rotary_embedding_torch import RotaryEmbedding"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import torch\nfrom rotary_embedding_torch import RotaryEmbedding\n\n# Define embedding dimension\ndim = 64\n# Initialize RotaryEmbedding. max_seq_len can be set for pre-computation.\n# If not set, it's computed dynamically based on input.\nrotary_emb = RotaryEmbedding(dim=dim, max_seq_len=2048)\n\n# Create dummy query and key tensors\n# shape: (batch_size, num_heads, sequence_length, head_dim)\nseq_len = 1024\nq = torch.randn(1, 8, seq_len, dim)\nk = torch.randn(1, 8, seq_len, dim)\n\n# Apply rotary embeddings\nq_rot = rotary_emb(q)\nk_rot = rotary_emb(k)\n\nprint(f\"Original query shape: {q.shape}\")\nprint(f\"Rotary-embedded query shape: {q_rot.shape}\")\nprint(f\"Example embedded value (first element): {q_rot[0, 0, 0, 0].item():.4f}\")","lang":"python","description":"This example demonstrates how to initialize `RotaryEmbedding` and apply it to example query and key tensors, typically used in self-attention mechanisms. The `dim` parameter must match the last dimension of your input tensors (head_dim).","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-15","installed_version":"0.8.9","pypi_latest":"0.8.9","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":40,"avg_install_s":66.5,"avg_import_s":5.49,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"rotary-embedding-torch","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"rotary-embedding-torch","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":75.8,"import_time_s":3.79,"mem_mb":59.5,"disk_size":"4.6G"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"rotary-embedding-torch","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"rotary-embedding-torch","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":68.1,"import_time_s":5.99,"mem_mb":64.3,"disk_size":"4.7G"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"rotary-embedding-torch","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"rotary-embedding-torch","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":63.8,"import_time_s":7,"mem_mb":63.2,"disk_size":"4.7G"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"rotary-embedding-torch","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"rotary-embedding-torch","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":58.3,"import_time_s":5.17,"mem_mb":63.6,"disk_size":"4.7G"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"rotary-embedding-torch","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"rotary-embedding-torch","exit_code":1,"wheel_type":null,"failure_reason":"timeout","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null}]}}