Sky Optimization

Contains documentation about the optimization code used in FogROS2-Sky

module sky_optimization

Functions

terminateClusters()

Terminates all Sky benchmarking instances.

main()

Main Method containing user interface command parser.

OptimizationFunctionType : public Enum

Specifies whether the optimization problem will be solving for time or cost.

Public Static Attributes

TIME = 1

Time Optimization.

COST = 2

Cost Optimization.

OBJECTIVE_COST = 3

Objective Cost Optimization (Motion Planning)

class SkyOptimization

Sky Optimizer responsible for performing the cost and time optimizations based on problem type (Dexnet, VSLAM, Motion Planning) and GPU type (No GPU, T4, etc)

Public Functions

__init__(self, yaml_file, gpu_yaml_file, steps, max_cost, max_time, max_objective_cost, debug, gpu_type, count)

Sky Optimization Constructor.

Parameters:
  • yaml_file – YAML file specifying Sky benchmarking setup for no GPU

  • gpu_yaml_file – YAML file specifying Sky benchmarking setup for given GPU type (Tested only on T4)

  • steps – Number of steps the Sky benchmarking should run

  • max_cost – User provided cost constraint

  • max_time – User provided time constraint

  • max_objective_cost – User provided objective cost constraint

  • debug – Debug Mode (Lots of print statements)

  • gpu_type – The GPU type used in the Sky benchmarking (only tested on No GPU, T4)

  • count – Index in list of SkyOptimization Problems being run (helps coordinate the multithreading)

fullOptimization(self)

Full Sky Optimization Function.

Returns:

List containing Time and Cost Optimizations

getObjectiveCost(self, machine_name)

Parses Sky benchmarking to get objective cost for given machine instance.

Parameters:

machine_name – Name of benchmarking machine instance

Returns:

Objective cost from instance

findInstance(self, optimization_results, optimization_type)

Given results of optimization, this will find the closest feasible hardware setup and its corresponding AWS Instance (Future Work: Build out to other cloud providers)

Parameters:
  • optimization_results – Scipy Output from optimization

  • optimization_type – Optimization Type (Cost or Time)

binarySearchRounding(self, optimal_cpu_count)

Rounds CPU output of optimization to nearest feasible CPU amount allowed in cloud instance.

Parameters:

optimal_cpu_count – CPU output from optimization

Returns:

Feasible CPU amount closest to the optimal CPU amount

findGpuValues(self)

Parses provided GPU benchmark file to determine possible hardware setups for given GPU.

findCpuValues(self)

Parses provided CPU benchmark file to determine edge case hardware setups.

createBenchmarks(self, gpu_type)

Creates Yaml files for each benchmarking instance that will be run.

Parameters:

gpu_type – The GPU type of this optimization instance (only tested on T4 and No GPU)

runSkyBenchmarks(self, count)

Multithreads (Python-style) sky benchmarking instances.

Parameters:

count – Global count relative to other SkyOptimization instances to make sure each Sky benchmarking instance name is unique

skyBenchmark(self, yaml_file, benchmark_name, hardware_count)

Runs sky benchmarking instance from bash script.

Parameters:
  • yaml_file – Yaml configuration file for benchmarking instance

  • benchmark_name – Name of Sky benchmarking instance

  • hardware_count – Tuple containing (CPU, Memory)

regressionSolver(self, data, purpose)

Finds best fitting model given benchmarking data.

Parameters:
  • data – Benchmarking data for either time, cost, or objective cost

  • purpose – Time, Cost, or Objective Cost

Returns:

Best fit model and its coefficients

createBounds(self)

Bounds for CPU and Memory for optimization problem.

Returns:

SciPy Bounds object for optimization problem

createConstraints(self, constraint_function_type)

Constraints for Optimization Problem (includes time/cost along with memory/CPU ratio)

Parameters:

constraint_function_type – Constraint function type, which is opposite of the optimization problem (Time Optimization -> Cost Constraint and Cost Optimization -> Time Constraint)

Returns:

SciPy Constraints object for optimization problem

getTimeOptimization(self)

Gets Time Optimization Results.

Returns:

Time Optimization Results

getCostOptimization(self)

Gets Cost Optimization Results.

Returns:

Cost Optimization Results

createObjectiveFunction(self, objective_function_type)

Optimization Loss Function.

Parameters:

objective_function_type – Time or Cost

Returns:

Optimization Loss Function

memoryFunction(self)

Function for memory/CPU ratio constraint.

Returns:

Memory:CPU Constraint Function

costFunction(self)

Cost Function = $/second * seconds/step * # steps.

Returns:

Function object for the Cost Function

timeFunction(self)

Time Function = seconds/step * # steps.

Returns:

Function object for the Time Function

objectiveCostFunction(self)

Objective Cost Function.

Returns:

Function object for the Objective Cost Function

solveOptimization(self, objective_function_type, constraint_function_type)

Optimization Problem Setup and Solver.

Parameters:
  • objective_function_type – Time or Cost

  • constraint_function_type – Opposite of objective_function_type

Returns:

Optimization Result, Time Model Result, Cost Model Result

Public Members

debug_

Debug Mode (Lots of print statements)

steps_

Number of steps the Sky benchmarking should run.

max_cost_

User provided cost constraint.

max_time_

User provided time constraint.

max_objective_cost_

User provided objective cost constraint.

gpu_type_

The GPU type used in the Sky benchmarking (only tested on No GPU, T4)

count_

Index in list of SkyOptimization Problems being run (helps coordinate the multithreading)

SECONDS_PER_MINUTE

Number of seconds in a minute.

MINUTES_PER_HOUR

Number of minutes in an hour.

SECONDS_PER_HOUR

Number of seconds in an hour.

ZERO_EPSILON

Positive zero approximation.

yaml_file_

YAML file specifying Sky benchmarking setup for no GPU.

gpu_yaml_file_

YAML file specifying Sky benchmarking setup for given GPU type (Tested only on T4)

is_slam_

Boolean indicating if the task is V-SLAM.

is_motion_planning_

Boolean indicating if the task is motion planning.

is_dexnet_

Boolean indicating if the task is Dexnet.

optimization_function_type_length_

Index in solution string specifying optimization function type.

max_cpu_

Initialzation of maximum CPU constraint.

max_memory_

Initialization of maximum memory constraint.

relevant_cpu_list_

List of realistic CPU setups for the cloud (similar to relevant hardware list without memory, rememant of prototype version that just looked for optimal CPU)

relevant_hardware_list_

List of realistic CPU and memory setups for the cloud.

benchmark_time_results_

List storing results from time benchmarking.

benchmark_yaml_list_

List of YAML files generated that will be used for Sky benchmarking.

benchmark_range_

Number of benchmarks performed per feature (i.e we only do benchmarking for minimum CPU amount, maximum CPU amount, and middle CPU amount)

benchmark_threads_

List of different threads running Sky benchmarking.

benchmark_cost_substring_1_

First identifier substring for cost benchmarking.

benchmark_cost_substring_2_

Second identifier substring for cost benchmarking.

benchmark_time_substring_1_

First identifier substring for time benchmarking.

benchmark_time_substring_2_

Second identifier substring for time benchmarking.

min_gpu_substring_1_

First identifier substring for GPU identification.

min_gpu_substring_2_

Second identifier substring for GPU identification.

mem_to_cpu_ratio_for_gpu_

Initialization for memory:CPU ratio (used only when GPU type isn’t None)

num_steps_and_duration_

List containing step and startup time results for benchmarking (remmanat of prototype version where we tried to account for startup time.

average_setup_time_

Average setup time for cloud instance (remmenant of prototype version: see self.num_steps_and_duration_ for explanation)

got_cost_info_

Boolean indicating if we have receieved cost information from benchmarking.

benchmark_cost_substring_cpu_index_

Indiex where CPU information is located in benchmark cost string.

benchmark_cost_substring_cost_index_

Index where Cost information is located in benchmark cost string.

benchmark_cost_results_

List containng cost results from Sky benchmarking.

benchmark_objective_cost_results_

List containing objective cost results for Sky benchmarking (only relevant for Motion Planning)

yaml_file_contents_

String containing YAML file contents for Sky benchmark YAML.

cpu_start_index_

Index containing information about where CPU information starts in YAML file.

cpu_candiate_index_

Index containing information about where CPU candidate information starts in YAML file.

cpu_str_offset_

Offset for index where we insert CPU information into the YAML file.

seconds_per_step_index_

Index containing seconds per step information during Sky benchmarking.

num_steps_index_

Index containing number of steps information during Sky benchmarking.

duration_min_index_

Index containing minute duration during Sky benchmarking.

duration_sec_index_

Index containing second duration during Sky benchmarking.

solutions_in_constraints_

List of solutions that are within constraints.

solutions_outside_constraints_

List of solutions that are outside constraints.

data_file_

String before relevant benchmarking data (Let’s the program know which line to collect benchmarking data from)

data_file_name_

Data file we will save benchmark data results.

result_queue_

List containing info that will be outputted to data file.

possible_cpus_

List containing possible CPUs (current cloud setup could not do any other CPU amounts)

optimal_cost_instance_

String stating the optimal cloud instance for cost optimization.

optimal_time_instance_

String stating the optimal cloud instance for time optimization.

optimal_objective_cost_instance_

String stating the optimal cloud instance for objective cost optimization.

t4_map_

Map between hardware tuples (CPU, Memory) and T4 GPU cloud instances for AWS (Future Work: Will generate these maps online by parsing SkyPilot database CSV file)

no_gpu_map_

Map between hardware tuples (CPU, Memory) and no GPU cloud instance (Future Work: Will generate these maps online by parsing SkyPilot database CSV file)

time_model_info_

Time Regression Output containing model info and constraints.

cost_model_info_

Cost Regression Output containing model info and constraints.

objective_cost_model_info_

Objective Cost Regression Output containing model info and constraints (only motion planning)

timeModel_

Time Regression Model.

time_model_coefficients_

Coefficients for Time Regression Model.

costModel_

Cost Regression Model.

cost_model_coefficients_

Coefficients for Cost Regression Model.

objectiveCostModel_

Objective Cost Regression Model.

objective_cost_model_coefficients_

Coefficients for Objective Cost Regression Model.

cost_optimization_results_

Scipy Output from Cost Optimization.

time_optimization_results_

Scipy Output from Time Optimization.

objective_cost_optimization_results_

Scipy Output from Objective Cost Optimization.