Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/CUDApp/blob/main/backend/amd/gfx942/rope.om # CUDApp CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `CUDApp / backend / amd / gfx942 / rope.om` 107 lines · 2163 bytes Raw Blame History 1 om2 2 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 note Q27 config `017b9c7a`: theta `10000000`, rotary dim 64; text positions share all MRoPE axes. 4 note Input exactly one little-endian u32 position; output cos[32], sin[32] binary32 words. 5 note Explicit binary32 frequency, position and angle boundaries follow Transformers v5.8.0. 6 note Binary64 exp and Cody-Waite reduction; no libm, host runtime, Python or GPU dependency. 7 note Exit 64 for a malformed position record, 74 for I/O failure. No output on malformed input. 8 global rin uchar 4 9 global rout uchar 256 10 global rend uchar 1 11 global trig f64 2 12 fn rexp x f64 to f64 13 n = uint div x 0.`6931471805599453f64` 14 r = sub x mul f64 n 0.`6931471805599453f64` 15 t = 1.0f64 16 y = 1.0f64 17 for j ulong 18 18 t = div mul t r f64 add j 1 19 y = add y t 20 end 21 scale = bitcast f64 shl add ulong n 1023 52 22 ret mul y scale 23 end 24 fn rfreq i ulong to f32 25 x = div mul f64 i 16.`11809565095832f64` 32.0f64 26 power = f32 rexp x 27 ret div 1.0f32 power 28 end 29 fn rtrig x f64 to void 30 n = ulong add mul x 0.`6366197723675813f64` 0.5f64 31 r = sub x mul f64 n 1.`570796012878418f64` 32 r = sub r mul f64 n bitcast f64 ulong 0x3e95110b4611a626 33 z = neg mul r r 34 st = r 35 sv = r 36 ct = 1.0f64 37 cv = 1.0f64 38 for j ulong 10 39 k = add mul j 2 2 40 st = div mul st z f64 mul k add k 1 41 ct = div mul ct z f64 mul k sub k 1 42 sv = add sv st 43 cv = add cv ct 44 end 45 q = and n 3 46 if eq q 0 47 put trig 0 cv 48 put trig 1 sv 49 end 50 if eq q 1 51 put trig 0 neg sv 52 put trig 1 cv 53 end 54 if eq q 2 55 put trig 0 neg cv 56 put trig 1 neg sv 57 end 58 if eq q 3 59 put trig 0 sv 60 put trig 1 neg cv 61 end 62 end 63 fn rput p ulong x f64 to void 64 b = ulong bitcast uint f32 x 65 for j ulong 4 66 put rout add p j uchar and shr b mul j 8 255 67 end 68 end 69 fn main to int 70 n = ulong 0 71 while lt n 4 bound 999999 72 r = read 0 rin n sub 4 n 73 if lt r 0 74 ret 74 75 end 76 if eq r 0 77 ret 64 78 end 79 n = add n ulong r 80 end 81 r = read 0 rend 0 1 82 if lt r 0 83 ret 74 84 end 85 if ne r 0 86 ret 64 87 end 88 p = ulong 0 89 for j ulong 4 90 p = or p shl ulong get rin j mul j 8 91 end 92 for i ulong 32 93 angle = mul f32 p rfreq i 94 rtrig f64 angle 95 rput mul i 4 get trig 0 96 rput add 128 mul i 4 get trig 1 97 end 98 n = 0 99 while lt n 256 bound 999999 100 r = write 1 rout n sub 256 n 101 if le r 0 102 ret 74 103 end 104 n = add n ulong r 105 end 106 ret 0 107 end