Commit
·
a378726
1
Parent(s):
6c5fe27
enabling gradient information to be saved out correctly
Browse files
pythia_training_metrics.py → pythia-training-metrics.py
RENAMED
@@ -120,19 +120,21 @@ class PythiaTrainingMetrics(datasets.GeneratorBasedBuilder):
|
|
120 |
elif self.config_name == "gradients_mini":
|
121 |
for gradient_step in get_gradient_step(checkpoint_step)[:2]:
|
122 |
model_size_to_fp[model_size].append(f"{directory_path}/checkpoint_gradients_mini_{gradient_step}.pickle")
|
|
|
|
|
123 |
|
124 |
downloaded_files = dl_manager.download_and_extract(model_size_to_fp)
|
125 |
|
126 |
return [
|
127 |
datasets.SplitGenerator(
|
128 |
-
name=
|
129 |
gen_kwargs={
|
130 |
"filepaths": downloaded_fps
|
131 |
}
|
132 |
-
) for downloaded_fps in downloaded_files.
|
133 |
]
|
134 |
|
135 |
-
def _generate_examples(self, filepaths):
|
136 |
|
137 |
# the filepaths should be a list of filepaths
|
138 |
if isinstance(filepaths, str):
|
@@ -149,11 +151,12 @@ class PythiaTrainingMetrics(datasets.GeneratorBasedBuilder):
|
|
149 |
|
150 |
if self.config.name in ["activations", "weights"]:
|
151 |
for layer_name, layer_data in data.items():
|
152 |
-
|
153 |
-
|
154 |
-
global_idx += 1
|
155 |
elif self.config.name in ["gradients", "gradients_mini"]:
|
|
|
|
|
|
|
156 |
for layer_name, layer_data in data.items():
|
157 |
-
|
158 |
-
|
159 |
-
global_idx += 1
|
|
|
120 |
elif self.config_name == "gradients_mini":
|
121 |
for gradient_step in get_gradient_step(checkpoint_step)[:2]:
|
122 |
model_size_to_fp[model_size].append(f"{directory_path}/checkpoint_gradients_mini_{gradient_step}.pickle")
|
123 |
+
else:
|
124 |
+
raise Exception("Invalid config name")
|
125 |
|
126 |
downloaded_files = dl_manager.download_and_extract(model_size_to_fp)
|
127 |
|
128 |
return [
|
129 |
datasets.SplitGenerator(
|
130 |
+
name=model_size_name,
|
131 |
gen_kwargs={
|
132 |
"filepaths": downloaded_fps
|
133 |
}
|
134 |
+
) for model_size_name, downloaded_fps in downloaded_files.items()
|
135 |
]
|
136 |
|
137 |
+
def _generate_examples(self, filepaths, **kwargs):
|
138 |
|
139 |
# the filepaths should be a list of filepaths
|
140 |
if isinstance(filepaths, str):
|
|
|
151 |
|
152 |
if self.config.name in ["activations", "weights"]:
|
153 |
for layer_name, layer_data in data.items():
|
154 |
+
yield global_idx, {"checkpoint_step": checkpoint_step, "layer_name": layer_name, "data": data}
|
155 |
+
global_idx += 1
|
|
|
156 |
elif self.config.name in ["gradients", "gradients_mini"]:
|
157 |
+
|
158 |
+
gradient_step = int(filepath.split('/')[-1].split("_")[-1].split(".")[0])
|
159 |
+
|
160 |
for layer_name, layer_data in data.items():
|
161 |
+
yield global_idx, {"checkpoint_step": checkpoint_step, "layer_name": layer_name, "gradient_step": gradient_step, "gradient": layer_data}
|
162 |
+
global_idx += 1
|
|