[ { "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" } ] } ]