diff --git a/tools/ci/hrx_f16_narrowing.py b/tools/ci/hrx_f16_narrowing.py index 4d4034a0f..466b37725 100755 --- a/tools/ci/hrx_f16_narrowing.py +++ b/tools/ci/hrx_f16_narrowing.py @@ -41,11 +41,16 @@ """ import argparse import pathlib +import re import sys CORPUS = pathlib.Path("third_party/llama.cpp/ggml/src/ggml-hrx/kernel-corpus/kernels") BASELINE = pathlib.Path("tools/ci/hrx_f16_narrowing.txt") -NARROW = ("f32 to f16", "truncf") +# engine#2219: the marker set missed the vector form. `fptrunc` does not contain "truncf" (it ends in +# "trunc"), and the vector spelling is `vector<4xf32> to vector<4xf16>`, which does not contain the scalar +# phrase "f32 to f16" either -- so 132 of the 233 narrowing lines in the corpus were invisible and the +# baseline listed 25 of the 52 narrowing bodies. The pattern is the TYPE PAIR, so it matches both spellings. +NARROW = (re.compile(r"f32 to f16"), re.compile(r"f32>\s+to\s+vector<\d+xf16>")) GUARD = ("scale_log2", "prescale") @@ -59,7 +64,7 @@ def narrowing_bodies(corpus): found = set() for path in corpus.rglob("*.loom"): body = path.read_text(encoding="utf-8", errors="replace") - if any(marker in body for marker in NARROW): + if any(marker.search(body) for marker in NARROW): found.add(path.relative_to(corpus).as_posix()) return found @@ -136,6 +141,16 @@ def check_that(ok, what): (root / BASELINE).write_text("# comment\n# another\na.loom\n") check_that(not drift(baseline_paths((root / BASELINE).read_text()), narrowing_bodies(corpus))[0], "an unchanged corpus has no drift") + # engine#2219: the vector spelling carries neither old marker -- `fptrunc` ends in "trunc", not + # "truncf", and `vector<4xf32> to vector<4xf16>` is not the scalar phrase "f32 to f16" -- so 132 + # narrowing lines were invisible. It narrows, so it is listed and it drifts like any other body. + (corpus / "v.loom").write_text( + " %h = vector.fptrunc %v : vector<4xf32> to vector<4xf16>\n") + check_that("v.loom" in narrowing_bodies(corpus), + "the vector form `vector to vector` is a narrowing body") + new, stale = drift(baseline_paths((root / BASELINE).read_text()), narrowing_bodies(corpus)) + check_that(new == ["v.loom"] and not stale, "the vector body drifts like any other body") + (corpus / "v.loom").unlink() (corpus / "c.loom").write_text(" %z = scalar.fptrunc %w : f32 to f16\n") new, stale = drift(baseline_paths((root / BASELINE).read_text()), narrowing_bodies(corpus)) check_that(new == ["c.loom"] and not stale, "a new narrowing body is drift, and only it") diff --git a/tools/ci/hrx_f16_narrowing.txt b/tools/ci/hrx_f16_narrowing.txt index b7e67e613..d52512a5c 100644 --- a/tools/ci/hrx_f16_narrowing.txt +++ b/tools/ci/hrx_f16_narrowing.txt @@ -21,21 +21,46 @@ # perfectly correct. What the list buys is that a NEW narrowing body cannot appear without someone # writing it down and saying what feeds it -- and that is the open question on engine#1962: which of # these are protected by a producer-side prescale cannot be answered by reading them. +loom-libs/motifs/bf16_f16.loom +loom-libs/motifs/dequant.loom +loom-libs/motifs/dequant_1bit.loom +loom-libs/motifs/dequant_prism.loom +loom-libs/motifs/f32_f16.loom +loom-libs/motifs/llm_attention_qkv_matmul_postops.loom +loom-libs/motifs/mul_mat_f32_f32_wmma_core.loom loom-libs/motifs/mul_mat_id_f16_f16_wmma_core.loom +loom-libs/motifs/mul_mat_id_f32_f32_wmma_core.loom loom-libs/motifs/mul_mat_id_q4k_f16_wmma_projection.loom loom-libs/motifs/mul_mat_id_q5k_f16_wmma_projection.loom +loom-libs/motifs/mul_mat_id_q6k_f16_wmma_projection.loom +loom-libs/motifs/mul_mat_id_swiglu_f16_f16_accumulate.loom +loom-libs/motifs/mul_mat_id_swiglu_f16_f16_wmma_body.loom +loom-libs/motifs/mul_mat_quantized_f16_prefill.loom +loom-libs/motifs/publish_f32.loom loom-libs/motifs/q4_k_f16.loom +loom-libs/motifs/q6_k_f16.loom +loom-libs/motifs/q8_0_f16.loom +loom-libs/motifs/q8_1_f16.loom loom-libs/motifs/quantize_q8_1_x4.loom -loom-libs/motifs/unary_f32_apply.loom +loom-libs/ops/copy_f32.loom loom-libs/ops/flash_attention_decode_split_f32_f16_wmma.loom loom-libs/ops/flash_attention_f32_f16_wmma.loom loom-libs/ops/gated_delta_net_f32_wmma.loom +loom-libs/ops/llm_attention_k_matmul_rope_set_rows_decode_f32_f32.loom loom-libs/ops/llm_attention_v_matmul_set_rows_decode_f32_f32.loom +loom-libs/ops/mul_mat_id_swiglu_f32_f32_wmma.loom +loom-libs/ops/mul_mat_q6_k_packed_f16_wmma.loom +loom-libs/ops/mul_mat_swiglu_f32_f32_wmma.loom loom-libs/ops/mul_mat_swiglu_symmetric_i4_wmma.loom +loom-libs/ops/mul_mat_symmetric_i4_wmma.loom loom-libs/ops/mul_mat_symmetric_i8_wmma.loom +loom-libs/ops/rmsnorm_binary_f32.loom +loom-libs/ops/rope_set_rows_f32.loom loom-libs/ops/set_rows.loom loom-libs/ops/small_rows_f32.loom +qwen_moe/ggml/linear_q6k_q8_1_x4.loom qwen_moe/ggml/quantize_q8_1_x4.loom +qwen_moe/qwen3_moe/attention_postprocess_f32_f16.loom qwen_moe/qwen3_moe/attention_prepare_quantized.loom qwen_moe/qwen3_moe/dense_linear_quantized_f16_wmma.loom qwen_moe/qwen3_moe/flash_attention_decode_f32_f16_wmma.loom @@ -43,6 +68,7 @@ qwen_moe/qwen3_moe/flash_attention_decode_q128_f32_f16_wmma.loom qwen_moe/qwen3_moe/flash_attention_decode_split_f32_f16_wmma.loom qwen_moe/qwen3_moe/flash_attention_decode_split_next_q8_test.loom qwen_moe/qwen3_moe/flash_attention_f32_f16_wmma.loom +qwen_moe/qwen3_moe/routed_down_quantized_f16_wmma.loom qwen_moe/qwen3_moe/routed_down_weighted_reduce_next_rmsnorm_q8_1_x4.loom qwen_moe/qwen3_moe/routed_gate_up_swiglu_q4k.loom qwen_moe/qwen3_moe/routed_linear_q4k_f16_wmma.loom