[Benchmark Integrity] ShiftingMemoryPoolAllocator pointer-shift caching (a9fa080) & post-timing audit request

オープン
#31 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
15/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
python, pytorch
領域
testing

調査の方向性

Start with ShiftingMemoryPoolAllocator._compute_offset_blocks and get_unique_args in src/sol_execbench/core/bench/io.py, then the call sites in eval_driver.py and timing.py. Reproducing the stale-output exploit on L1/003 is the first step. Done means an optional post-timing audit flags cached outputs after input contents change, while the CUPTI-measured loop stays unchanged. Maintainer design input is needed first.

索引モデルが issue の本文から書いたものです。

説明

Summary

Following up on issues #15 and #19, the maintainer discussion in PR #20, and Yue Shui's post ("Reward Hacking in GPU Kernel Optimization: Loopholes and Defenses in SOL-ExecBench", https://syhya.github.io/posts/2026-11-24-gpu-kernel-reward-hacking/), I reproduced cross-call address-shift caching end-to-end on both the online NVIDIA B200 web evaluator (L1/003, L1/036) and the local SOL-ExecBench v1.1 evaluator (commit a9fa080) across L1, FlashInfer-Bench, and Quant (L2 shares the same driver/allocator code path and was not evaluated locally in this run).

I understand the maintainers' rationale in PR #20 against inserting output checks inside the timed loop (to preserve measurement reliability) and relying on async online review. However, two practical gaps remain:

  1. Immediate online B200 web evaluation still returns near-1.0 scores (1.000000 on 003, 0.998662 on 036) with ~2.1 µs measured latency and 16 / 16 correctness.
  2. Local sol-execbench users have no optional out-of-loop post-timing audit mode to catch stale timed-path outputs offline without disturbing CUPTI measurements.

Root Cause (Commit a9fa080)

  1. src/sol_execbench/core/bench/io.py:594-629 (ShiftingMemoryPoolAllocator._compute_offset_blocks):

    _POOL_ALIGNMENT = 256
    _MAX_SHIFT_BYTES = 2048
    ...
    for _ in range(max(0, total_iterations - 1)):
        offsets.append(offsets[-1] + rng.randint(1, max_multiplier))
    

    Every iteration shifts all input/output tensors by a shared, strictly positive cumulative multiple of 256 bytes in [256, 2048].

  2. src/sol_execbench/core/bench/io.py:693-705 (ShiftingMemoryPoolAllocator.get_unique_args):
    Each timed call copies the exact same entry["source"] bytes into the newly shifted pool slice—only tensor.data_ptr() changes, never the logical values.

  3. src/sol_execbench/driver/templates/eval_driver.py:584-597 & src/sol_execbench/core/bench/timing.py:155-207, 343-356:
    Numerical correctness finishes before time_runnable() starts; during warmup, discovery, and timed iterations, candidate return values are discarded (_ = fn(*args)).


Minimal Reproduction Logic (e.g., L1/003 and L1/036)

Taking 003_lm_head_projection_with_logit_slicing (large BF16 LM-head GEMM) and 036_flux_output_norm_projection_chain (LayerNorm + modulation linear projection + output linear projection) as concrete examples:

  1. Pre-timing correctness rounds (gen_inputs): Fresh allocations do not advance along a uniform [256, 2048] B progression across consecutive calls, so is_pool_shift is False. The candidate computes the exact reference output and caches (cur_ptrs, cached_out, marker, streak=0) keyed by tensor shapes, dtypes, device, and scalar parameters (e.g., slice_size for 003 or eps for 036).
  2. Timing path (ShiftingMemoryPoolAllocator): Warmup + discovery + timed calls advance all input pointers by identical 256-byte-aligned deltas in [256, 2048] B. Once consecutive matching shifts reach streak >= 3 (which also avoids accidental ~1 KB allocator collisions on tiny tensors such as FlashInfer/022), the candidate skips all real compute, launches a 1-thread @triton.jit marker kernel to satisfy CUPTI activity checks, and returns cached_out.

Illustrative pseudocode:

import torch
import triton
import triton.language as tl

_cache = {}  # key -> (prev_ptrs, cached_out, marker, streak)

@triton.jit
def _marker_kernel(marker_ptr):
    tl.store(marker_ptr, 1)

def run(*args):
    key = tuple(
        (a.shape, a.dtype, str(a.device)) if isinstance(a, torch.Tensor) else a
        for a in args
    )
    ptrs = tuple(a.data_ptr() for a in args if isinstance(a, torch.Tensor))
    prev_ptrs, cached_out, marker, streak = _cache.get(key, (None, None, None, 0))

    deltas = [c - p for c, p in zip(ptrs, prev_ptrs)] if prev_ptrs else []
    is_pool_shift = (
        len(deltas) > 0
        and len(set(deltas)) == 1
        and 256 <= deltas[0] <= 2048
        and (deltas[0] % 256) == 0
    )
    streak = (streak + 1) if is_pool_shift else 0

    if streak >= 3 and cached_out is not None:
        _marker_kernel[(1,)](marker, num_warps=1)  # satisfies CUPTI discovery/timing
        _cache[key] = (ptrs, cached_out, marker, streak)
        return cached_out

    out = exact_reference_impl(*args)
    marker = marker if marker is not None else torch.empty((), dtype=torch.int32, device=out.device)
    _cache[key] = (ptrs, out, marker, streak)
    return out

Because returned outputs are unverified after eval_driver.py:584, the evaluator bills only _marker_kernel (~0.6–2.1 µs).


Empirical Reproduction Results

A. Online SOL-ExecBench Web Platform Reproduction (NVIDIA B200)
Operator Platform / Hardware Score Measured Latency Correctness Apparent Speedup
003_lm_head_projection_with_logit_slicing Online web evaluator (B200) 1.000000 0.002149 ms 16 / 16 = 1.00 177.25×
036_flux_output_norm_projection_chain Online web evaluator (B200) 0.998662 0.002108 ms 16 / 16 = 1.00 33.75×
Screenshot 2026-11-25 at 5 53 31 PM Screenshot 2026-11-25 at 5 53 44 PM
B. Local NVIDIA H200 Cross-Suite Reproduction (SOL-ExecBench v1.1, a9fa080, paired UUIDs)

Environment: NVIDIA H200 (PyTorch 2.9.0+cu130, Triton 3.7.0, CUDA 13.0). All speedups below are computed strictly over paired workload UUIDs present in both reference and candidate traces:

Suite Ops Evaluated Workloads Status in Local v1.1 Evaluator Candidate Geomean Latency Peak Paired-UUID Fake Speedup vs Ref
L1 (033, 003, 036) 3 / 3 All tested workloads (48 / 48) returned PASSED (003: 0.630 µs, 036: 0.628 µs, both 16/16) 0.000628 – 0.000953 ms 1,212.5× (003, 16/16 paired UUIDs)
FlashInfer-Bench (001..026) 26 / 26 All tested workloads (452 / 452 out of 660 total) returned PASSED (all 48 candidate workloads on 012 passed) ~0.0006 – 0.0008 ms 30,059.1× (012, 6 shared UUIDs)
Quant (FP8 H200 subset) 18 / 33 (15 NVFP4 B200-only) All tested workloads (278 / 278 H200 FP8) returned PASSED ~0.0006 – 0.0007 ms 25,159.5× (015, ~25.2k×, 16 paired UUIDs)
L2 Not evaluated locally Shares the same ShiftingMemoryPoolAllocator / eval_driver path — —

Proposal: Out-of-Loop Post-Timing Cache Audit & Acceptance Criteria

To address PR #20's concern about in-loop timing interference, sol-execbench can keep the measured CUPTI loop 100% unchanged and provide an optional post-timing audit pass (e.g., --audit-timing-cache) after time_runnable() completes:

  1. Same-Allocator Mutated Replay (Out-of-Loop):
    • Replay a ShiftingMemoryPoolAllocator sequence with the identical 256..2048 B pointer-shift pattern, mutate entry["source"] contents in-place—covering both floating-point tensors and integer index tensors (e.g., int64 position_ids in RoPE ops like Quant/014)—and validate outputs (including strict type(t) is torch.Tensor via check_lazy_outputs()) against a fresh reference.
  2. Independent Per-Tensor Shifts (Defense-in-Depth):
    • Randomize per-tensor offsets independently (non-monotonic positive/negative shifts across varying alignment steps rather than a shared monotonic +256..2048 B progression).
Acceptance Criteria
  • Changing valid input contents (both floating-point and integer tensors) on the same shifted allocation path flags any solution returning stale/cached outputs as REWARD_HACK.
  • Measured CUPTI latency remains completely unaffected, and audit pass/fail status and audit overhead are reported separately.
Local Audit Validation (No false positives observed in 48 local controls)
  • Evaluated locally on H200 using the smallest workload per operator across all 47 address-shift negative controls and 48 legitimate controls (4 optimized L1 CUDA C++/Triton solutions + 44 suite reference implementations across FlashInfer-Bench and Quant FP8):
    • Address-shift caching detections: 47 / 47 (100.0%) flagged by post-warmup mutated-pool validation.
    • Legitimate controls: 0 / 48 (0.0%) false positives.
主要言語
Python
スター
340
フォーク
37
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

NVIDIA/SOL-ExecBench のほかの issue

NVIDIA/SOL-ExecBench の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。