Skip to content

Commit 0f4633b

Browse files
committed
[examples] Add GPT-3 175B workload
1 parent 7156573 commit 0f4633b

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

examples/workloads/gpt3_175B.yaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Each tensor is shaped by a set of ranks, denoted by capital letters
2+
# For example: Q is shaped by (B, M, H, E)
3+
# We'll use lower-case letters to index into the ranks
4+
# For example: Q[b, m, h, e] is the tensor Q at index (b, m, h, e)
5+
6+
# When making a projection list, it's equivalent to the Einsum subscript notation, so:
7+
# Q projection [b, m, h, e] means that b indexes into B, m indexes into M...
8+
# When making a projection dict, it's equivalent to the Einsum subscript/superscript notation, so:
9+
# K projection { B: b, M: p, H: h, E: e } means that b indexes into B, p indexes into M...
10+
11+
# Renames take a tensor name and turn them into a canonical name that we can use in
12+
# architecture constraints. For example, we want to use the words "input", "weight", and
13+
# "output" to refer to the tensors of an Einsum, but the Einsum QK has no clear "weight"
14+
# or "input" because both Q and K are inputs. So we rename K to be weight.
15+
16+
17+
workload:
18+
rank_sizes:
19+
{% set BATCH_SIZE = BATCH_SIZE | default(1) %}
20+
{% set N_TOKENS = N_TOKENS | default(8192) %}
21+
B: {{BATCH_SIZE}}
22+
P: {{N_TOKENS}}
23+
M: {{N_TOKENS}}
24+
H: 96
25+
E: 128
26+
F: 128
27+
D: 96*128 # = e * h
28+
C: 4*96*128
29+
J: 96*128
30+
G: 96*128
31+
32+
bits_per_value: {All: 8}
33+
persistent_tensors: weight - Intermediates
34+
35+
einsums:
36+
- einsum: I(output)[b, m, d] = I_in(input)[b, m, d]
37+
is_copy_operation: True
38+
- V[b, m, h, e] = I[b, m, d] * WV[h, e, d]
39+
- K[b, m, h, e] = I[b, m, d] * WK[h, e, d]
40+
- Q[b, m, h, e] = I[b, m, d] * WQ[h, e, d]
41+
- QK[b, m, p, h] = Q(input)[b, m, h, e] * K(weight)[b, M=p, h, e]
42+
- QK_softmax[b, m, p, h] = QK(input)[b, m, p, h]
43+
- AV[b, m, h, f] = QK_softmax(input)[b, m, p, h] * V(weight)[b, M=p, H=h, E=f]
44+
- Z[b, m, g] = AV[b, m, h, f] * WZ[h, f, g]
45+
- FFA[b, m, c] = Z[b, m, g] * WFFA[g, c]
46+
- FFB[b, m, j] = FFA[b, m, c] * WFFB[c, j]
47+
48+
renames:
49+
einsums:
50+
- name: default
51+
tensor_accesses:
52+
- name: input
53+
source: Inputs & Intermediates
54+
expected_count: 1
55+
- name: output
56+
source: Outputs
57+
expected_count: 1
58+
- name: weight
59+
source: ~(input | output)
60+
expected_count: 1 if len(All) == 3 else 0

0 commit comments

Comments
 (0)