@@ -60,6 +60,7 @@ extern "C" {
6060 int cudaStreamSynchronize (void * stream);
6161}
6262constexpr int cudaMemcpyDeviceToHost = 2 ;
63+ constexpr int cudaMemcpyDefault = 4 ;
6364constexpr int cudaMemcpyDeviceToDevice = 3 ;
6465
6566// Static memory hijacking: additional CUDA API forward declarations
@@ -356,7 +357,7 @@ void phase2_hijack::copy_data_to_static(void* cuda_stream) {
356357 for (int i = 0 ; i < n_slots; i++) {
357358 if (slots[i].addr && slots[i].orig_data && slots[i].size > 0 ) {
358359 cudaMemcpyAsync (slots[i].addr , slots[i].orig_data ,
359- slots[i].size , cudaMemcpyDeviceToDevice , (cudaStream_t)cuda_stream);
360+ slots[i].size , cudaMemcpyDefault , (cudaStream_t)cuda_stream);
360361 }
361362 }
362363}
@@ -2084,21 +2085,6 @@ llm_graph_result * llama_context::process_ubatch(const llama_ubatch & ubatch, ll
20842085 ggml_tensor * t = ggml_graph_node (phase2_gf, i);
20852086 auto [tid, il] = h2_hijack.match_name (t->name );
20862087 if (tid >= 0 ) ggml_backend_sched_set_tensor_backend (sched.get (), t, gpu);
2087- if (t->op == GGML_OP_GLU ) {
2088- for (int s = 0 ; s < 2 && t->src [s]; s++)
2089- ggml_backend_sched_set_tensor_backend (sched.get (), t->src [s], gpu);
2090- }
2091- if (t->op == GGML_OP_MUL_MAT_ID ) {
2092- for (int s = 0 ; s < GGML_MAX_SRC && t->src [s]; s++) {
2093- if (s == 0 ) continue ; // src[0]=weight: MoE cache GPU buffer, don't force
2094- ggml_backend_sched_set_tensor_backend (sched.get (), t->src [s], gpu);
2095- }
2096- }
2097- }
2098- for (int i = 0 ; i < ggml_graph_n_leafs (phase2_gf); i++) {
2099- ggml_tensor * t = ggml_graph_leaf (phase2_gf, i);
2100- auto [tid, il] = h2_hijack.match_name (t->name );
2101- if (tid >= 0 ) ggml_backend_sched_set_tensor_backend (sched.get (), t, gpu);
21022088 }
21032089 force_idxs_to_cpu ();
21042090 if (!ggml_backend_sched_alloc_graph (sched.get (), phase2_gf)) {
@@ -2121,11 +2107,15 @@ llm_graph_result * llama_context::process_ubatch(const llama_ubatch & ubatch, ll
21212107 res->set_inputs (&ubatch);
21222108 void * capture_st = ggml_backend_cuda_get_stream_ptr (gpu, 0 );
21232109 h2_hijack.copy_data_to_static (capture_st);
2110+ fprintf (stderr, " phase2: D2D copy done, starting capture\n " );
21242111 ggml_backend_sched_synchronize (sched.get ());
21252112
21262113 // 5. CUDA Graph Capture
2114+ fprintf (stderr, " phase2: beginCapture...\n " );
21272115 if (cudaStreamBeginCapture (capture_st, cudaStreamCaptureModeRelaxed) == cudaSuccess) {
2116+ fprintf (stderr, " phase2: capture started, computing...\n " );
21282117 auto s = graph_compute (phase2_gf, false );
2118+ fprintf (stderr, " phase2: graph_compute done status=%d\n " , (int )s);
21292119 if (s == GGML_STATUS_SUCCESS ) {
21302120 cudaGraph_t g;
21312121 if (cudaStreamEndCapture (capture_st, &g) == cudaSuccess) {
0 commit comments