Datasets:
Upload folder using huggingface_hub
Browse files- README.md +0 -33
- reference/46_gemv_decode.py +20 -0
- utils/input_output_tensors.py +14 -30
README.md
CHANGED
|
@@ -10,39 +10,6 @@ tags:
|
|
| 10 |
- benchmark
|
| 11 |
size_categories:
|
| 12 |
- n<1K
|
| 13 |
-
configs:
|
| 14 |
-
- config_name: default
|
| 15 |
-
data_files:
|
| 16 |
-
- split: train
|
| 17 |
-
path: data/train-*
|
| 18 |
-
dataset_info:
|
| 19 |
-
features:
|
| 20 |
-
- name: problem_id
|
| 21 |
-
dtype: int64
|
| 22 |
-
- name: stem
|
| 23 |
-
dtype: large_string
|
| 24 |
-
- name: reference_code
|
| 25 |
-
dtype: large_string
|
| 26 |
-
- name: reference_path
|
| 27 |
-
dtype: large_string
|
| 28 |
-
- name: input_tensor_spec_path
|
| 29 |
-
dtype: large_string
|
| 30 |
-
- name: world_size
|
| 31 |
-
dtype: int64
|
| 32 |
-
- name: default_m
|
| 33 |
-
dtype: int64
|
| 34 |
-
- name: default_n
|
| 35 |
-
dtype: int64
|
| 36 |
-
- name: default_dtype
|
| 37 |
-
dtype: large_string
|
| 38 |
-
- name: default_trials
|
| 39 |
-
dtype: int64
|
| 40 |
-
splits:
|
| 41 |
-
- name: train
|
| 42 |
-
num_bytes: 281370
|
| 43 |
-
num_examples: 87
|
| 44 |
-
download_size: 87623
|
| 45 |
-
dataset_size: 281370
|
| 46 |
---
|
| 47 |
|
| 48 |
# ParallelKernelBench (benchmark)
|
|
|
|
| 10 |
- benchmark
|
| 11 |
size_categories:
|
| 12 |
- n<1K
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
---
|
| 14 |
|
| 15 |
# ParallelKernelBench (benchmark)
|
reference/46_gemv_decode.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import torch.distributed as dist
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
@torch.no_grad()
|
| 6 |
+
def solution(
|
| 7 |
+
hidden_states: torch.Tensor,
|
| 8 |
+
weight_shard: torch.Tensor,
|
| 9 |
+
bias_shard: torch.Tensor,
|
| 10 |
+
) -> torch.Tensor:
|
| 11 |
+
world_size = dist.get_world_size()
|
| 12 |
+
|
| 13 |
+
local_logits = torch.matmul(hidden_states, weight_shard.t())
|
| 14 |
+
local_logits = local_logits + bias_shard
|
| 15 |
+
|
| 16 |
+
gathered = [torch.empty_like(local_logits) for _ in range(world_size)]
|
| 17 |
+
dist.all_gather(gathered, local_logits.contiguous())
|
| 18 |
+
logits = torch.cat(gathered, dim=1)
|
| 19 |
+
|
| 20 |
+
return logits
|
utils/input_output_tensors.py
CHANGED
|
@@ -892,38 +892,22 @@ def create_input_tensor(
|
|
| 892 |
eps = 1e-5
|
| 893 |
return (rs_input, gamma, eps)
|
| 894 |
|
| 895 |
-
# 46:
|
| 896 |
elif problem_id == 46:
|
| 897 |
_seed(problem_id, 0, trial)
|
| 898 |
-
|
| 899 |
-
|
| 900 |
-
|
| 901 |
-
|
| 902 |
-
|
| 903 |
-
|
| 904 |
-
|
| 905 |
-
|
| 906 |
-
|
| 907 |
-
|
| 908 |
-
|
| 909 |
-
|
| 910 |
-
|
| 911 |
-
beta2 = 0.999
|
| 912 |
-
eps = 1e-8
|
| 913 |
-
weight_decay = 0.01
|
| 914 |
-
adam_step = 1 + (trial % 7)
|
| 915 |
-
return (
|
| 916 |
-
flat_param_shard,
|
| 917 |
-
flat_grad_shard,
|
| 918 |
-
exp_avg_shard,
|
| 919 |
-
exp_avg_sq_shard,
|
| 920 |
-
lr,
|
| 921 |
-
beta1,
|
| 922 |
-
beta2,
|
| 923 |
-
eps,
|
| 924 |
-
weight_decay,
|
| 925 |
-
adam_step,
|
| 926 |
-
)
|
| 927 |
|
| 928 |
# 47: fsdp_step_e2e
|
| 929 |
elif problem_id == 47:
|
|
|
|
| 892 |
eps = 1e-5
|
| 893 |
return (rs_input, gamma, eps)
|
| 894 |
|
| 895 |
+
# 46: gemv_decode
|
| 896 |
elif problem_id == 46:
|
| 897 |
_seed(problem_id, 0, trial)
|
| 898 |
+
num_tokens = max(1, min(8, M // 1024))
|
| 899 |
+
hidden = max(128, min(N, 4096))
|
| 900 |
+
vocab = _round_up_multiple(max(M, world_size * 1024), world_size)
|
| 901 |
+
local_vocab = vocab // world_size
|
| 902 |
+
|
| 903 |
+
hidden_states = torch.randn((num_tokens, hidden), dtype=dtype, device=dev)
|
| 904 |
+
full_weight = torch.randn((vocab, hidden), dtype=dtype, device=dev)
|
| 905 |
+
full_bias = torch.randn((vocab,), dtype=dtype, device=dev)
|
| 906 |
+
|
| 907 |
+
sl = slice(rank * local_vocab, (rank + 1) * local_vocab)
|
| 908 |
+
weight_shard = full_weight[sl].contiguous()
|
| 909 |
+
bias_shard = full_bias[sl].contiguous()
|
| 910 |
+
return (hidden_states, weight_shard, bias_shard)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 911 |
|
| 912 |
# 47: fsdp_step_e2e
|
| 913 |
elif problem_id == 47:
|