Upload folder using huggingface_hub
Browse files- rope_constants/README.md +23 -0
- rope_constants/formatted_tensors.json +74 -0
- rope_constants/rope.cos_bf16.npy +3 -0
- rope_constants/rope.cos_fp32.npy +3 -0
- rope_constants/rope.freq_bf16.npy +3 -0
- rope_constants/rope.freq_fp32.npy +3 -0
- rope_constants/rope.sin_bf16.npy +3 -0
- rope_constants/rope.sin_fp32.npy +3 -0
rope_constants/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# RoPE constants
|
| 2 |
+
|
| 3 |
+
## BF16
|
| 4 |
+
|
| 5 |
+
`rope.freq_bf16`:
|
| 6 |
+
- shape: `[1, 4096, 64]`, 4096 denotes maximum sequence length, 64 is half of the head dimension (128/2=64)
|
| 7 |
+
- each element is $m \theta_i$ where $m$ is the position id, $i$ is the head dimension index.
|
| 8 |
+
|
| 9 |
+
`rope.cos_bf16`: `cos_bf16 = cos(freq_bf16)`
|
| 10 |
+
|
| 11 |
+
`rope.sin_bf16`: `sin_bf16 = sin(freq_bf16)`
|
| 12 |
+
|
| 13 |
+
## FP32 for reference
|
| 14 |
+
|
| 15 |
+
HuggingFace forces the RoPE constants to be in FP32 format because both BF16 and FP16 introduce errors in the output cos and sin values. For example, BF16 cannot represent the exact value of 4088, 4089, ..., 4095 (all these values are rounded to 4096). [This issue](https://github.com/huggingface/transformers/pull/29285) discusses this problem.
|
| 16 |
+
|
| 17 |
+
Therefore, we also provide the FP32 version of the RoPE constants for reference. This assumes all the constants are computed in FP32 format.
|
| 18 |
+
|
| 19 |
+
- `rope.freq_fp32`
|
| 20 |
+
- `rope.cos_fp32`
|
| 21 |
+
- `rope.sin_fp32`
|
| 22 |
+
|
| 23 |
+
|
rope_constants/formatted_tensors.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"rope.freq_fp32": {
|
| 3 |
+
"tensor_meta": {
|
| 4 |
+
"is_emulated": false,
|
| 5 |
+
"dtype": "torch.float32",
|
| 6 |
+
"shape": [
|
| 7 |
+
1,
|
| 8 |
+
4096,
|
| 9 |
+
64
|
| 10 |
+
]
|
| 11 |
+
},
|
| 12 |
+
"hex": "saved_tensors/rope_constants/rope.freq_fp32.npy"
|
| 13 |
+
},
|
| 14 |
+
"rope.cos_fp32": {
|
| 15 |
+
"tensor_meta": {
|
| 16 |
+
"is_emulated": false,
|
| 17 |
+
"dtype": "torch.float32",
|
| 18 |
+
"shape": [
|
| 19 |
+
1,
|
| 20 |
+
4096,
|
| 21 |
+
64
|
| 22 |
+
]
|
| 23 |
+
},
|
| 24 |
+
"hex": "saved_tensors/rope_constants/rope.cos_fp32.npy"
|
| 25 |
+
},
|
| 26 |
+
"rope.sin_fp32": {
|
| 27 |
+
"tensor_meta": {
|
| 28 |
+
"is_emulated": false,
|
| 29 |
+
"dtype": "torch.float32",
|
| 30 |
+
"shape": [
|
| 31 |
+
1,
|
| 32 |
+
4096,
|
| 33 |
+
64
|
| 34 |
+
]
|
| 35 |
+
},
|
| 36 |
+
"hex": "saved_tensors/rope_constants/rope.sin_fp32.npy"
|
| 37 |
+
},
|
| 38 |
+
"rope.freq_bf16": {
|
| 39 |
+
"tensor_meta": {
|
| 40 |
+
"is_emulated": false,
|
| 41 |
+
"dtype": "torch.bfloat16",
|
| 42 |
+
"shape": [
|
| 43 |
+
1,
|
| 44 |
+
4096,
|
| 45 |
+
64
|
| 46 |
+
]
|
| 47 |
+
},
|
| 48 |
+
"hex": "saved_tensors/rope_constants/rope.freq_bf16.npy"
|
| 49 |
+
},
|
| 50 |
+
"rope.cos_bf16": {
|
| 51 |
+
"tensor_meta": {
|
| 52 |
+
"is_emulated": false,
|
| 53 |
+
"dtype": "torch.bfloat16",
|
| 54 |
+
"shape": [
|
| 55 |
+
1,
|
| 56 |
+
4096,
|
| 57 |
+
64
|
| 58 |
+
]
|
| 59 |
+
},
|
| 60 |
+
"hex": "saved_tensors/rope_constants/rope.cos_bf16.npy"
|
| 61 |
+
},
|
| 62 |
+
"rope.sin_bf16": {
|
| 63 |
+
"tensor_meta": {
|
| 64 |
+
"is_emulated": false,
|
| 65 |
+
"dtype": "torch.bfloat16",
|
| 66 |
+
"shape": [
|
| 67 |
+
1,
|
| 68 |
+
4096,
|
| 69 |
+
64
|
| 70 |
+
]
|
| 71 |
+
},
|
| 72 |
+
"hex": "saved_tensors/rope_constants/rope.sin_bf16.npy"
|
| 73 |
+
}
|
| 74 |
+
}
|
rope_constants/rope.cos_bf16.npy
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:70f28d596aaacb1646c81846b557189b780c3aaa917d0ae31ba6cfc569c9ea79
|
| 3 |
+
size 4194432
|
rope_constants/rope.cos_fp32.npy
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9ba5f2b91a5cf9a4108e3e78f46b6bf65c5f41ed98497c71551d3986a2d49dcc
|
| 3 |
+
size 8388736
|
rope_constants/rope.freq_bf16.npy
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b0d29ed33793771990e3da32248c20da11bc62aafec23de3a9a6195f05edacb5
|
| 3 |
+
size 4194432
|
rope_constants/rope.freq_fp32.npy
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:055169d5ed6ced2abbce1e07a300ae0354d591c64cf4da94a9b85889d25b88fb
|
| 3 |
+
size 8388736
|
rope_constants/rope.sin_bf16.npy
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9a3da4227ba320912e1099430d803b48c04a0aad48a41b2e8d8d95e7ec23e367
|
| 3 |
+
size 4194432
|
rope_constants/rope.sin_fp32.npy
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bb65963e12c7977d9d9fef8556a107b8c95d54b740c377394f82690a6ccd0abd
|
| 3 |
+
size 8388736
|