Skip to content

Commit 99b187a

Browse files
authored
kernel bias fix and cupti release method (#42)
* changed predictor.py * cupti close connection * setup.py original config * changed cupti and runtime versions --------- Co-authored-by: John Calderon <john.calderon@centml.ai>
1 parent f6b08ab commit 99b187a

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

analyzer/habitat/analysis/predictor.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def _conv2d_scale(self, operation, dest_device):
180180
merged['padding'][0]
181181
if isinstance(merged['padding'], tuple) else merged['padding']
182182
),
183-
bias=(1 if merged['bias'] is not None else 0),
183+
bias=(1 if merged.get('bias',None) != None else 0),
184184
)
185185

186186
# 3. Call model to make prediction
@@ -214,7 +214,7 @@ def _conv_transpose2d_scale(self, operation, dest_device):
214214
merged['padding'][0]
215215
if isinstance(merged['padding'], tuple) else merged['padding']
216216
),
217-
bias=(1 if merged['bias'] is not None else 0),
217+
bias=(1 if merged.get('bias',None) != None else 0),
218218
)
219219

220220
# 3. Call model to make prediction
@@ -251,7 +251,7 @@ def _linear_scale(self, operation, dest_device):
251251
batch=effective_batch,
252252
in_features=merged['weight'][1],
253253
out_features=merged['weight'][0],
254-
bias=(1 if merged['bias'] is not None else 0)
254+
bias=(1 if merged.get('bias',None) != None else 0)
255255
)
256256

257257
arguments = [arguments[x] for x in self.linear_pred.model.features]
@@ -293,7 +293,7 @@ def _lstm_scale(self, operation, dest_device):
293293
operation.arguments.kwargs,
294294
)
295295
arguments = dict(
296-
bias=(1 if merged['bias'] is not None else 0),
296+
bias=(1 if merged.get('bias',None) != None else 0),
297297
bidirectional=(1 if merged['bidirectional'] else 0),
298298
batch=merged['input'][1], # We require the batch to be in position 1
299299
seq_len=merged['input'][0],
@@ -310,7 +310,7 @@ def _lstm_scale(self, operation, dest_device):
310310
)
311311
max_batch_size = max(operation.arguments.special['batch_sizes'])
312312
arguments = dict(
313-
bias=(1 if merged['bias'] is not None else 0),
313+
bias=(1 if merged.get('bias',None) != None else 0),
314314
bidirectional=(1 if merged['bidirectional'] else 0),
315315
batch=max_batch_size,
316316
seq_len=merged['input'][0] // max_batch_size,

analyzer/setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
"torch>=1.4.0",
4848
"pandas>=1.1.2",
4949
"tqdm>=4.49.0",
50-
"nvidia-cuda-cupti-cu11==11.7.101",
51-
"nvidia-cuda-runtime-cu11==11.7.99",
50+
"nvidia-cuda-cupti-cu12",
51+
"nvidia-cuda-runtime-cu12",
5252
"incremental"
5353
]
5454

cpp/src/frontend/profiler.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,9 @@ std::vector<KernelInstance> profile(
3939
return kernels;
4040
}
4141

42+
void release_cupti_hook(){
43+
CuptiManager::instance().unloadCupti();
44+
}
45+
4246
}
4347
}

cpp/src/frontend/profiler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ std::vector<cuda::KernelInstance> profile(std::function<void()> runnable);
1616
std::vector<cuda::KernelInstance> profile(
1717
std::function<void()> runnable, const std::string& metric);
1818

19+
void release_cupti_hook();
1920
}
2021
}

cpp/src/habitat_cuda.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,8 @@ PYBIND11_MODULE(habitat_cuda, m) {
3131
.def("run_flop_test", [](size_t num_blocks, size_t threads_per_block) {
3232
habitat::cuda::diagnostics::run_flop_test(num_blocks, threads_per_block);
3333
}, py::arg("num_blocks") = 8192, py::arg("threads_per_block") = 256);
34+
35+
m.def("release_cupti_hook",[](){
36+
habitat::frontend::release_cupti_hook();
37+
});
3438
}

0 commit comments

Comments
 (0)