IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).

Mojo function

gptj_rotate

def gptj_rotate[pairs: Int, *, odd_fuses_sine: Bool = False](values: SIMD[.float32, (Int(2) * pairs)], cosine: SIMD[.float32, pairs], sine: SIMD[.float32, pairs]) -> SIMD[.float32, (Int(2) * pairs)]

Rotates interleaved (even, odd) channel pairs.

Each output fuses one product into an FMA, as the reference stores' compilers contract even * cos - odd * sin and the odd output. Triton contracts odd * cos + even * sin around odd * cos, CUDA contracts even * sin + odd * cos around even * sin.

Parameters:

  • ​pairs (Int): The number of pairs.
  • ​odd_fuses_sine (Bool): Fuse even * sin rather than odd * cos into the odd output.

Args:

Returns:

SIMD[.float32, (Int(2) * pairs)]: The rotated pairs.

Was this page helpful?