File size: 7,898 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
[
  {
    "function_name": "cal_grad_z",
    "file_path": "code/prune/infulence_score.py",
    "function_calls": [
      {
        "function_call_name": "trainer.get_sample_loss",
        "functionality": "Returns the cross-entropy loss computed on one training sample by index.",
        "input": "sample_idx",
        "output": "loss (float tensor)",
        "location_or_namespace": "code/prune/trainers.py"
      },
      {
        "function_call_name": "trainer.model.named_parameters",
        "functionality": "Yields parameter name and value tuples from the model.",
        "input": "",
        "output": "iterator over (name, parameter)",
        "location_or_namespace": "code/prune/trainers.py"
      },
      {
        "function_call_name": "grad",
        "functionality": "Computes gradients of outputs with respect to inputs.",
        "input": "loss, params",
        "output": "list of gradients",
        "location_or_namespace": "torch.autograd"
      }
    ]
  },
  {
    "function_name": "cal_grad_batch_z",
    "file_path": "code/prune/infulence_score.py",
    "function_calls": [
      {
        "function_call_name": "trainer.get_batch_loss",
        "functionality": "Computes the average cross-entropy loss on a batch of training samples.",
        "input": "batch",
        "output": "loss (float tensor)",
        "location_or_namespace": "code/prune/trainers.py"
      },
      {
        "function_call_name": "trainer.model.named_parameters",
        "functionality": "Yields parameter name and value tuples from the model.",
        "input": "",
        "output": "iterator over (name, parameter)",
        "location_or_namespace": "code/prune/trainers.py"
      },
      {
        "function_call_name": "grad",
        "functionality": "Computes gradients of outputs with respect to inputs.",
        "input": "loss, params",
        "output": "list of gradients",
        "location_or_namespace": "torch.autograd"
      }
    ]
  },
  {
    "function_name": "hvp",
    "file_path": "code/prune/infulence_score.py",
    "function_calls": [
      {
        "function_call_name": "grad",
        "functionality": "Computes gradients of outputs with respect to inputs.",
        "input": "y, w, retain_graph=True, create_graph=True",
        "output": "first-order gradients",
        "location_or_namespace": "torch.autograd"
      },
      {
        "function_call_name": "zip",
        "functionality": "Returns iterator of tuples from the argument iterables.",
        "input": "first_grads, v",
        "output": "iterator",
        "location_or_namespace": "builtins"
      },
      {
        "function_call_name": "torch.sum",
        "functionality": "Sums all elements of the input tensor.",
        "input": "grad_elem * v_elem",
        "output": "scalar tensor",
        "location_or_namespace": "torch"
      },
      {
        "function_call_name": "grad",
        "functionality": "Computes gradients of outputs with respect to inputs.",
        "input": "elemwise_products, w, create_graph=True",
        "output": "second-order gradient (HVP)",
        "location_or_namespace": "torch.autograd"
      }
    ]
  },
  {
    "function_name": "estimate_hv",
    "file_path": "code/prune/infulence_score.py",
    "function_calls": [
      {
        "function_call_name": "tqdm",
        "functionality": "Displays a progress bar for an iterable.",
        "input": "range(recursion_depth), total=recursion_depth",
        "output": "iterator with progress bar",
        "location_or_namespace": "tqdm"
      },
      {
        "function_call_name": "random.choice",
        "functionality": "Selects a random element from a list.",
        "input": "list of indices",
        "output": "int",
        "location_or_namespace": "random"
      },
      {
        "function_call_name": "trainer.get_sample_loss",
        "functionality": "Returns the cross-entropy loss computed on one training sample by index.",
        "input": "random_idx",
        "output": "loss (float tensor)",
        "location_or_namespace": "code/prune/trainers.py"
      },
      {
        "function_call_name": "trainer.model.named_parameters",
        "functionality": "Yields parameter name and value tuples from the model.",
        "input": "",
        "output": "iterator over (name, parameter)",
        "location_or_namespace": "code/prune/trainers.py"
      },
      {
        "function_call_name": "hvp",
        "functionality": "Computes Hessian-vector product using second-order autodiff.",
        "input": "loss, params, h_estimate",
        "output": "HVP result",
        "location_or_namespace": "code/prune/infulence_score.py"
      },
      {
        "function_call_name": "torch.no_grad",
        "functionality": "Context manager to disable gradient tracking.",
        "input": "with block",
        "output": "",
        "location_or_namespace": "torch"
      },
      {
        "function_call_name": "_.detach",
        "functionality": "Returns a tensor detached from the current graph.",
        "input": "tensor",
        "output": "detached tensor",
        "location_or_namespace": "torch.Tensor"
      },
      {
        "function_call_name": "_.reshape",
        "functionality": "Reshapes a tensor without changing its data.",
        "input": "-1",
        "output": "flattened tensor",
        "location_or_namespace": "torch.Tensor"
      }
    ]
  },
  {
    "function_name": "get_influence_score",
    "file_path": "code/prune/infulence_score.py",
    "function_calls": [
      {
        "function_call_name": "cal_grad_batch_z",
        "functionality": "Computes average batch loss gradients on validation set.",
        "input": "batch, trainer",
        "output": "gradient vector",
        "location_or_namespace": "code/prune/infulence_score.py"
      },
      {
        "function_call_name": "torch.cat",
        "functionality": "Concatenates tensors along a dimension.",
        "input": "v_list, dim=0",
        "output": "concatenated tensor",
        "location_or_namespace": "torch"
      },
      {
        "function_call_name": "torch.mean",
        "functionality": "Computes mean value of tensor along a dimension.",
        "input": "tensor, dim=0",
        "output": "mean tensor",
        "location_or_namespace": "torch"
      },
      {
        "function_call_name": "estimate_hv",
        "functionality": "Recursively estimates H⁻¹·v using LiSSA algorithm.",
        "input": "trainer, args, h_estimate, v",
        "output": "H⁻¹v estimate",
        "location_or_namespace": "code/prune/infulence_score.py"
      },
      {
        "function_call_name": "cal_grad_z",
        "functionality": "Computes per-sample loss gradient with respect to model parameters.",
        "input": "idx, trainer",
        "output": "gradient vector",
        "location_or_namespace": "code/prune/infulence_score.py"
      },
      {
        "function_call_name": "torch.matmul",
        "functionality": "Performs matrix multiplication on input tensors.",
        "input": "H_inverse[0], sample[0].view(-1).T",
        "output": "scalar",
        "location_or_namespace": "torch"
      },
      {
        "function_call_name": "torch.tensor",
        "functionality": "Creates a tensor from a list or array.",
        "input": "influence_score",
        "output": "tensor object",
        "location_or_namespace": "torch"
      },
      {
        "function_call_name": "tensor.cpu",
        "functionality": "Moves tensor to CPU memory.",
        "input": "",
        "output": "tensor",
        "location_or_namespace": "torch.Tensor"
      },
      {
        "function_call_name": "tqdm",
        "functionality": "Displays progress bar for iterable.",
        "input": "range(len(trainer.train_dataset)), total=...",
        "output": "iterator with progress bar",
        "location_or_namespace": "tqdm"
      }
    ]
  }
]