"算子开发(Operator Kernel Development)"在真实工业环境里,绝对不只是"写一个 conv 的实现",而是:
围绕一个 Operator,在特定硬件 + 特定编译器 + 特定 workload 下,设计最优 kernel + schedule + memory layout + fusion 策略。
下面我给你一个完全真实的岗位工作分解(GPU / AI 加速器公司基本一致)。
一、算子开发到底在做什么(真实职责分层)
算子开发 ≠ 写算法
算子开发 =
Operator Semantics
↓
Kernel Design
↓
Loop Schedule
↓
Memory Movement
↓
Hardware Mapping
二、你说的 "设计不同底层实现" ------ 是对的,但要具体到这 5 类工作
① Kernel 实现(最核心)
比如 Conv2D。
不会只有一个实现。
常见 kernel family:
direct conv
im2col + GEMM
winograd
fft conv
implicit GEMM
tensorcore conv
算子开发做的就是:
为不同 shape / 硬件 / dtype 设计不同 kernel
例如:
small batch → direct conv
large batch → tensorcore GEMM conv
1x1 conv → GEMM
depthwise → special kernel
② Schedule 设计(DL 编译器核心)
你应该非常熟悉这个层级(因为你做体系结构)。
他们会设计:
tiling
blocking
loop reorder
unroll
vectorize
tensorize
pipeline
例如 TVM:
s[C].tile(i,j,32,32)
s[C].tensorize(...)
本质:
设计 loop nest 结构
③ Memory Layout & Dataflow 设计(真正的性能关键)
算子开发大量时间花在:
NHWC vs NCHW
COL32 layout
TensorCore fragment layout
shared memory swizzle
bank conflict removal
因为:
性能瓶颈 70% 在 memory,而不是 compute
④ Kernel Fusion(现在最热门)
例如:
matmul + bias + gelu + residual
算子开发会写:
fused kernel
原因:
减少 global memory traffic
FlashAttention 就是:
attention 算子级 fusion
⑤ Auto-tuning & Kernel Selection
真实系统不会只有一个 kernel。
而是:
kernel registry
+
shape-based dispatch
例如:
if M<128 → kernel A
if head_dim=64 → kernel B
if bf16 → kernel C
三、一个真实 NVIDIA / ByteDance / Huawei 算子开发工作日
你可能会:
Step1
分析 profile:
conv2d 占 40% latency
Step2
看 IR:
lowered loop
memory access pattern
Step3
设计新 kernel:
warp tile = 64x64
block tile = 128x128
Step4
写:
CUDA
Triton
CUTLASS
TVM TensorIR
MLIR Linalg
Step5
调:
occupancy
bank conflict
register pressure
L2 hit rate
四、不同公司的"算子开发"差别非常大(这是关键)
1️⃣ GPU 公司(NVIDIA / AMD)
重点:
TensorCore mapping
warp-level MMA
PTX
CUTLASS
2️⃣ AI Compiler 公司(TVM / ByteDance / OpenAI infra)
重点:
IR lowering
schedule search
fusion
autotuning
3️⃣ AI 芯片公司(寒武纪 / 华为昇腾 / 壁仞)
重点:
mapping to NPU dataflow
on-chip SRAM scheduling
DMA orchestration
4️⃣ LLM Infra 公司(DeepSeek / Anthropic infra)
重点:
fused transformer kernels
flash attention
kv-cache kernels
quant kernels
五、一个非常重要的认知(90%新人完全误解)
算子开发:
❌ 不是写 PyTorch operator
❌ 不是写算法
❌ 不是写模型
而是:
写 HPC Kernel
+
写 Compiler Schedule
+
写 Hardware Mapping
本质岗位:
AI 时代的 HPC Kernel Engineer
六、基于你的背景(体系结构 + ysyx + Verilog)
我非常明确告诉你:
你其实非常适合做:
AI Hardware Mapping 型算子开发
比普通 CS 出身更适合。
因为你已经理解:
loop
dataflow
memory hierarchy
而这些就是算子优化的核心。