Skip to content

Commit 42b4de0

Browse files
committed
Remove commented CUDA Graph code
1 parent ed28419 commit 42b4de0

1 file changed

Lines changed: 0 additions & 54 deletions

File tree

src/engine/server/NN/ModelManager.cpp

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,6 @@ std::shared_ptr<torch::optim::ReduceLROnPlateauScheduler> scheduler;
5252
std::deque<ActorCritic> old_ac;
5353
std::vector<int> old_bots_indexes;
5454
std::vector<int> input_to_model_id;
55-
bool graph_recorded = false;
56-
57-
// Tested CUDA Graphs - produce numerical instability
58-
//std::vector<torch::Tensor> graph_input_tensors;
59-
//std::vector<torch::Tensor> graph_output_tensors;
60-
//torch::Tensor graph_main_input_tensor, graph_main_output_tensor;
61-
//at::cuda::CUDAGraph graph;
62-
//at::cuda::CUDAStream graph_stream = at::cuda::getStreamFromPool();
6355

6456
VT states;
6557
VT actions;
@@ -120,9 +112,6 @@ ModelManager::ModelManager(bool is_training, std::string train_folder, size_t ba
120112
ac_update->Initialize(n_in, n_out, h_start, std_dev);
121113
ac_work->Initialize(n_in, n_out, h_start, std_dev);
122114

123-
//graph_main_input_tensor = torch::empty({(int)(count_bots - old_bots_indexes.size()), n_in}, torch::kCUDA);
124-
//graph_main_output_tensor = torch::empty({(int)(count_bots - old_bots_indexes.size()), n_out}, torch::kCUDA);
125-
126115
// Global Speedups
127116
// Produce nondetermenistic behavior even on the same gpu
128117
// Enable optimized cuDNN algorithms, works best with non-fluxuating input size, perfect for RL
@@ -454,27 +443,19 @@ std::vector<ModelOutput> ModelManager::Decide(
454443
//printf("333\n");
455444
std::vector<torch::Tensor> old_batches;
456445
//printf("444\n");
457-
int graph_counter = 0;
458-
int graph_main_counter = 0;
459446
//nvtxRangePushA("Redistributing actions");
460447

461448
for(size_t i = 0; i < input_inputs.size(); ++i)
462449
{
463450
if(!input_to_model_id.empty() && input_to_model_id[i] != -1)
464451
{
465-
/*if(!graph_recorded)
466-
graph_input_tensors.push_back(state_gpu[i].reshape({1, n_in}));
467-
else*/
468452
old_states.push_back(state_gpu[i].reshape({1, n_in}));
469453
old_indices.push_back(i); // Track the original index
470-
graph_counter += 1;
471454
}
472455
else
473456
{
474-
//current_states[graph_main_counter].copy_(state_gpu[i].reshape({1, n_in}), true);
475457
current_states.push_back(state_gpu[i].reshape({1, n_in}));
476458
current_indices.push_back(i); // Track the original index
477-
graph_main_counter += 1;
478459
}
479460
}
480461
//nvtxRangePop();
@@ -516,24 +497,6 @@ std::vector<ModelOutput> ModelManager::Decide(
516497

517498
measure_time = std::chrono::high_resolution_clock::now();
518499
torch::Tensor main_input = torch::cat(current_states, 0);
519-
//std::cout << graph_main_input_tensor.sizes() << std::endl;
520-
521-
// Process old models
522-
//cudaStreamCreate(&stream);
523-
//omp_set_num_threads(4);
524-
//#pragma omp parallel for
525-
526-
//graph_main_output_tensor.copy_(ac_work->actor_forward(graph_main_input_tensor), true);
527-
528-
//for(int i = 0; i < graph_input_tensors.size(); ++i)
529-
//{
530-
// int model_id = input_to_model_id[old_indices[i]]; // get the model id for this input
531-
// auto av_old = old_ac[model_id]->actor_forward(graph_input_tensors[i]);
532-
// graph_output_tensors[i].copy_(av_old.reshape({n_out}), true); // store the result for this old model
533-
//}
534-
535-
//nvtxRangePushA("Graph begin");
536-
537500

538501
torch::Tensor av_current = ac_work->actor_forward(main_input);
539502

@@ -551,7 +514,6 @@ std::vector<ModelOutput> ModelManager::Decide(
551514
time_forward = std::chrono::duration<double>(now - measure_time).count() * 1000.;
552515
measure_time = std::chrono::high_resolution_clock::now();
553516
//nvtxRangePushA("normal_actor");
554-
//std::cout << graph_main_output_tensor[0] << std::endl;
555517
torch::Tensor av_current_sampled, old_current_sampled, old_current;
556518
//printf("1\n");
557519
if(old_batches.size())
@@ -894,22 +856,6 @@ void ModelManager::Update(double avg_reward, bool cache_model, bool &updated,
894856
if(!old_ac.empty())
895857
{
896858
ReassignOldModels();
897-
//graph_input_tensors.clear();
898-
////graph_main_input_tensors.clear();
899-
//graph_output_tensors.clear();
900-
//for(size_t i = 0; i < old_bots_indexes.size(); i++)
901-
//{
902-
// torch::Tensor empty_in = torch::empty({1, n_in}, torch::kCUDA);
903-
// graph_input_tensors.push_back(empty_in);
904-
// torch::Tensor empty_out = torch::empty({n_out}, torch::kCUDA);
905-
// graph_output_tensors.push_back(empty_out);
906-
//}
907-
//graph_main_input_tensor = torch::empty({(int)(count_bots - old_bots_indexes.size()), n_in}, torch::kCUDA);
908-
//graph_main_output_tensor = torch::empty({(int)(count_bots - old_bots_indexes.size()), n_out}, torch::kCUDA);
909-
910-
// Clean up
911-
//graph.reset();
912-
//graph_recorded = false;
913859
}
914860

915861
//int botes = count_bots - old_bots_indexes.size();

0 commit comments

Comments
 (0)