Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,28 @@ public TornadoExecutionPlan createExecutionPlan() {

// ── Initialisation ────────────────────────────────────────────────────────

/**
* Puts the read-only weights on the device. With CUDA graphs enabled the pass is also the
* capture, so it still runs every graph; otherwise it is a plain copy-in and no kernel runs.
*/
// @formatter:off
@Override
public void forceCopyInReadOnlyData() {
if (!CUDA_GRAPHS) {
executionPlan.transferToDevice();
return;
}

state.wrapX.clear();
state.positionHolder.init(0);
state.wrapXBatch.clear();
state.batchStartPosHolder.init(0);

for (int i = 0; i <= taskGraphLayout.logitsIdx(); i++) {
var g = executionPlan.withGraph(i)
.withGridScheduler(batchPrefillDecodeForwardPlan.getGridScheduler());
if (CUDA_GRAPHS) {
g.withCUDAGraph();
}
g.execute();
executionPlan.withGraph(i)
.withGridScheduler(batchPrefillDecodeForwardPlan.getGridScheduler())
.withCUDAGraph()
.execute();
}
}
// @formatter:on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,26 @@ public TornadoExecutionPlan createExecutionPlan() {

// ── Initialisation ────────────────────────────────────────────────────────

/** Runs all graphs once to trigger FIRST_EXECUTION uploads and warm up CUDA graphs. */
/**
* Puts the read-only weights on the device. With CUDA graphs enabled the pass is also the
* capture, so it still runs every graph; otherwise it is a plain copy-in and no kernel runs.
*/
// @formatter:off
@Override
public void forceCopyInReadOnlyData() {
if (!CUDA_GRAPHS) {
executionPlan.transferToDevice();
return;
}

state.wrapX.clear();
state.positionHolder.init(0);

for (int i = 0; i <= taskGraphLayout.logitsIdx(); i++) {
var g = executionPlan.withGraph(i)
.withGridScheduler(prefillDecodeForwardPlan.getGridScheduler());
if (CUDA_GRAPHS) {
g.withCUDAGraph();
}
g.execute();
executionPlan.withGraph(i)
.withGridScheduler(prefillDecodeForwardPlan.getGridScheduler())
.withCUDAGraph()
.execute();
}
}
// @formatter:on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,18 @@ public FloatArray tornadoVMForwardDecode(int position) {
}
// @formatter:on

/**
* Puts the read-only weights on the device. With CUDA graphs enabled the pass is also the
* capture, so it still runs every graph; otherwise it is a plain copy-in and no kernel runs.
*/
// @formatter:off
@Override
public void forceCopyInReadOnlyData() {
if (!CUDA_GRAPHS) {
executionPlan.transferToDevice();
return;
}

state.wrapX.clear();
state.positionHolder.init(0);

Expand Down
Loading