Repository navigation
Closed
Labels
component: testingAdd test cases and benchmark-related taskstype: performancePerformance optimization tasks aimed at increasing throughput and reducing latency etc.
Description
Summary
Add a generic benchmark suite for evaluating Kernel-Align kernels under RL-shaped synthetic workloads.
fused_logp should be the first benchmarked operator, but the benchmark framework should support future kernels through adapters rather than being hardcoded to one CUDA file.
Why This Issue Exists
The README positions Kernel-Align as infrastructure for GRPO and large-scale RL post-training. Kernel benchmarks should therefore measure dimensions that matter to RL loops:
- group size and samples per prompt;
- prompt/completion length;
- valid-token density;
- vocab size or hidden size depending on operator type;
- dtype and output precision;
- peak extra memory;
- latency under realistic masks;
- numerical drift against reference operators.
A generic RL-shaped benchmark layer prevents each kernel PR from inventing its own benchmark metadata and fixture logic.
Scope
Add a benchmark script or package, for example:
benchmarks/benchmark_rl_kernels.py- optional per-op adapters under
benchmarks/rl_kernel_cases/
Initial operator adapters:
selected_logprob:- PyTorch reference
log_softmax + gather; - current
kernel_align_ops.fused_logp; - future
outbuffer and valid-token variants.
- PyTorch reference
Future adapters should be possible for:
- sampling kernels;
- attention kernels;
- masked reductions;
- GRPO/PPO/DPO loss kernels.
Benchmark dimensions:
- num prompts;
- samples per prompt / group size
G; - prompt length;
- completion length;
- vocab size;
- hidden size when relevant;
- dtype;
- valid-token mask density;
- output precision;
- operator name.
Record:
- latency;
- peak memory;
- valid token count;
- max reference error;
- ratio drift, if logprobs are involved;
- KL drift, if reference logps are involved;
- OOM or skipped-shape notes.
Non-Goals
- Do not require a real model.
- Do not require a real RL dataset.
- Do not require vLLM, DeepSpeed, Ray, TRL, OpenRLHF, or verl.
- Do not replace full end-to-end RL benchmarks.
- Do not implement kernel optimizations in this issue.
Suggested Implementation
- Reuse the generic RL kernel batch fixture.
- Reuse the generic RL reference operators.
- Define a small benchmark adapter interface:
class RLKernelBenchmarkCase(Protocol):
name: str
def make_inputs(self, batch, config): ...
def run_reference(self, inputs): ...
def run_candidate(self, inputs): ...
def summarize(self, reference, candidate, inputs): ...- Use CUDA synchronization around timing.
- Use
torch.cuda.reset_peak_memory_stats()andtorch.cuda.max_memory_allocated()for memory tracking. - Support smoke mode for local development.
- Support large shapes for A100/H100-class GPUs.
- Emit CSV rows suitable for KDA workspace
benchmark.csvfiles.
Suggested CLI:
py -3.13 benchmarks/benchmark_rl_kernels.py --case selected_logprob --smoke
py -3.13 benchmarks/benchmark_rl_kernels.py --case selected_logprob --g-sizes 64,128,256 --completion-lens 256,512 --vocab-sizes 128256Acceptance Criteria
- Smoke benchmark runs on small CUDA shapes.
- Benchmark can skip or record OOM shapes without crashing the whole run.
- CSV output includes operator name, shape, dtype, mask density, precision, latency, memory, and correctness drift.
- The first adapter benchmarks
fused_logpasselected_logprob. - The benchmark structure can add at least one future operator adapter without rewriting the runner.
Dependencies
- Generic RL kernel batch schema and fixtures.
- Generic RL kernel reference operators.
- Existing
kernel_align_ops.fused_logpextension when CUDA is available for the first adapter.
Follow-Up Users
fused_logp_kernel.cuoptimization candidates.- Hardware benchmark dashboard issue.
- Automated performance profiling suite issue.
- Future sampling, attention, and RL loss kernel PRs.
Metadata
Metadata
Assignees
Labels
component: testingAdd test cases and benchmark-related taskstype: performancePerformance optimization tasks aimed at increasing throughput and reducing latency etc.
Activity
inaniloquentee commentedon May 31, 2026
This is the PR: #43