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

fixed minor issues str to enum conv #14

Merged
merged 1 commit into from
Feb 26, 2024
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
10 changes: 4 additions & 6 deletions jobs/bayesian_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@ def generate_initial_bounds(self, system: System) -> torch.Tensor:
t_bounds = torch.tensor([int(self.bayesian_setting["bounds"]["T_min"]),
int(self.bayesian_setting["bounds"]["T_max"])])
policy_bounds = torch.tensor([0, 1])
if self.model_type == "QHybrid":
if self.model_type == Policy.QFixed:
q_bounds = torch.tensor([1, self.bayesian_setting["bounds"]["T_max"] - 1])
bounds = torch.stack([h_bounds, t_bounds, q_bounds], dim=-1)
elif self.model_type == "YZHybrid":
elif self.model_type == Policy.YZHybrid:
y_bounds = torch.tensor([1, self.bayesian_setting["bounds"]["T_max"] - 1])
z_bounds = torch.tensor([1, self.bayesian_setting["bounds"]["T_max"] - 1])
bounds = torch.stack([h_bounds, t_bounds, y_bounds, z_bounds], dim=-1)
# elif self.model_type == "KHybrid": # TODO add support for KHybrid model
# elif self.model_type == Policy.KHybrid: # TODO add support for KHybrid model
else:
bounds = torch.stack([h_bounds, t_bounds, policy_bounds], dim=-1)
return bounds
Expand Down Expand Up @@ -184,7 +184,7 @@ def get_next_points(self, x: torch.Tensor, y: torch.Tensor, best_y: float, bound
single_model = MixedSingleTaskGP(x, y, cat_dims=[1, 2], input_transform=Normalize(d=x.shape[1],
bounds=bounds),
outcome_transform=Standardize(m=1))
elif self.model_type == "YZHybrid":
elif self.model_type == Policy.YZHybrid:
single_model = MixedSingleTaskGP(x, y, cat_dims=[1, 2, 3], input_transform=Normalize(d=x.shape[1],
bounds=bounds),
outcome_transform=Standardize(m=1))
Expand Down Expand Up @@ -273,8 +273,6 @@ def _update_best_designs(self, best_designs: List[Tuple[LSMDesign, float]], new_
# TODO: code for KHybrid to be added
else:
h, size_ratio, policy = x[0], x[1], x[2]
if(policy.item == 0.0):
print ("0 value for policy!")
best_designs.append((LSMDesign(h.item(), np.ceil(size_ratio.item()), policy.item()), y.item()))
return best_designs

Expand Down
6 changes: 3 additions & 3 deletions jobs/bo_job_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ def compare_designs(n_runs=3, csv_filename='design_comparison.csv'):
writer.writerow(['Entries per page(E)', 'Physical Entries per page(B)', 'Selectivity(s)',
'Max bits per element(H)', 'Total elements (N)', 'Empty Reads', 'Non-Empty Reads',
'Range Queries', 'Writes', 'BO Design', 'Analytical Design', 'BO Cost',
'Analytical Cost', 'Diff(Analytical-Bayesian)', "Elapsed Time"])
'Analytical Cost', 'Diff(Analytical-Bayesian)'])

for i in range(n_runs):
print(f"Iteration {i + 1}/{n_runs} running")
system = generator._sample_system()
z0, z1, q, w = generator._sample_workload(4)
bo_design, bo_cost, time = bayesian_optimizer.run(system, z0, z1, q, w)
bo_design, bo_cost = bayesian_optimizer.run(system, z0, z1, q, w)
analytical_design, analytical_cost = bayesian_optimizer._find_analytical_results(system, z0, z1, q, w)
writer.writerow([system.E, system.B, system.s, system.H, system.N, z0, z1, q, w,
bo_design, analytical_design, bo_cost, analytical_cost, analytical_cost - bo_cost, time])
bo_design, analytical_design, bo_cost, analytical_cost, analytical_cost - bo_cost])


if __name__ == "__main__":
Expand Down
Loading