Skip to content

Commit

Permalink
new large gpu launch
Browse files Browse the repository at this point in the history
  • Loading branch information
degleris1 committed Jan 11, 2025
1 parent 883795a commit e791c6b
Show file tree
Hide file tree
Showing 5 changed files with 254 additions and 7 deletions.
82 changes: 82 additions & 0 deletions experiments/plan/config/gpu_large_v01base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
tags: []

system:
threads: 128
runtime: 600
memory: auto

data:
name: pypsa
case: load_medium
add_ground: true
use_batteries: true
num_nodes: 1000
use_extra_components: false
start_hour: peak_hybrid_day
num_hours: 8640
dont_expand: [hydro, coal, biomass]
scale_by_hours: false
args:
power_unit: 1000.0 # 1e3 = GW
cost_unit: 100.0 # $ / MWh
marginal_load_value: 500.0 # $ / MWh
scale_load: 1.0
scale_generator_capacity_factor: 0.7
scale_line_capacity_factor: 0.7
carbon_tax: 0.0 # $ / ton CO2
generator_cost_perturbation: 1.0 # MW
load_cost_perturbation: 10.0 # MW
drop_empty_generators: false
expand_empty_generators: 0.5 # MW
battery_discharge_cost: 1.0 # $ / MWh
battery_init_soc: 0.0
battery_final_soc: 0.0

problem:
stochastic: true
hours_per_scenario: 24
cost_weight: 1.0
emissions_weight: 200.0 # $ / ton CO2
regularize: 1.0e-6 # Jacobian regularization
parameters: [generator, dc_line, ac_line, battery]

optimizer:
name: gradient_descent
batch_size: 8
parallel: true
num_parallel_workers: 8
num_iterations: 500
initial_state: initial
use_wandb: true
log_wandb_every: 1
checkpoint_every: 1
track_full_loss_every: -1
args:
step_size: [expand, 1.0e-2, 1.0e-3]
clip: 1000.0

layer:
use_admm: false
torch_dtype: float32
args:
# Settings
machine: cuda
resid_norm: 2
battery_window: 24
verbose: false

# Duration / convergence
num_iterations: 1000
minimum_iterations: 250
atol: 1.0e-3

# Penalty parameter
adaptive_rho: true
rho_power: 1.0
rho_angle: 1.0
alpha: 1.0
adaptation_frequency: 50

relaxation:
should_solve: false
81 changes: 81 additions & 0 deletions experiments/plan/config/gpu_large_v01exp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
tags: []

system:
threads: 16
runtime: 120
memory: auto
gpu: 1

data:
name: pypsa
case: load_medium
add_ground: true
use_batteries: true
num_nodes: 1000
use_extra_components: false
start_hour: peak_hybrid_day
num_hours: 8640
dont_expand: [hydro, coal, biomass]
scale_by_hours: false
args:
power_unit: 1000.0 # 1e3 = GW
cost_unit: 100.0 # $ / MWh
marginal_load_value: 500.0 # $ / MWh
scale_load: 1.0
scale_generator_capacity_factor: 0.7
scale_line_capacity_factor: 0.7
carbon_tax: 0.0 # $ / ton CO2
generator_cost_perturbation: 1.0 # MW
load_cost_perturbation: 10.0 # MW
drop_empty_generators: false
expand_empty_generators: 0.5 # MW
battery_discharge_cost: 1.0 # $ / MWh
battery_init_soc: 0.0
battery_final_soc: 0.0

problem:
stochastic: true
hours_per_scenario: 192
cost_weight: 1.0
emissions_weight: 200.0 # $ / ton CO2
regularize: 1.0e-6 # Jacobian regularization
parameters: [generator, dc_line, ac_line, battery]

optimizer:
name: gradient_descent
batch_size: 1
num_iterations: 500
initial_state: initial
use_wandb: true
log_wandb_every: 1
checkpoint_every: 1
track_full_loss_every: -1
args:
step_size: [expand, 1.0e-2, 1.0e-3]
clip: 1000.0

layer:
use_admm: true
torch_dtype: float32
args:
# Settings
machine: cuda
resid_norm: 2
battery_window: 24
verbose: false

# Duration / convergence
num_iterations: 1000
minimum_iterations: 250
atol: 1.0e-3

# Penalty parameter
adaptive_rho: true
rho_power: 1.0
rho_angle: 1.0
alpha: 1.0
adaptation_frequency: 50

relaxation:
should_solve: false
13 changes: 7 additions & 6 deletions experiments/plan/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,13 @@ def all_op_costs(J, grad, params, last_state, problem):
if track_full_loss_every == 0: # Track once per batch
track_full_loss_every = int(num_problems / batch_size)

if batch_size != num_problems:
if (batch_size == num_problems) or (batch_size == -1):
print("Not tracking full loss because batch_size is 0, num_problems, or -1.")

def full_loss_tracker(J, grad, params, last_state, _stoch_prob):
return J

else:
print(f"Tracking full loss every {track_full_loss_every} batches.")

def full_loss_tracker(J, grad, params, last_state, _stoch_prob):
Expand All @@ -787,11 +793,6 @@ def full_loss_tracker(J, grad, params, last_state, _stoch_prob):
return problem.full_loss
else:
return getattr(problem, "full_loss", np.inf)
else:
print("Not tracking full loss because batch_size is 0.")

def full_loss_tracker(J, grad, params, last_state, _stoch_prob):
return J
else:

def full_loss_tracker(J, grad, params, last_state, problem):
Expand Down
83 changes: 83 additions & 0 deletions experiments/solve/config/scaling_devices_v04cpu.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---

system:
threads: 128
runtime: 240 # minutes
memory: auto

data:
name: pypsa
case: load_medium
start_hour: peak_hybrid_day
num_nodes: [expand, 100, 500, 1000, 2000, 4000]
num_hours: 240 # Total number of hourds in the dataset
add_ground: true
use_batteries: true
use_extra_components: false
dont_expand: [hydro, coal, biomass]
scale_by_hours: false
args:
power_unit: 1000.0 # 1e3 = GW
cost_unit: 100.0 # $ / MWh
marginal_load_value: 500.0 # $ / MWh
scale_load: [expand, 0.5, 0.6, 0.7]
scale_generator_capacity_factor: 0.7
scale_line_capacity_factor: 0.7
carbon_tax: 0.0 # $ / ton CO2
generator_cost_perturbation: 1.0 # MW
load_cost_perturbation: 10.0 # MW
drop_empty_generators: false
expand_empty_generators: 0.5 # MW
battery_discharge_cost: 1.0 # $ / MWh
battery_init_soc: 0.0
battery_final_soc: 0.0

parameters:
parameter_types: [generator, dc_line, ac_line, battery]
hours_per_scenario: 24 # Hours in one "batch"
capacities: [base] # base, 1.5, base_v07/000/model_00500

solver: admm

battery_window: 24 # Hours for battery time horizon

cvxpy_args:
solver: MOSEK
solver_kwargs:
verbose: true
accept_unknown: true
mosek_params:
MSK_IPAR_NUM_THREADS: 16
# MSK_DPAR_INTPNT_TOL_REL_GAP: 1.0e-3
# MSK_DPAR_INTPNT_TOL_DFEAS: 1.0e-3
# MSK_DPAR_INTPNT_TOL_PFEAS: 1.0e-3

admm_args:
# Machine settings
machine: cpu
dtype: float32
resid_norm: 2
safe_mode: false
scale_dual_residuals: true
relative_rho_angle: false
verbose: false

# Duration and tolerance
num_iterations: 5000
minimum_iterations: 5000
atol: 1.0e-3

# Step size
rho_power: 1.0
rho_angle: 1.0
alpha: [sweep, 1.0, 1.5] # Over-relaxation

# Adaptation
adaptive_rho: true
adaptation_frequency: 10
adaptation_tolerance: 2.0
tau: 1.1

# Battery prox operator parameters
battery_inner_iterations: 10
battery_inner_weight: 1.0
2 changes: 1 addition & 1 deletion zap/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def forward(self, **kwargs) -> DispatchOutcome:
contingency_device=self.contingency_device,
contingency_mask=self.contingency_mask,
)
print("Dispatch: ", time.time() - start)
# print("Dispatch: ", time.time() - start)
return result

def backward(self, z: DispatchOutcome, dz: DispatchOutcome, regularize=1e-8, **kwargs):
Expand Down

0 comments on commit e791c6b

Please sign in to comment.