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

Abierto
#25 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
64/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python, pytorch

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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).

Lenguaje dominante
Python
Estrellas
340
Forks
37
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de NVIDIA/SOL-ExecBench

Todos los issues de NVIDIA/SOL-ExecBench

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.