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

Đang mở
#31 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
15/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python, pytorch
Lĩnh vực
testing

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
Python
Star
340
Fork
37
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của NVIDIA/SOL-ExecBench

Tất cả issue của NVIDIA/SOL-ExecBench

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.