Skip to content

Commit 73097f5

Browse files
committed
cont : comments + static_assert
1 parent 6e2ac82 commit 73097f5

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

ggml/src/ggml-cuda/common.cuh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,7 @@ struct ggml_tensor_extra_gpu {
11221122
#endif
11231123

11241124
struct ggml_cuda_graph_node_properties {
1125-
void * node_address;
1125+
void * node_data;
11261126
ggml_op node_op;
11271127
int32_t flags;
11281128
int64_t ne[GGML_MAX_DIMS];
@@ -1131,6 +1131,8 @@ struct ggml_cuda_graph_node_properties {
11311131
int32_t op_params[GGML_MAX_OP_PARAMS / sizeof(int32_t)];
11321132
};
11331133

1134+
static_assert(std::is_trivial<ggml_cuda_graph_node_properties>::value, "ggml_cuda_graph_node_properties must be trivial");
1135+
11341136
struct ggml_cuda_graph {
11351137
#ifdef USE_CUDA_GRAPH
11361138
~ggml_cuda_graph() {
@@ -1149,6 +1151,11 @@ struct ggml_cuda_graph {
11491151
bool disable_due_to_too_many_updates = false;
11501152
int number_consecutive_updates = 0;
11511153
std::vector<ggml_cuda_graph_node_properties> props;
1154+
1155+
// these are extra tensors (inputs) that participate in the ggml graph but are not nodes
1156+
// they properties also have to match in order to be able to safely reuse a CUDA graph
1157+
// ref: https://github.com/ggml-org/llama.cpp/pull/18583
1158+
// ref: https://github.com/ggml-org/llama.cpp/pull/19165
11521159
std::vector<ggml_cuda_graph_node_properties> extra;
11531160

11541161
void record_update(bool use_graph, bool update_required) {

ggml/src/ggml-cuda/ggml-cuda.cu

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2918,7 +2918,7 @@ static bool ggml_cuda_graph_check_compability(ggml_cgraph * cgraph) {
29182918

29192919
static void ggml_cuda_graph_node_set_properties(ggml_cuda_graph_node_properties * props, ggml_tensor * node) {
29202920
memset(props, 0, sizeof(ggml_cuda_graph_node_properties));
2921-
props->node_address = node->data;
2921+
props->node_data = node->data;
29222922
props->node_op = node->op;
29232923
props->flags = node->flags;
29242924
for (int i = 0; i < GGML_MAX_DIMS; i++) {
@@ -2936,8 +2936,7 @@ static void ggml_cuda_graph_node_set_properties(ggml_cuda_graph_node_properties
29362936
}
29372937

29382938
static bool ggml_cuda_graph_node_properties_match(ggml_tensor * node, ggml_cuda_graph_node_properties * props) {
2939-
if (node->data != props->node_address &&
2940-
node->op != GGML_OP_VIEW) {
2939+
if (node->data != props->node_data && node->op != GGML_OP_VIEW) {
29412940
return false;
29422941
}
29432942

0 commit comments

Comments
 (0)