Commit
·
2b544b3
1
Parent(s):
bc74a1c
bug fixing checkpoint and gradient step
Browse files- pythia-training-metrics.py +16 -9
pythia-training-metrics.py
CHANGED
@@ -85,27 +85,31 @@ class PythiaTrainingMetrics(datasets.GeneratorBasedBuilder):
|
|
85 |
"""
|
86 |
return list(range(max(0, step-5), min(step+6, 143_000)))
|
87 |
|
88 |
-
for model_size in self.MODEL_SIZES:
|
89 |
for checkpoint_step in checkpoint_steps:
|
90 |
|
91 |
directory_path = f"./models/{model_size}/checkpoint_{checkpoint_step}"
|
92 |
|
93 |
if self.config.name == "activations":
|
94 |
model_size_to_fp[model_size].append(f"{directory_path}/checkpoint_activations.pickle")
|
95 |
-
|
|
|
96 |
elif self.config.name == "weights":
|
97 |
model_size_to_fp[model_size].append(f"{directory_path}/checkpoint_weights.pickle")
|
98 |
-
|
|
|
99 |
elif self.config.name == "gradients":
|
100 |
for gradient_step in get_gradient_step(checkpoint_step):
|
101 |
model_size_to_fp[model_size].append(f"{directory_path}/checkpoint_gradients_{gradient_step}.pickle")
|
102 |
-
|
103 |
-
|
|
|
104 |
elif self.config.name == "gradients_mini":
|
105 |
for gradient_step in get_gradient_step(checkpoint_step)[:2]:
|
106 |
model_size_to_fp[model_size].append(f"{directory_path}/checkpoint_gradients_mini_{gradient_step}.pickle")
|
107 |
-
|
108 |
-
|
|
|
109 |
else:
|
110 |
raise Exception("Invalid config name")
|
111 |
|
@@ -117,17 +121,20 @@ class PythiaTrainingMetrics(datasets.GeneratorBasedBuilder):
|
|
117 |
gen_kwargs={
|
118 |
"filepaths": downloaded_fps,
|
119 |
"checkpoint_steps": kwargs_checkpoint_steps,
|
120 |
-
"gradient_steps": kwargs_gradient_steps,
|
121 |
}
|
122 |
) for model_size_name, downloaded_fps in downloaded_files.items()
|
123 |
]
|
124 |
|
125 |
-
def _generate_examples(self, filepaths, checkpoint_steps,
|
126 |
|
127 |
# the filepaths should be a list of filepaths
|
128 |
if isinstance(filepaths, str):
|
129 |
filepaths = [filepaths]
|
130 |
|
|
|
|
|
|
|
131 |
global_idx = 0 # the unique identifier for the example
|
132 |
|
133 |
for idx, filepath in enumerate(filepaths):
|
|
|
85 |
"""
|
86 |
return list(range(max(0, step-5), min(step+6, 143_000)))
|
87 |
|
88 |
+
for _idx, model_size in enumerate(self.MODEL_SIZES):
|
89 |
for checkpoint_step in checkpoint_steps:
|
90 |
|
91 |
directory_path = f"./models/{model_size}/checkpoint_{checkpoint_step}"
|
92 |
|
93 |
if self.config.name == "activations":
|
94 |
model_size_to_fp[model_size].append(f"{directory_path}/checkpoint_activations.pickle")
|
95 |
+
if _idx == 0:
|
96 |
+
kwargs_checkpoint_steps.append(checkpoint_step)
|
97 |
elif self.config.name == "weights":
|
98 |
model_size_to_fp[model_size].append(f"{directory_path}/checkpoint_weights.pickle")
|
99 |
+
if _idx == 0:
|
100 |
+
kwargs_checkpoint_steps.append(checkpoint_step)
|
101 |
elif self.config.name == "gradients":
|
102 |
for gradient_step in get_gradient_step(checkpoint_step):
|
103 |
model_size_to_fp[model_size].append(f"{directory_path}/checkpoint_gradients_{gradient_step}.pickle")
|
104 |
+
if _idx == 0:
|
105 |
+
kwargs_checkpoint_steps.append(checkpoint_step)
|
106 |
+
kwargs_gradient_steps.append(gradient_step)
|
107 |
elif self.config.name == "gradients_mini":
|
108 |
for gradient_step in get_gradient_step(checkpoint_step)[:2]:
|
109 |
model_size_to_fp[model_size].append(f"{directory_path}/checkpoint_gradients_mini_{gradient_step}.pickle")
|
110 |
+
if _idx == 0:
|
111 |
+
kwargs_checkpoint_steps.append(checkpoint_step)
|
112 |
+
kwargs_gradient_steps.append(gradient_step)
|
113 |
else:
|
114 |
raise Exception("Invalid config name")
|
115 |
|
|
|
121 |
gen_kwargs={
|
122 |
"filepaths": downloaded_fps,
|
123 |
"checkpoint_steps": kwargs_checkpoint_steps,
|
124 |
+
**({"gradient_steps": kwargs_gradient_steps} if self.config.name in ["gradients", "gradients_mini"] else {}),
|
125 |
}
|
126 |
) for model_size_name, downloaded_fps in downloaded_files.items()
|
127 |
]
|
128 |
|
129 |
+
def _generate_examples(self, filepaths, checkpoint_steps, **kwargs):
|
130 |
|
131 |
# the filepaths should be a list of filepaths
|
132 |
if isinstance(filepaths, str):
|
133 |
filepaths = [filepaths]
|
134 |
|
135 |
+
if self.config.name in ["gradients", "gradients_mini"]:
|
136 |
+
gradient_steps = kwargs["gradient_steps"]
|
137 |
+
|
138 |
global_idx = 0 # the unique identifier for the example
|
139 |
|
140 |
for idx, filepath in enumerate(filepaths):
|