sahancpal commited on
Commit
dc518c2
·
verified ·
1 Parent(s): 3962aaa

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +111 -0
README.md ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Understanding Trace Files in BackendBench
2
+
3
+ ## Format
4
+ Trace files capture PyTorch operations and their arguments from real model executions:
5
+
6
+ ```
7
+ Operator: operation_name
8
+ cnt: count, serialized_arguments
9
+ cnt: count, serialized_arguments
10
+ ...
11
+ ```
12
+
13
+ ## Structure
14
+
15
+ **Operator line**: Specifies the PyTorch operation
16
+ ```
17
+ Operator: aten.add.Tensor
18
+ Operator: aten.relu.default
19
+ Operator: aten.linear.default
20
+ ```
21
+
22
+ **Count lines**: Show how often each argument combination was used
23
+ ```
24
+ cnt: 42, ((T([10, 20], f16), T([10, 20], f16)), {})
25
+ cnt: 0, ((T([5, 5], f32), T([5, 5], f32)), {})
26
+ ```
27
+
28
+ ## Reading Count Lines
29
+
30
+ **Count `42`**: This argument combination appeared 42 times in traced models
31
+ - **`cnt: 0`** = Synthetic/generated arguments (not from real models)
32
+ - **`cnt: >0`** = Real usage frequency from model traces
33
+
34
+ **Arguments**: Same format as serialized arguments - `((args), {kwargs})`
35
+
36
+ ## Complete Example
37
+
38
+ ```
39
+ Operator: aten.add.Tensor
40
+ cnt: 156, ((T([1, 512, 768], f16), T([1, 512, 768], f16)), {})
41
+ cnt: 89, ((T([32, 128], f32), T([32, 128], f32)), {})
42
+ cnt: 0, ((T([10, 10], f16), T([10, 10], f16)), {})
43
+
44
+ Operator: aten.relu.default
45
+ cnt: 234, ((T([64, 256], f16),), {})
46
+ ```
47
+
48
+ This shows:
49
+ - `aten.add.Tensor` called 156 times with 1×512×768 tensors
50
+ - Same operation called 89 times with 32×128 tensors
51
+ - One synthetic test case (cnt: 0)
52
+ - `aten.relu.default` called 234 times with 64×256 tensor
53
+
54
+ ## Interpretation
55
+ Trace files provide real-world operation usage patterns, showing which tensor shapes and operations are most common in actual PyTorch models. These are fairly useful for debugging.
56
+ Note: These may be deprecated in the future, but are described as they are currently included in the dataset / codebase.
57
+
58
+
59
+ # Understanding Serialized Arguments in BackendBench
60
+ ## Format
61
+ BackendBench stores function arguments as strings containing all parameters needed to reproduce PyTorch operations:
62
+
63
+ ```
64
+ ((arg1, arg2, ...), {'key1': val1, 'key2': val2})
65
+ ```
66
+
67
+ ## Tensor Representation
68
+ Tensors use the format `T([shape], dtype)` or `T([shape], dtype, [stride])`:
69
+
70
+ ```python
71
+ T([10, 20], f32) # 10×20 float32 tensor
72
+ T([1, 512, 768], f16) # 1×512×768 float16 tensor
73
+ T([64], i32) # 64-element int32 vector
74
+ ```
75
+
76
+ **Data types**: `f16/f32/f64` (float), `bf16` (bfloat16), `i32/i64` (int), `b8` (bool)
77
+
78
+ ## Complete Examples
79
+
80
+ **Single tensor argument:**
81
+ ```python
82
+ ((T([48, 24, 28, 28], f16),), {})
83
+ ```
84
+ = Function called with one 48×24×28×28 float16 tensor, no keyword arguments
85
+
86
+ **Multiple tensors:**
87
+ ```python
88
+ ((T([8, 8, 8, 8, 8], f16), T([8, 8, 8, 8, 8], f16)), {})
89
+ ```
90
+ = Function with two identical 5D tensors
91
+
92
+ **Mixed arguments:**
93
+ ```python
94
+ ((T([128, 256], f16), [1024, 249, 249]), {'dtype': torch.float16, 'device': 'cuda'})
95
+ ```
96
+ = Function with tensor, list, and keyword arguments
97
+
98
+ **Complex nested:**
99
+ ```python
100
+ (([T([5, 5], f32), T([3, 3], i64), 42],), {'weight': T([3, 3], f32)})
101
+ ```
102
+ = Function with list containing tensors and numbers, plus tensor keyword argument
103
+
104
+ ## Argument Types
105
+ - **Tensors**: `T([shape], dtype)` format
106
+ - **Lists**: `[item1, item2, ...]` (can contain tensors)
107
+ - **Primitives**: `42`, `'hello'`, `True`, `None`
108
+ - **PyTorch objects**: `torch.float16`, `torch.strided`
109
+
110
+ ## Acknowledgements
111
+ We are extremely grateful for the folks working on [TritonBench](https://github.com/pytorch-labs/tritonbench/tree/main) for these traces and intuitive format