File size: 9,798 Bytes
2d13eb2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | [
{
"function_name": "__init__",
"file_path": "multihead_diffattn.py",
"function_calls": [
{
"function_call_name": "super().__init__",
"functionality": "Initializes the base class (nn.Module).",
"input": "self",
"output": "None",
"location_or_namespace": "torch.nn.Module"
},
{
"function_call_name": "nn.Linear",
"functionality": "Applies a linear transformation to the incoming data. Used here to initialize projection layers.",
"input": "in_features, out_features, bias=True",
"output": "torch.nn.Linear object",
"location_or_namespace": "torch.nn"
},
{
"function_call_name": "lambda_init_fn",
"functionality": "Calculates an initial lambda value based on layer depth using the formula 0.8 - 0.6 * math.exp(-0.3 * depth).",
"input": "depth (int)",
"output": "float",
"location_or_namespace": "multihead_diffattn.py"
},
{
"function_call_name": "torch.zeros",
"functionality": "Returns a tensor filled with the scalar value 0.",
"input": "size, *, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False",
"output": "torch.Tensor",
"location_or_namespace": "torch"
},
{
"function_call_name": "normal_",
"functionality": "Fills self tensor with elements sampled from the normal distribution (in-place).",
"input": "mean=0, std=1, *, generator=None",
"output": "torch.Tensor (in-place)",
"location_or_namespace": "torch.Tensor"
},
{
"function_call_name": "nn.Parameter",
"functionality": "A kind of Tensor that is to be considered a module parameter.",
"input": "data (torch.Tensor), requires_grad=True",
"output": "torch.nn.Parameter object",
"location_or_namespace": "torch.nn"
},
{
"function_call_name": "RMSNorm",
"functionality": "Initializes the RMSNorm layer. Assumed to be custom RMSNorm from rms_norm.py if Apex FusedRMSNorm is not found.",
"input": "normalized_shape (int or torch.Size), eps (float), elementwise_affine (bool)",
"output": "RMSNorm object",
"location_or_namespace": "rms_norm.py"
}
]
},
{
"function_name": "forward",
"file_path": "multihead_diffattn.py",
"function_calls": [
{
"function_call_name": "size",
"functionality": "Returns the size of the tensor.",
"input": "",
"output": "torch.Size",
"location_or_namespace": "torch.Tensor"
},
{
"function_call_name": "self.q_proj",
"functionality": "Applies the q_proj linear transformation (instance of nn.Linear).",
"input": "x (torch.Tensor)",
"output": "torch.Tensor",
"location_or_namespace": "torch.nn.Linear"
},
{
"function_call_name": "self.k_proj",
"functionality": "Applies the k_proj linear transformation (instance of nn.Linear).",
"input": "x (torch.Tensor)",
"output": "torch.Tensor",
"location_or_namespace": "torch.nn.Linear"
},
{
"function_call_name": "self.v_proj",
"functionality": "Applies the v_proj linear transformation (instance of nn.Linear).",
"input": "x (torch.Tensor)",
"output": "torch.Tensor",
"location_or_namespace": "torch.nn.Linear"
},
{
"function_call_name": "view",
"functionality": "Returns a new tensor with the same data but different shape.",
"input": "*shape (tuple of ints)",
"output": "torch.Tensor",
"location_or_namespace": "torch.Tensor"
},
{
"function_call_name": "apply_rotary_emb",
"functionality": "Applies rotary positional embeddings to the input tensor.",
"input": "x (torch.Tensor), freqs_cis (torch.Tensor), interleaved (bool)",
"output": "torch.Tensor",
"location_or_namespace": "kernel/rotary.py"
},
{
"function_call_name": "transpose",
"functionality": "Returns a transposed version of the tensor by swapping two specified dimensions.",
"input": "dim0 (int), dim1 (int)",
"output": "torch.Tensor",
"location_or_namespace": "torch.Tensor"
},
{
"function_call_name": "repeat_kv",
"functionality": "Repeats Key/Value tensors n_rep times for grouped query attention.",
"input": "x (torch.Tensor), n_rep (int)",
"output": "torch.Tensor",
"location_or_namespace": "multihead_diffattn.py"
},
{
"function_call_name": "torch.matmul",
"functionality": "Matrix product of two tensors.",
"input": "input (torch.Tensor), other (torch.Tensor), *, out=None",
"output": "torch.Tensor",
"location_or_namespace": "torch"
},
{
"function_call_name": "torch.zeros",
"functionality": "Returns a tensor filled with the scalar value 0.",
"input": "size, *, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False",
"output": "torch.Tensor",
"location_or_namespace": "torch"
},
{
"function_call_name": "float",
"functionality": "Casts self tensor to float dtype.",
"input": "",
"output": "torch.Tensor",
"location_or_namespace": "torch.Tensor"
},
{
"function_call_name": "fill_",
"functionality": "Fills self tensor with the specified value (in-place).",
"input": "value (float or int)",
"output": "torch.Tensor (in-place)",
"location_or_namespace": "torch.Tensor"
},
{
"function_call_name": "type_as",
"functionality": "Returns this tensor cast to the dtype of the given tensor.",
"input": "tensor (torch.Tensor)",
"output": "torch.Tensor",
"location_or_namespace": "torch.Tensor"
},
{
"function_call_name": "torch.nan_to_num",
"functionality": "Replaces NaN, positive infinity, and negative infinity values in input tensor.",
"input": "input (torch.Tensor), nan=0.0, posinf=None, neginf=None, *, out=None",
"output": "torch.Tensor",
"location_or_namespace": "torch"
},
{
"function_call_name": "F.softmax",
"functionality": "Applies a softmax function to an n-dimensional input Tensor rescaling them so that the elements of the n-dimensional output Tensor lie in the range [0,1] and sum to 1.",
"input": "input (torch.Tensor), dim=None, _stacklevel=3, dtype=None",
"output": "torch.Tensor",
"location_or_namespace": "torch.nn.functional"
},
{
"function_call_name": "torch.exp",
"functionality": "Returns a new tensor with the exponential of the elements of the input tensor.",
"input": "input (torch.Tensor), *, out=None",
"output": "torch.Tensor",
"location_or_namespace": "torch"
},
{
"function_call_name": "torch.sum",
"functionality": "Returns the sum of all elements in the input tensor, or along a given dimension.",
"input": "input (torch.Tensor), dim, keepdim=False, *, dtype=None",
"output": "torch.Tensor",
"location_or_namespace": "torch"
},
{
"function_call_name": "self.subln",
"functionality": "Applies Root Mean Square Layer Normalization (instance of RMSNorm).",
"input": "attn (torch.Tensor)",
"output": "torch.Tensor",
"location_or_namespace": "rms_norm.RMSNorm"
},
{
"function_call_name": "reshape",
"functionality": "Returns a tensor with the same data and number of elements as input, but with the specified shape.",
"input": "*shape (tuple of ints)",
"output": "torch.Tensor",
"location_or_namespace": "torch.Tensor"
},
{
"function_call_name": "self.out_proj",
"functionality": "Applies the out_proj linear transformation (instance of nn.Linear).",
"input": "attn (torch.Tensor)",
"output": "torch.Tensor",
"location_or_namespace": "torch.nn.Linear"
}
]
},
{
"function_name": "lambda_init_fn",
"file_path": "multihead_diffattn.py",
"function_calls": [
{
"function_call_name": "exp",
"functionality": "Return e raised to the power of x.",
"input": "x (float)",
"output": "float",
"location_or_namespace": "math"
}
]
},
{
"function_name": "repeat_kv",
"file_path": "multihead_diffattn.py",
"function_calls": [
{
"function_call_name": "expand",
"functionality": "Returns a new view of the self tensor with singleton dimensions expanded to a larger size.",
"input": "*sizes (tuple of ints)",
"output": "torch.Tensor",
"location_or_namespace": "torch.Tensor"
},
{
"function_call_name": "reshape",
"functionality": "Returns a tensor with the same data and number of elements as input, but with the specified shape.",
"input": "*shape (tuple of ints)",
"output": "torch.Tensor",
"location_or_namespace": "torch.Tensor"
}
]
}
] |