Skip to content
Merged
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
14 changes: 7 additions & 7 deletions algorithmic_efficiency/random_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,30 @@

# Annoyingly, RandomState(seed) requires seed to be in [0, 2 ** 32 - 1] (an
# unsigned int), while RandomState.randint only accepts and returns signed ints.
MAX_INT32 = 2**31
MIN_INT32 = -MAX_INT32
MAX_UINT32 = 2**32 - 1
MIN_UINT32 = 0

SeedType = Union[int, list, np.ndarray]


def _signed_to_unsigned(seed: SeedType) -> SeedType:
if isinstance(seed, int):
return seed % 2**32
return seed % MAX_UINT32
if isinstance(seed, list):
return [s % 2**32 for s in seed]
return [s % MAX_UINT32 for s in seed]
if isinstance(seed, np.ndarray):
return np.array([s % 2**32 for s in seed.tolist()])
return np.array([s % MAX_UINT32 for s in seed.tolist()])


def _fold_in(seed: SeedType, data: Any) -> List[Union[SeedType, Any]]:
rng = np.random.RandomState(seed=_signed_to_unsigned(seed))
new_seed = rng.randint(MIN_INT32, MAX_INT32, dtype=np.int32)
new_seed = rng.randint(MIN_UINT32, MAX_UINT32, dtype=np.uint32)
return [new_seed, data]


def _split(seed: SeedType, num: int = 2) -> SeedType:
rng = np.random.RandomState(seed=_signed_to_unsigned(seed))
return rng.randint(MIN_INT32, MAX_INT32, dtype=np.int32, size=[num, 2])
return rng.randint(MIN_UINT32, MAX_UINT32, dtype=np.uint32, size=[num, 2])


def _PRNGKey(seed: SeedType) -> SeedType: # pylint: disable=invalid-name
Expand Down
5 changes: 4 additions & 1 deletion scoring/performance_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ def compute_performance_profiles(submissions,
scale='linear',
verbosity=0,
strict=False,
self_tuning_ruleset=False):
self_tuning_ruleset=False,
output_dir=None):
"""Compute performance profiles for a set of submission by some time column.

Args:
Expand Down Expand Up @@ -321,6 +322,8 @@ def compute_performance_profiles(submissions,
# Sort workloads alphabetically (for better display)
df = df.reindex(sorted(df.columns), axis=1)

# Save time to target dataframe
df.to_csv(os.path.join(output_dir, 'time_to_targets.csv'))
# For each held-out workload set to inf if the base workload is inf or nan
for workload in df.keys():
if workload not in BASE_WORKLOADS:
Expand Down
4 changes: 3 additions & 1 deletion scoring/score_submissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,9 @@ def main(_):
scale='linear',
verbosity=0,
self_tuning_ruleset=FLAGS.self_tuning_ruleset,
strict=FLAGS.strict)
strict=FLAGS.strict,
output_dir=FLAGS.output_dir,
)
if not os.path.exists(FLAGS.output_dir):
os.mkdir(FLAGS.output_dir)
performance_profile.plot_performance_profiles(
Expand Down
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ jax_core_deps =
chex==0.1.7
ml_dtypes==0.2.0
protobuf==4.25.3
scipy==1.11.4


# JAX CPU
Expand Down
Loading