Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring Fusion Executor, pulling out compiled kernel #3082

Closed
wants to merge 17 commits into from
Closed
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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ list(APPEND NVFUSER_SRCS
${NVFUSER_SRCS_DIR}/preseg_passes/reorder_sharded_axis.cpp
${NVFUSER_SRCS_DIR}/rng.cpp
${NVFUSER_SRCS_DIR}/runtime/allocations.cpp
${NVFUSER_SRCS_DIR}/runtime/compiled_kernel.cpp
${NVFUSER_SRCS_DIR}/runtime/executor.cpp
${NVFUSER_SRCS_DIR}/runtime/executor_kernel_arg.cpp
${NVFUSER_SRCS_DIR}/runtime/executor_params.cpp
Expand Down
9 changes: 6 additions & 3 deletions benchmarks/cpp/matmul.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ static void SingleMatmulBase(
FusionExecutor fe;
fe.compileFusion(fusion, args, launch_constraints, cparams);
NVF_CHECK(
getBankConflictInfo(fe.kernel(), launch_constraints).empty(),
getBankConflictInfo(fe.compiledKernel()->kernel(), launch_constraints)
.empty(),
"Shared memory bank conflict not removed.");

std::vector<c10::IValue> aten_inputs({inputs.first, inputs.second});
Expand Down Expand Up @@ -359,7 +360,7 @@ static void SingleMatmulPartitionedK(
auto lparams = LaunchParams();
fe.compileFusion(fusion, args, lparams, cparams);
NVF_CHECK(
getBankConflictInfo(fe.kernel(), lparams).empty(),
getBankConflictInfo(fe.compiledKernel()->kernel(), lparams).empty(),
"Shared memory bank conflict not removed.");

// Warm up run
Expand Down Expand Up @@ -466,7 +467,9 @@ static void NvFuserScheduler_MatmulSplitKReduction(
fusion, args, heuristic_params->lparams, heuristic_params->cparams);

NVF_CHECK(
getBankConflictInfo(fe.kernel(), heuristic_params->lparams).empty(),
getBankConflictInfo(
fe.compiledKernel()->kernel(), heuristic_params->lparams)
.empty(),
"Shared memory bank conflict not removed.");

// Warm up run
Expand Down
6 changes: 5 additions & 1 deletion csrc/evaluator_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,11 @@ void PrecomputedValues::bindValues(
const std::vector<Val*>& inputs,
const KernelArgumentHolder& args) {
NVF_ERROR(
args.size() == inputs.size(), "kernel inputs size does not match args");
args.size() == inputs.size(),
"kernel inputs size does not match args: ",
args.size(),
" vs ",
inputs.size());

for (const auto i : c10::irange((int64_t)inputs.size())) {
const auto input = inputs[i];
Expand Down
14 changes: 8 additions & 6 deletions csrc/python_frontend/fusion_definition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,10 +416,11 @@ std::string FusionDefinition::lastCudaCode(

if (!override_user_schedule && (user_exec != nullptr)) {
if (intrinsic_code) {
result = user_exec->getStructuredCode(
user_exec->kernelString(), user_exec->kernel()->indexType());
result = user_exec->compiledKernel()->getStructuredCode(
user_exec->compiledKernel()->kernelString(),
user_exec->compiledKernel()->kernel()->indexType());
} else {
result = user_exec->kernelString();
result = user_exec->compiledKernel()->kernelString();
}
} else {
result = scheds->auto_gen_schedules->getMostRecentCode(intrinsic_code);
Expand All @@ -445,10 +446,11 @@ std::string FusionDefinition::cudaCodeFor(
scheds, user_sched_id.value(), device);
auto user_exec = user_sched.executor.get();
if (intrinsic_code) {
return user_exec->getStructuredCode(
user_exec->kernelString(), user_exec->kernel()->indexType());
return user_exec->compiledKernel()->getStructuredCode(
user_exec->compiledKernel()->kernelString(),
user_exec->compiledKernel()->kernel()->indexType());
} else {
return user_exec->kernelString();
return user_exec->compiledKernel()->kernelString();
}
}
}
Expand Down
Loading
Loading