Norm weights are generated as all ones and biases as all zeros, so kernels that ignore or misuse them pass

Đang mở
#25 1 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ó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
64/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

Hướng nghiên cứu

Start in src/sol_execbench/core/bench/io.py at _generate_heuristic_tensor around lines 281-285, then run the CPU reproduction for L1/082_qk_norm_scaled_dot_product_attention. Inspect the 26 problems with their own get_inputs and the listed constant weights and biases. Done means declared random norm inputs vary element-wise while intentional constants remain unchanged and the reference workloads still pass.

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

Mô tả

Summary

_generate_heuristic_tensor fills inputs that look like norm weights with torch.ones and norm biases with torch.zeros (io.py#L281-L285). It does this even when the workload declares the input "random". Many problems' own get_inputs also set weights and biases to constants.

A constant tensor hides any kernel that ignores it, applies it twice, or reads it at the wrong index. Scaling inputs (x3, x0.01, negation) does not help: a scaled constant is still a constant.

Reproduction (CPU only)

Commit a9fa080 (current main). Dataset nvidia/SOL-ExecBench at 6369940 (current).

import json
from collections import defaultdict
from pathlib import Path

import torch
from sol_execbench.core.bench.io import gen_inputs
from sol_execbench.core.data.definition import Definition
from sol_execbench.core.data.workload import Workload

p = Path("data/benchmark/L1/082_qk_norm_scaled_dot_product_attention")
d = Definition(**json.loads((p / "definition.json").read_text()))
const = defaultdict(set)
hits = defaultdict(int)
lines = (p / "workload.jsonl").read_text().splitlines()
for line in lines:
    w = Workload(**json.loads(line))
    for name, x in zip(d.inputs, gen_inputs(d, w, "cpu")):
        if isinstance(x, torch.Tensor) and x.is_floating_point() and x.unique().numel() == 1:
            const[name].add(x.flatten()[0].item())
            hits[name] += 1
for name, vals in const.items():
    print(f"{name}: all elements = {sorted(vals)} in {hits[name]}/{len(lines)} workloads")
q_norm_weight: all elements = [1.0] in 16/16 workloads
q_norm_bias: all elements = [0.0] in 16/16 workloads
k_norm_weight: all elements = [1.0] in 16/16 workloads
k_norm_bias: all elements = [0.0] in 16/16 workloads

All four inputs are declared {"type": "random"} in workload.jsonl.

Effect

sol-execbench CLI, a9fa080, 1x B200, L1/082. The second column uses the two-line change proposed below.

Solution Current inputs Norm weights 1 + 0.1·N(0,1), biases 0.1·N(0,1)
Reference 16/16 16/16
Reference with the four norm inputs replaced by ones/zeros 16/16 0/16
Agent-written CUDA C++ kernel that applies the LayerNorm affine twice 16/16 0/16

The agent kernel also passes 16/16 with inputs x3, x0.01 and negated.

A second agent kernel shows the same problem on a problem with its own get_inputs. On L1/021 (qkv_bias and proj_bias are zeros), a CUDA C++ kernel adds qkv_bias to each element but not to its rotary partner. It passes 16/16 on current inputs, and 16/16 with inputs x3, x0.01 and negated. With element-wise random biases it passes 0/16.

Scope

Smallest workload of each problem, generated on CPU:

  • 195 of 235 problems generate on CPU. The other 40 do not: 26 FlashInfer-Bench definitions fail Definition validation (hf_id), and 14 nvfp4 problems need a GPU.
  • 61 of 195 have at least one float input whose elements are all equal. That is 179 inputs: 94 weights/scales, 79 biases, 6 other.
  • 35 of the 61 use the default generator only. The other 26 define their own get_inputs.
  • 51 problems have inputs matched by _is_norm_weight / _is_norm_bias. In 46 of 51, the reference with those inputs replaced by ones/zeros passes every workload. All 46 fail once those inputs vary element-wise.

Some constants are intentional, such as initial recurrent states. Weights and biases are the concern.

All 61 problems
Problem Own get_inputs Constant inputs
L1/002_vae_conv3x3_groupnorm_silu_residual_fused no norm1_weight = 1, norm1_bias = 0, norm2_weight = 1, norm2_bias = 0
L1/015_grouped_query_attention_with_rope_and_qk_norm no q_norm_weight = 1, k_norm_weight = 1
L1/018_fused_rope_with_qk_norm_and_kv_cache_update yes q_norm_weight = 1, k_norm_weight = 1
L1/020_vision_patch_merger_spatial_shuffle_mlp yes ln_weight = 1, ln_bias = 0
L1/021_vision_cu_seqlens_variable_length_attention yes qkv_bias = 0, proj_bias = 0
L1/026_video_patch_embedding_projection no norm_weight = 1, norm_bias = 0
L1/027_video_spatial_attention_with_rope_3d yes qkv_bias = 0, out_bias = 0
L1/043_mla_fused_qkv_rope_split no q_a_layernorm_weight = 1
L1/047_attention_with_qk_norm_and_rope no q_norm_weight = 1, k_norm_weight = 1
L1/051_attention_qkv_with_qk_norm_single_kernel_backward no q_norm_weight = 1, k_norm_weight = 1
L1/054_audio_attention_qkv_projection_with_normalization no q_norm_weight = 1, k_norm_weight = 1
L1/064_latent_kv_expansion_with_split no kv_a_layernorm_weight = 1
L1/073_fused_encoder_final_norm_to_decoder_cross_attention_kv_projection no norm_weight = 1
L1/082_qk_norm_scaled_dot_product_attention no q_norm_weight = 1, q_norm_bias = 0, k_norm_weight = 1, k_norm_bias = 0
L1/089_vae_attention_block_with_groupnorm no group_norm_weight = 1, group_norm_bias = 0
L1/091_fused_gqa_qkv_rope_qk_norm_backward no q_norm_weight = 1, k_norm_weight = 1
L1/092_gqa_attention_with_qk_norm no q_norm_weight = 1, k_norm_weight = 1
L1/094_time_decay_exponential_stabilization yes max_state = finfo.min, num_state = 0, den_state = 0
L2/002_decoder_layer_full_block no input_layernorm_weight = 1, post_attention_layernorm_weight = 1
L2/004_fused_residual_rms_mlp no norm_weight = 1
L2/009_decoder_layer_with_residual_connections yes q_norm_weight = 1, k_norm_weight = 1
L2/018_cu_seqlens_variable_length_vision_attention yes qkv_bias = 0, proj_bias = 0
L2/019_decoder_layer_fused_attention_mlp no input_layernorm_weight = 1, post_attention_layernorm_weight = 1
L2/020_decoder_layer_pre_post_norm_residual no input_layernorm_weight = 1, post_attention_layernorm_weight = 1
L2/022_video_latent_denoising_unet_block no temporal_norm_weight = 1, temporal_norm_bias = 0, spatial_norm_weight = 1, spatial_norm_bias = 0, cross_attn_norm_weight = 1, cross_attn_norm_bias = 0, ffn_norm_weight = 1, ffn_norm_bias = 0
L2/027_grouped_query_attention_with_yarn_rope_and_qk_norm yes q_norm_weight = 1, k_norm_weight = 1
L2/031_flux_timestep_guidance_projection_embedding yes timestep_linear1_bias = 0, timestep_linear2_bias = 0, text_embedder_bias = 0
L2/032_dual_stream_attention_with_conditional_cross_attention yes adaln_linear_bias = 0, to_q_bias = 0, to_k_bias = 0, to_v_bias = 0, to_k_context_bias = 0, to_v_context_bias = 0, to_out_bias = 0
L2/035_convnextv2_block_with_grn no layernorm_weight = 1, layernorm_bias = 0
L2/038_audio_relative_position_attention yes per_dim_scale = 0
L2/039_kv_shared_attention_with_rope yes q_norm_weight = 1, k_norm_weight = 1
L2/040_altup_predict_correction_cycle_backward no norm_weight = 1
L2/041_kv_shared_attention_with_dual_rope yes q_norm_weight = 1, k_norm_weight = 1
L2/042_ffn_gelu_projection_fused_backward yes ln_weight = 1
L2/045_audio_encoder_to_language_model_multimodal_fusion yes encoder_input_bias = 0, encoder_out_bias = 0, encoder_out_mid_bias = 0, qformer_q_proj_bias = 0, qformer_k_proj_bias = 0, qformer_v_proj_bias = 0, qformer_out_proj_bias = 0, projector_bias = 0
L2/046_conformer_relative_position_attention no pre_norm_weight = 1, pre_norm_bias = 0
L2/050_vae_decoder_mid_block_attention_resnet no resnet1_norm1_weight = 1, resnet1_norm1_bias = 0, resnet1_norm2_weight = 1, resnet1_norm2_bias = 0, attn_group_norm_weight = 1, attn_group_norm_bias = 0, resnet2_norm1_weight = 1, resnet2_norm1_bias = 0, resnet2_norm2_weight = 1, resnet2_norm2_bias = 0
L2/051_seqlen-finetuned-reconstructed_hyena_complete_forward_block yes norm1_weight = 1, norm1_bias = 0, norm2_weight = 1, norm2_bias = 0, sin_freq = 1
L2/053_text_decoder_layer_with_self_attention_and_mlp no input_layernorm_weight = 1, post_attention_layernorm_weight = 1
L2/054_vision_encoder_layer_with_gated_residuals no input_layernorm_weight = 1, input_layernorm_bias = 0, post_attention_layernorm_weight = 1, post_attention_layernorm_bias = 0
L2/055_audio_encoder_conv_positional_layer_stack yes self_attn_layer_norm_weight = 1, self_attn_layer_norm_bias = 0, final_layer_norm_weight = 1, final_layer_norm_bias = 0
L2/058_mamba2_selective_scan no norm_weight = 1
L2/059_decoder_layer_full_block no input_layernorm_weight = 1, q_norm_weight = 1, k_norm_weight = 1, post_attention_layernorm_weight = 1
L2/062_decoder_complete_layer no self_attn_norm_weight = 1, cross_attn_norm_weight = 1, mlp_norm_weight = 1
L2/063_encoder_layer_dual_residual_norm_chain no pre_sa_norm_weight = 1, post_sa_norm_weight = 1
L2/065_sparse_expert_dispatch_and_combine yes gate_up_proj_bias = 0, down_proj_bias = 0
L2/066_resnet_block_with_time_embedding no norm1_weight = 1, norm1_bias = 0, norm2_weight = 1, norm2_bias = 0
L2/069_joint_transformer_block_residual_path yes norm1_weight = 1, norm1_bias = 0
L2/070_basic_transformer_block no norm1_weight = 1, norm1_bias = 0, norm2_weight = 1, norm2_bias = 0, norm3_weight = 1, norm3_bias = 0
L2/071_edit_consistency_loss_with_perceptual_weighting yes extractor0_conv1_bias = 0, extractor0_conv2_bias = 0, extractor1_conv1_bias = 0, extractor1_conv2_bias = 0, extractor2_conv1_bias = 0, extractor2_conv2_bias = 0, scale_weights = 0.333333
L2/072_region_aware_self_attention_with_edit_bias_backward yes qkv_bias = 0, out_bias = 0, attention_mask = 1
L2/075_sam_hq_mask_decoder_two_way_transformer no layer_norm1_weight = 1, layer_norm1_bias = 0, layer_norm2_weight = 1, layer_norm2_bias = 0, layer_norm3_weight = 1, layer_norm3_bias = 0, layer_norm4_weight = 1, layer_norm4_bias = 0
L2/076_sam_hq_vision_attention_with_relative_position_backward yes qkv_bias = 0, proj_bias = 0
L2/077_sam_hq_vision_encoder_window_partition_attention no layer_norm1_weight = 1, layer_norm1_bias = 0, layer_norm2_weight = 1, layer_norm2_bias = 0
L2/078_fused_final_layer_upsample_with_adaptive_norm yes resblock_in_norm_weight = 1, resblock_in_norm_bias = 0, resblock_out_norm_weight = 1, resblock_out_norm_bias = 0, final_norm_weight = 1, final_norm_bias = 0
L2/079_git_vision_encoder_layer no layer_norm1_weight = 1, layer_norm1_bias = 0, layer_norm2_weight = 1, layer_norm2_bias = 0
L2/080_moe_complete_layer_with_shared_expert_backward yes e_score_correction_bias = 0, score_mask = 1
Quant/002_fp8_attention_qkv_projection no q_norm_weight = 1, k_norm_weight = 1
Quant/013_fp8_mla_kv_compression_projection yes kv_a_layernorm_weight = 1
Quant/016_fp8_multi_latent_attention_qkv_projection no q_a_layernorm_weight = 1, kv_a_layernorm_weight = 1
Quant/023_fp8_mamba2_ssm_discretization yes dt_bias = 1

Proposed fix

  1. In _generate_heuristic_tensor:

         if _is_norm_weight(name):
    -        return torch.ones(shape, dtype=dtype, device=device)
    +        return (1 + 0.1 * torch.randn(shape, device=device)).to(dtype)
    
         if _is_norm_bias(name):
    -        return torch.zeros(shape, dtype=dtype, device=device)
    +        return (0.1 * torch.randn(shape, device=device)).to(dtype)
    

    With this change the L1/082 reference still passes 16/16, and both wrong solutions fail 0/16.

  2. In the 26 problems with their own get_inputs, replace constant weights and biases with element-wise random values.

  3. Optionally, flag any generated float tensor whose elements are all equal.

I can open a PR for (1) and (3).

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.