Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 6 additions & 1 deletion intervention/days_of_week_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import numpy as np
import transformer_lens
import torch
from task import Problem, get_acts, plot_pca, get_all_acts, get_acts_pca
from task import activation_patching

Expand Down Expand Up @@ -148,7 +149,11 @@ def generate_problems(self):

def get_model(self):
if self.n_devices is None:
self.n_devices = 2 if "llama" == self.model_name else 1
self.n_devices = (
min(2, max(1, torch.cuda.device_count()))
if "llama" == self.model_name
else 1
)
if self._lazy_model is None:
if self.model_name == "mistral":
self._lazy_model = transformer_lens.HookedTransformer.from_pretrained(
Expand Down
7 changes: 6 additions & 1 deletion intervention/months_of_year_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import numpy as np
import transformer_lens
import torch
from task import Problem, get_acts, plot_pca, get_all_acts, get_acts_pca
from task import activation_patching

Expand Down Expand Up @@ -159,7 +160,11 @@ def generate_problems(self):

def get_model(self):
if self.n_devices is None:
self.n_devices = 2 if "llama" == self.model_name else 1
self.n_devices = (
min(2, max(1, torch.cuda.device_count()))
if "llama" == self.model_name
else 1
)
if self._lazy_model is None:
if self.model_name == "mistral":
self._lazy_model = transformer_lens.HookedTransformer.from_pretrained(
Expand Down