Skip to content

Commit fd9e4d3

Browse files
authored
Add event tracer support for channelwise gated (pytorch#21389)
Differential Revision: D113603106 Pull Request resolved: pytorch#21389
1 parent d9e7a2e commit fd9e4d3

4 files changed

Lines changed: 447 additions & 361 deletions

File tree

‎extension/llm/custom_ops/BUCK‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ non_fbcode_target(_kind = define_common_targets,)
1313
# Any targets that should be shared between fbcode and xplat must be defined in
1414
# targets.bzl. This file can contain fbcode-only targets.
1515

16+
load("@fbsource//tools/target_determinator/macros:ci.bzl", "ci")
1617
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
1718
load(":targets.bzl", "define_common_targets")
1819

@@ -45,6 +46,26 @@ fbcode_target(_kind = runtime.python_test,
4546
],
4647
deps = [
4748
"//caffe2:torch",
49+
],
50+
)
51+
52+
fbcode_target(_kind = runtime.python_test,
53+
name = "test_gated_delta",
54+
srcs = [
55+
"test_gated_delta.py",
56+
],
57+
# Builds the runtime, kernels and custom_ops with -DET_EVENT_TRACER_ENABLED so
58+
# the .pte-execution test can assert the op's per-op native_call_ ETDump event.
59+
labels = [] if runtime.is_oss else ci.labels(
60+
ci.buckconfig("executorch.event_tracer_enabled", "true"),
61+
),
62+
preload_deps = [
63+
":custom_ops_aot_lib",
64+
":custom_ops_aot_py",
65+
],
66+
deps = [
67+
"//caffe2:torch",
68+
"//executorch/devtools:lib",
4869
"//executorch/exir:lib",
4970
"//executorch/runtime:runtime",
5071
],

‎extension/llm/custom_ops/op_sdpa.cpp‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <ATen/cpu/vec/functional.h>
1313
#include <ATen/cpu/vec/vec.h>
1414
#include <executorch/kernels/optimized/blas/CPUBlas.h>
15+
#include <executorch/runtime/core/event_tracer_hooks.h>
1516
#include <executorch/runtime/core/exec_aten/util/dim_order_util.h>
1617
// @lint-ignore CLANGTIDY facebook-unused-include-check
1718
#include <c10/util/irange.h>
@@ -1308,6 +1309,10 @@ namespace {
13081309
void channelwise_gated_delta_rule_out_boxed(
13091310
executorch::runtime::KernelRuntimeContext& ctx,
13101311
executorch::runtime::Span<executorch::runtime::EValue*> stack) {
1312+
executorch::runtime::internal::EventTracerProfileOpScope
1313+
event_tracer_op_scope(
1314+
ctx.internal_event_tracer(),
1315+
"native_call_llama::channelwise_gated_delta_rule.out");
13111316
// Multi-output out variants get a trailing TensorList aggregating the two
13121317
// outputs appended by the emitter, so the boxed stack has 9 entries: 6 inputs
13131318
// + out + final_state_out + [out, final_state_out]. The aggregate (stack[8])

0 commit comments

Comments
 (0)