Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

train probe per prompt #271

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix pyright
  • Loading branch information
derpyplops committed Jul 14, 2023
commit f35626a8bc73ba3b1408b20b8794ac7f39543116
6 changes: 3 additions & 3 deletions elk/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def execute(

devices = select_usable_devices(self.num_gpus, min_memory=self.min_gpu_mem)
num_devices = len(devices)
func: Callable[[int], dict[str, pd.DataFrame]] = partial(
func: Callable[[int], list[dict[str, pd.DataFrame]]] = partial(
self.apply_to_layer,
devices=devices,
world_size=num_devices,
Expand All @@ -113,7 +113,7 @@ def execute(
@abstractmethod
def apply_to_layer(
self, layer: int, devices: list[str], world_size: int, probe_per_prompt: bool
) -> dict[str, pd.DataFrame]:
) -> list[dict[str, pd.DataFrame]]:
"""Train or eval a reporter on a single layer."""

def make_reproducible(self, seed: int):
Expand Down Expand Up @@ -162,7 +162,7 @@ def concatenate(self, layers):

def apply_to_layers(
self,
func: Callable[[int], dict[str, pd.DataFrame]],
func: Callable[[int], list[dict[str, pd.DataFrame]]],
num_devices: int,
):
"""Apply a function to each layer of the datasets in parallel
Expand Down
2 changes: 2 additions & 0 deletions elk/training/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ def apply_to_layer(
probe_per_prompt: bool,
) -> list[dict[str, pd.DataFrame]]:
"""Train a single reporter on a single layer."""
assert self.out_dir is not None # TODO this is really annoying, why can it be
# None?

self.make_reproducible(seed=self.net.seed + layer)
device = self.get_device(devices, world_size)
Expand Down
Loading