Skip to content

[FEAT][benchmarking]: add RL-shaped fused_logp benchmark suite #29

Closed

Description

@inaniloquentee

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 out buffer and valid-token variants.

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

  1. Reuse the generic RL kernel batch fixture.
  2. Reuse the generic RL reference operators.
  3. 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): ...
  1. Use CUDA synchronization around timing.
  2. Use torch.cuda.reset_peak_memory_stats() and torch.cuda.max_memory_allocated() for memory tracking.
  3. Support smoke mode for local development.
  4. Support large shapes for A100/H100-class GPUs.
  5. Emit CSV rows suitable for KDA workspace benchmark.csv files.

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 128256

Acceptance 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_logp as selected_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_logp extension when CUDA is available for the first adapter.

Follow-Up Users

  • fused_logp_kernel.cu optimization candidates.
  • Hardware benchmark dashboard issue.
  • Automated performance profiling suite issue.
  • Future sampling, attention, and RL loss kernel PRs.

Activity

  1. added
    component: testing
    type: performance
    on May 31, 2026
  2. inaniloquentee commented on May 31, 2026

    @inaniloquentee
    CollaboratorAuthor

    This is the PR: #43

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

component: testingtype: performance

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions