Dataset Preview
Duplicate
The full dataset viewer is not available (click to read why). Only showing a preview of the rows.
The dataset generation failed because of a cast error
Error code:   DatasetGenerationCastError
Exception:    DatasetGenerationCastError
Message:      An error occurred while generating the dataset

All the data files must have the same columns, but at some point there are 1 new columns ({'gemm.output'}) and 3 missing columns ({'dot_product.b', 'dot_product.a', 'dot_product.output'}).

This happened while the json dataset builder was generating data using

hf://datasets/edteams/ref-ops-v2/gemm/m-4_n-4096_k-4096_seed-0/formatted_tensors.json (at revision 8688e0f16a0b40286826f4c99e2a96d6ef9c597a)

Please either edit the data files to have matching columns, or separate them into different configurations (see docs at https://hf.co/docs/hub/datasets-manual-configuration#multiple-configurations)
Traceback:    Traceback (most recent call last):
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 1831, in _prepare_split_single
                  writer.write_table(table)
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/arrow_writer.py", line 644, in write_table
                  pa_table = table_cast(pa_table, self._schema)
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/table.py", line 2272, in table_cast
                  return cast_table_to_schema(table, schema)
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/table.py", line 2218, in cast_table_to_schema
                  raise CastError(
              datasets.table.CastError: Couldn't cast
              gemm.output: struct<tensor_meta: struct<is_emulated: bool, dtype: string, shape: list<item: int64>>, hex: string>
                child 0, tensor_meta: struct<is_emulated: bool, dtype: string, shape: list<item: int64>>
                    child 0, is_emulated: bool
                    child 1, dtype: string
                    child 2, shape: list<item: int64>
                        child 0, item: int64
                child 1, hex: string
              to
              {'dot_product.a': {'tensor_meta': {'is_emulated': Value('bool'), 'dtype': Value('string'), 'block_size': Value('int64'), 'block_axis': Value('int64'), 'shape': List(Value('int64')), 'round_mode': Value('string')}, 'hex': Value('string')}, 'dot_product.b': {'tensor_meta': {'is_emulated': Value('bool'), 'dtype': Value('string'), 'block_size': Value('int64'), 'block_axis': Value('int64'), 'shape': List(Value('int64')), 'round_mode': Value('string')}, 'hex': Value('string')}, 'dot_product.output': {'tensor_meta': {'is_emulated': Value('bool'), 'dtype': Value('string'), 'shape': List(Value('int64'))}, 'hex': Value('string')}}
              because column names don't match
              
              During handling of the above exception, another exception occurred:
              
              Traceback (most recent call last):
                File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 1456, in compute_config_parquet_and_info_response
                  parquet_operations = convert_to_parquet(builder)
                File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 1055, in convert_to_parquet
                  builder.download_and_prepare(
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 894, in download_and_prepare
                  self._download_and_prepare(
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 970, in _download_and_prepare
                  self._prepare_split(split_generator, **prepare_split_kwargs)
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 1702, in _prepare_split
                  for job_id, done, content in self._prepare_split_single(
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 1833, in _prepare_split_single
                  raise DatasetGenerationCastError.from_cast_error(
              datasets.exceptions.DatasetGenerationCastError: An error occurred while generating the dataset
              
              All the data files must have the same columns, but at some point there are 1 new columns ({'gemm.output'}) and 3 missing columns ({'dot_product.b', 'dot_product.a', 'dot_product.output'}).
              
              This happened while the json dataset builder was generating data using
              
              hf://datasets/edteams/ref-ops-v2/gemm/m-4_n-4096_k-4096_seed-0/formatted_tensors.json (at revision 8688e0f16a0b40286826f4c99e2a96d6ef9c597a)
              
              Please either edit the data files to have matching columns, or separate them into different configurations (see docs at https://hf.co/docs/hub/datasets-manual-configuration#multiple-configurations)

Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.

dot_product.a
dict
dot_product.b
dict
dot_product.output
dict
{ "tensor_meta": { "is_emulated": true, "dtype": "emulated_mxint8", "block_size": 32, "block_axis": 0, "shape": [ 4096 ], "round_mode": "trunc" }, "hex": "saved_tensors/dot_product/size-4096_seed-0/dot_product.a.npy" }
{ "tensor_meta": { "is_emulated": true, "dtype": "emulated_mxint8", "block_size": 32, "block_axis": 0, "shape": [ 4096 ], "round_mode": "trunc" }, "hex": "saved_tensors/dot_product/size-4096_seed-0/dot_product.b.npy" }
{ "tensor_meta": { "is_emulated": false, "dtype": "torch.bfloat16", "shape": [ 1 ] }, "hex": "saved_tensors/dot_product/size-4096_seed-0/dot_product.output.npy" }
{ "tensor_meta": { "is_emulated": true, "dtype": "emulated_mxint8", "block_size": 32, "block_axis": 0, "shape": [ 4096 ], "round_mode": "trunc" }, "hex": "saved_tensors/dot_product/size-4096_seed-1/dot_product.a.npy" }
{ "tensor_meta": { "is_emulated": true, "dtype": "emulated_mxint8", "block_size": 32, "block_axis": 0, "shape": [ 4096 ], "round_mode": "trunc" }, "hex": "saved_tensors/dot_product/size-4096_seed-1/dot_product.b.npy" }
{ "tensor_meta": { "is_emulated": false, "dtype": "torch.bfloat16", "shape": [ 1 ] }, "hex": "saved_tensors/dot_product/size-4096_seed-1/dot_product.output.npy" }
{ "tensor_meta": { "is_emulated": true, "dtype": "emulated_mxint8", "block_size": 32, "block_axis": 0, "shape": [ 4096 ], "round_mode": "trunc" }, "hex": "saved_tensors/dot_product/size-4096_seed-2/dot_product.a.npy" }
{ "tensor_meta": { "is_emulated": true, "dtype": "emulated_mxint8", "block_size": 32, "block_axis": 0, "shape": [ 4096 ], "round_mode": "trunc" }, "hex": "saved_tensors/dot_product/size-4096_seed-2/dot_product.b.npy" }
{ "tensor_meta": { "is_emulated": false, "dtype": "torch.bfloat16", "shape": [ 1 ] }, "hex": "saved_tensors/dot_product/size-4096_seed-2/dot_product.output.npy" }
{ "tensor_meta": { "is_emulated": true, "dtype": "emulated_mxint8", "block_size": 32, "block_axis": 0, "shape": [ 4096 ], "round_mode": "trunc" }, "hex": "saved_tensors/dot_product/size-4096_seed-3/dot_product.a.npy" }
{ "tensor_meta": { "is_emulated": true, "dtype": "emulated_mxint8", "block_size": 32, "block_axis": 0, "shape": [ 4096 ], "round_mode": "trunc" }, "hex": "saved_tensors/dot_product/size-4096_seed-3/dot_product.b.npy" }
{ "tensor_meta": { "is_emulated": false, "dtype": "torch.bfloat16", "shape": [ 1 ] }, "hex": "saved_tensors/dot_product/size-4096_seed-3/dot_product.output.npy" }
{ "tensor_meta": { "is_emulated": true, "dtype": "emulated_mxint8", "block_size": 32, "block_axis": 0, "shape": [ 4096 ], "round_mode": "trunc" }, "hex": "saved_tensors/dot_product/size-4096_seed-4/dot_product.a.npy" }
{ "tensor_meta": { "is_emulated": true, "dtype": "emulated_mxint8", "block_size": 32, "block_axis": 0, "shape": [ 4096 ], "round_mode": "trunc" }, "hex": "saved_tensors/dot_product/size-4096_seed-4/dot_product.b.npy" }
{ "tensor_meta": { "is_emulated": false, "dtype": "torch.bfloat16", "shape": [ 1 ] }, "hex": "saved_tensors/dot_product/size-4096_seed-4/dot_product.output.npy" }
{ "tensor_meta": { "is_emulated": true, "dtype": "emulated_mxint8", "block_size": 32, "block_axis": 0, "shape": [ 4096 ], "round_mode": "trunc" }, "hex": "saved_tensors/dot_product/size-4096_seed-5/dot_product.a.npy" }
{ "tensor_meta": { "is_emulated": true, "dtype": "emulated_mxint8", "block_size": 32, "block_axis": 0, "shape": [ 4096 ], "round_mode": "trunc" }, "hex": "saved_tensors/dot_product/size-4096_seed-5/dot_product.b.npy" }
{ "tensor_meta": { "is_emulated": false, "dtype": "torch.bfloat16", "shape": [ 1 ] }, "hex": "saved_tensors/dot_product/size-4096_seed-5/dot_product.output.npy" }
{ "tensor_meta": { "is_emulated": true, "dtype": "emulated_mxint8", "block_size": 32, "block_axis": 0, "shape": [ 4096 ], "round_mode": "trunc" }, "hex": "saved_tensors/dot_product/size-4096_seed-6/dot_product.a.npy" }
{ "tensor_meta": { "is_emulated": true, "dtype": "emulated_mxint8", "block_size": 32, "block_axis": 0, "shape": [ 4096 ], "round_mode": "trunc" }, "hex": "saved_tensors/dot_product/size-4096_seed-6/dot_product.b.npy" }
{ "tensor_meta": { "is_emulated": false, "dtype": "torch.bfloat16", "shape": [ 1 ] }, "hex": "saved_tensors/dot_product/size-4096_seed-6/dot_product.output.npy" }
{ "tensor_meta": { "is_emulated": true, "dtype": "emulated_mxint8", "block_size": 32, "block_axis": 0, "shape": [ 4096 ], "round_mode": "trunc" }, "hex": "saved_tensors/dot_product/size-4096_seed-7/dot_product.a.npy" }
{ "tensor_meta": { "is_emulated": true, "dtype": "emulated_mxint8", "block_size": 32, "block_axis": 0, "shape": [ 4096 ], "round_mode": "trunc" }, "hex": "saved_tensors/dot_product/size-4096_seed-7/dot_product.b.npy" }
{ "tensor_meta": { "is_emulated": false, "dtype": "torch.bfloat16", "shape": [ 1 ] }, "hex": "saved_tensors/dot_product/size-4096_seed-7/dot_product.output.npy" }
{ "tensor_meta": { "is_emulated": true, "dtype": "emulated_mxint8", "block_size": 32, "block_axis": 0, "shape": [ 4096 ], "round_mode": "trunc" }, "hex": "saved_tensors/dot_product/size-4096_seed-8/dot_product.a.npy" }
{ "tensor_meta": { "is_emulated": true, "dtype": "emulated_mxint8", "block_size": 32, "block_axis": 0, "shape": [ 4096 ], "round_mode": "trunc" }, "hex": "saved_tensors/dot_product/size-4096_seed-8/dot_product.b.npy" }
{ "tensor_meta": { "is_emulated": false, "dtype": "torch.bfloat16", "shape": [ 1 ] }, "hex": "saved_tensors/dot_product/size-4096_seed-8/dot_product.output.npy" }
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null

YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

Reference Operations V2

Dot Product

  • MXINT8 dot product
# sum(a .* b), dot product
# a.shape: [m]
# b.shape: [m]
# output.shape: scalar
output = dot_product(a, b)
  • MXINT8 vector-matrix multiplication
# vector @ matrix, vector-matrix multiplication
# vector.shape: [m]
# matrix.shape: [m, k]
# output.shape: [k]
output = gevm(vector, matrix)
  • MXINT8 matrix-matrix multiplication
# input @ other, matrix-matrix multiplication
# input.shape: [m, k]
# other.shape: [k, n]
# output.shape: [m, n]
output = gemm(input, other)

RoPE constants

BF16

Dumped tensors:

rope.freq_bf16:

  • shape: [1, 4096, 64], 4096 denotes maximum sequence length, 64 is half of the head dimension (128/2=64)
  • each element is $m \theta_i$ where $m$ is the position id, $i$ is the head dimension index.

rope.cos_bf16: cos_bf16 = cos(freq_bf16)

rope.sin_bf16: sin_bf16 = sin(freq_bf16)

FP32 for reference

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 discusses this problem.

Therefore, we also provide the FP32 version of the RoPE constants for reference. This assumes all the constants are computed in FP32 format.

  • rope.freq_fp32
  • rope.cos_fp32
  • rope.sin_fp32

Softmax

softmax_v is a function that computes the matmul(softmax(qk_T), v) operation in the attention layer. To match the HW behaviour, softmax_v is broken down into the following steps:

def softmaxed_v(qk_T, v):
    """
    qk_T.shape: [bs, num_heads, seq_q_len, seq_kv_len]
    v.shape: [bs, num_heads, seq_kv_len, head_dim]
    """

    # elementwise exp
    exp_bf16 = row_exp(qk_T, dim=-1) # shape: [bs, num_heads, seq_q_len, seq_kv_len]
    # sum exp along the head dimension
    exp_sum = reduce_sum(exp_bf16, dim=-1) # shape: [bs, num_heads, seq_q_len, 1]
    # quantize to mxint8 for vector-matrix multiplication
    exp_mxint8 = quantize(exp_bf16)
    # vector-matrix multiplication between two mxint8 tensors
    scaled_v = mxint8_gevm(exp_mxint8, v) # shape: [bs, num_heads, seq_q_len, head_dim]
    # inverse of the sum
    inv = 1.0 / exp_sum # shape: [bs, num_heads, seq_q_len, 1]
    # adjust scaled_v by the inverse
    out = scaled_v * inv # shape: [bs, num_heads, seq_q_len, head_dim]
    return out
Notation Description
bs batch size, 1 in this case
num_heads number of attention heads, 32 for llama-2-7b
seq_q_len query sequence length, 1 in this case
seq_kv_len key-value sequence length, which increments by 1 for each decoding step
head_dim head dimension, 128 for llama-2-7b

The folder name takes the form kv-size-<seq_kv_len>_seed-<seed>. For example, kv-size-4_seed-0 means the key-value sequence length is 4 and the random seed is 0.

The following tensors are dumped:

File Name Description
softmaxed_v.qk_T BF16 qk_T tensor
softmaxed_v.exp-bf16 BF16 exp_bf16 tensor
softmaxed_v.exp_sum BF16 exp_sum tensor
softmaxed_v.v MXINT8 v tensor
softmaxed_v.exp_mxint8 MXINT8 exp_mxint8 tensor
softmaxed_v.scaled_v BF16 scaled_v tensor
softmaxed_v.inv BF16 inv tensor
softmaxed_v.out BF16 out tensor
Downloads last month
3