Xenova's picture
Xenova HF Staff
sync 2e7068faf55e
cc4bd23 verified
Raw
History Blame
10.1 kB
{
"op": "com.microsoft.GemmaRotaryEmbedding",
"cases": [
{
"name": "f16_vec4",
"provenance": {
"notes": "float16 operands with a float32 emb, which is the type pair ONNX Runtime constrains this operator to. Sin and cos are computed at float32 and rounded once."
},
"inputs": {
"embT": {
"dtype": "float32",
"shape": [2, 4, 8],
"data": { "kind": "fillFloat32", "scale": 2.5, "sinStep": 0.23, "cosStep": 0.37 }
},
"qT": {
"dtype": "float16",
"shape": [2, 2, 4, 8],
"data": {
"kind": "fillFloat32",
"scale": 0.8,
"sinStep": 0.16999999999999998,
"cosStep": 0.29000000000000004
}
},
"qRotT": {
"dtype": "float16",
"shape": [2, 2, 4, 8],
"data": { "kind": "fillFloat32", "scale": 0.8, "sinStep": 0.43, "cosStep": 0.13 }
},
"kT": {
"dtype": "float16",
"shape": [2, 2, 4, 8],
"data": { "kind": "fillFloat32", "scale": 0.8, "sinStep": 0.35, "cosStep": 0.19 }
},
"kRotT": {
"dtype": "float16",
"shape": [2, 2, 4, 8],
"data": { "kind": "fillFloat32", "scale": 0.8, "sinStep": 0.47, "cosStep": 0.25 }
}
},
"outputs": {
"output1T": { "dtype": "float16", "shape": [2, 2, 4, 8], "tolerance": 0.005 },
"output2T": { "dtype": "float16", "shape": [2, 2, 4, 8], "tolerance": 0.005 }
}
},
{
"name": "f16_scalar",
"provenance": { "notes": "float16 on the scalar variant, dim 5." },
"inputs": {
"embT": {
"dtype": "float32",
"shape": [2, 3, 5],
"data": { "kind": "fillFloat32", "scale": 2.5, "sinStep": 0.24000000000000002, "cosStep": 0.38 }
},
"qT": {
"dtype": "float16",
"shape": [2, 2, 3, 5],
"data": { "kind": "fillFloat32", "scale": 0.8, "sinStep": 0.18, "cosStep": 0.30000000000000004 }
},
"qRotT": {
"dtype": "float16",
"shape": [2, 2, 3, 5],
"data": { "kind": "fillFloat32", "scale": 0.8, "sinStep": 0.44, "cosStep": 0.14 }
},
"kT": {
"dtype": "float16",
"shape": [2, 2, 3, 5],
"data": { "kind": "fillFloat32", "scale": 0.8, "sinStep": 0.36, "cosStep": 0.2 }
},
"kRotT": {
"dtype": "float16",
"shape": [2, 2, 3, 5],
"data": { "kind": "fillFloat32", "scale": 0.8, "sinStep": 0.48, "cosStep": 0.26 }
}
},
"outputs": {
"output1T": { "dtype": "float16", "shape": [2, 2, 3, 5], "tolerance": 0.005 },
"output2T": { "dtype": "float16", "shape": [2, 2, 3, 5], "tolerance": 0.005 }
}
},
{
"name": "pinned_f16_round_before_add",
"provenance": {
"notes": "Pins the round-to-T-before-add rule at float16. Every element is a near-cancellation: the two products are around 100 in magnitude and their sum is under 1, so rounding each product to float16 before the add moves the result by 150 to 900 ulps, while a backend that contracted the multiply into an fma and kept a float32 product would land somewhere else entirely. The angles were chosen so their float16 sin and cos survive several ulps of perturbation, so this does not test the GPU's transcendental."
},
"inputs": {
"embT": {
"dtype": "float32",
"shape": [1, 2, 4],
"data": {
"kind": "values",
"values": [0.896741, -0.7510284, 2.9392502, 2.4113605, 2.7308347, -2.6883833, -0.7908616, -0.4171633]
}
},
"qT": {
"dtype": "float16",
"shape": [1, 1, 2, 4],
"data": { "kind": "values", "values": [-105.625, 248.375, 232.875, 109.75, 214.75, 205.75, -98.5625, -142.0] }
},
"qRotT": {
"dtype": "float16",
"shape": [1, 1, 2, 4],
"data": { "kind": "values", "values": [84.4375, 266.0, 1135.0, 122.25, 493.25, -421.0, -98.0625, -322.25] }
},
"kT": {
"dtype": "float16",
"shape": [1, 1, 2, 4],
"data": {
"kind": "values",
"values": [-239.625, 217.875, 249.125, -202.125, -127.8125, -135.75, 118.4375, 208.75]
}
},
"kRotT": {
"dtype": "float16",
"shape": [1, 1, 2, 4],
"data": { "kind": "values", "values": [-165.25, 194.25, -411.75, 281.25, 252.375, 151.25, -194.0, -455.5] }
}
},
"outputs": {
"output1T": {
"dtype": "float16",
"shape": [1, 1, 2, 4],
"data": { "kind": "values", "values": [0.0, -0.125, -0.125, -0.1875, 0.125, -0.75, 0.375, 0.875] },
"tolerance": 0.005
},
"output2T": {
"dtype": "float16",
"shape": [1, 1, 2, 4],
"data": { "kind": "values", "values": [-278.5, 26.625, -326.75, 338.25, 218.0, 55.8125, 221.125, 375.5] },
"tolerance": 0.005
}
}
},
{
"name": "pinned_batch2_emb_broadcast",
"provenance": {
"notes": "Hand-computed by an independent model that Unsqueezes emb to (batch, 1, seq, dim) and broadcasts with real array shapes, never forming a flat index -- which is the step ONNX Runtime's own unit test gets wrong: it indexes emb by num_heads where the CUDA kernel uses seq_len, and its only case has batch_size 1, where the wrong term is multiplied by zero. heads (3) and seq_len (2) differ here and batch is 2, so the two disagree."
},
"inputs": {
"embT": {
"dtype": "float32",
"shape": [2, 2, 4],
"data": {
"kind": "values",
"values": [-2.75, -2.383333, -2.016667, -1.65, -1.283333, -0.916667, -0.55, -0.183333, 0.183333, 0.55, 0.916667, 1.283333, 1.65, 2.016667, 2.383333, 2.75]
}
},
"qT": {
"dtype": "float16",
"shape": [2, 3, 2, 4],
"data": {
"kind": "values",
"values": [0.686035, -0.222046, -0.056, -0.728027, 0.777832, -0.014, 0.219971, -0.970215, 0.512207, -0.260986, -0.564941, 0.10498, -0.898926, -0.805176, -0.737793, 0.758789, 0.099976, -0.890137, 0.366943, 0.452881, -0.427979, 0.220947, -0.284912, -0.829102, 0.36499, 0.771973, 0.406006, 0.899902, 0.604004, 0.124023, 0.341064, 0.088013, 0.03299, -0.908203, 0.726074, 0.077026, -0.650879, -0.657227, 0.290039, 0.905762, 0.600098, -0.36499, -0.568848, 0.399902, -0.366943, 0.542969, 0.333984, -0.650879]
}
},
"qRotT": {
"dtype": "float16",
"shape": [2, 3, 2, 4],
"data": {
"kind": "values",
"values": [0.368896, 0.120972, 0.058014, 0.370117, -0.188965, 0.052002, 0.64209, -0.974121, -0.845215, -0.566895, 0.748047, 0.915039, -0.520996, -0.717773, 0.74707, -0.085022, -0.570801, 0.869141, 0.112976, -0.671875, -0.346924, -0.794922, -0.644043, -0.182007, 0.862793, -0.569824, -0.189941, -0.253906, -0.791016, -0.698242, 0.540039, 0.003, -0.426025, 0.733887, -0.112, -0.364014, -0.724121, 0.167969, -0.540039, 0.088989, 0.011002, 0.203003, -0.213989, -0.292969, -0.151001, 0.895996, 0.682129, 0.910156]
}
},
"kT": {
"dtype": "float16",
"shape": [2, 3, 2, 4],
"data": {
"kind": "values",
"values": [-0.395996, -0.052002, 0.120972, -0.955078, -0.782227, 0.232056, -0.702148, 0.06897, 0.581055, 0.923828, -0.251953, 0.258057, -0.813965, -0.799805, 0.491943, -0.418945, 0.583008, -0.597168, 0.333008, 0.731934, 0.852051, -0.009003, -0.476074, 0.206055, -0.527832, 0.714844, 0.948242, -0.370117, 0.729004, 0.481934, -0.527832, -0.467041, -0.711914, 0.515137, 0.551758, -0.099976, -0.858887, -0.544922, 0.580078, 0.621094, -0.52002, -0.331055, 0.326904, -0.25293, 0.430908, -0.585938, -0.588867, -0.177002]
}
},
"kRotT": {
"dtype": "float16",
"shape": [2, 3, 2, 4],
"data": {
"kind": "values",
"values": [0.106018, 0.551758, 0.952148, -0.405029, 0.814941, -0.312012, -0.819824, 0.955078, -0.234009, 0.085022, 0.008003, 0.471924, 0.798828, -0.641113, 0.679199, -0.859863, -0.974121, -0.881836, -0.122986, -0.63623, 0.18396, 0.156006, 0.094971, 0.619141, -0.366943, 0.041992, 0.945801, -0.298096, 0.036011, 0.471924, 0.223999, 0.214966, 0.890137, 0.748047, 0.523926, 0.665039, 0.189941, 0.49292, -0.488037, -0.437012, 0.37207, -0.284912, 0.765137, 0.020996, -0.462891, -0.111023, -0.63916, 0.460938]
}
}
},
"outputs": {
"output1T": {
"dtype": "float16",
"shape": [2, 3, 2, 4],
"data": {
"kind": "values",
"values": [-0.774902, 0.078064, -0.028198, -0.311523, 0.401855, -0.049774, -0.147949, -0.776367, -0.150879, 0.579102, -0.431152, -0.920898, 0.244629, 0.07959, -1.019531, 0.761719, 0.125366, 0.048828, -0.260254, 0.634277, 0.211426, 0.765137, 0.093506, -0.782227, 0.516113, 0.360596, 0.096313, 0.011597, -0.836426, -0.683594, 0.123657, -0.0802, -0.045197, -0.390869, 0.352783, -0.327393, -0.670898, 0.435059, -0.582031, -0.803223, 0.592285, -0.2052, -0.516113, -0.167725, -0.12146, 0.574219, 0.22644, 0.949219]
},
"tolerance": 0.005
},
"output2T": {
"dtype": "float16",
"shape": [2, 3, 2, 4],
"data": {
"kind": "values",
"values": [0.325439, -0.341553, -0.911621, 0.479492, -1.003906, 0.388672, -0.17041, -0.106262, -0.447754, -0.729492, 0.10144, -0.490967, -0.99707, 0.022217, 0.064697, -0.255371, -0.167236, 1.040039, -0.032593, 0.576172, 0.065063, -0.129272, -0.455322, 0.089783, -0.585938, 0.631348, 1.328125, -0.390869, -0.021759, 0.218018, 0.537109, 0.513672, -0.538086, 0.830078, 0.751465, 0.609375, 0.257324, 0.679688, -0.756836, -0.741211, -0.443359, -0.431152, 0.805664, -0.051575, -0.495605, 0.152588, -0.011963, 0.339355]
},
"tolerance": 0.005
}
}
}
]
}