|
Download rules/BRIEF3.md from Elfsong/KernelBench-M: direct link, hf CLI and curl.
- Browser
- Download file 4.03 kB
-
https://huggingface.co/datasets/Elfsong/KernelBench-M/resolve/main/rules/BRIEF3.md
- Command line
-
hf download hf://datasets/Elfsong/KernelBench-M/rules/BRIEF3.md
-
curl -L -o BRIEF3.md https://huggingface.co/datasets/Elfsong/KernelBench-M/resolve/main/rules/BRIEF3.md
4.03 kB
| # Brief 3: fine-grained mutation rules ONLY | |
| ## The single objective | |
| Write rules whose mutants SURVIVE the benchmark's original inputs. Nothing | |
| else matters. A rule whose mutants die on the first input is worthless — we | |
| already have too many of those and they are being retired. | |
| The original inputs are, for essentially every task: | |
| torch.rand(...) # uniform [0,1), all POSITIVE, small magnitude | |
| aligned shapes # every dim divisible by 32 or 256 | |
| compared with allclose(atol=1e-2, rtol=1e-2) # 1% slack | |
| So a mutant survives if and only if its behavioural difference is INVISIBLE | |
| under that specific regime. Measured value rates from our pool prove the point: | |
| SURVIVES (keep writing rules like these) | |
| ceil2floor 100% remainder block never exists when aligned | |
| const0to1 62% changed constant is masked by tolerance | |
| sync2syncwarp 40% race is benign when all values are similar | |
| loop-bound-minus1 39% one missing term of thousands < 1% | |
| store-fp16 24% 1e-3 relative error < 1e-2 tolerance | |
| DIES INSTANTLY (do NOT write more of these) | |
| plus2minus 3% every output element changes | |
| mul2div/mul2plus 12% same | |
| fmax2fmin 0% same | |
| guard-drop-ternary 0% crashes or changes everything | |
| ## The four survival mechanisms — target these deliberately | |
| 1. TOLERANCE ABSORPTION. The fault's error is real but under 1% of the output | |
| magnitude. Examples: one term of a long reduction dropped or double | |
| counted; a constant off in the 4th significant digit; an intermediate | |
| rounded to fewer bits; a slightly different but nearly-equal formula | |
| (expf(a)*expf(b) instead of expf(a+b), fma vs mul+add, x*0.5f vs x/2.0f | |
| with a perturbation). | |
| 2. INPUT-DOMAIN EVASION. The faulty path is never taken because the input is | |
| positive, small and finite. Examples: a branch that only differs for | |
| negative / >1 / very large / NaN / exactly-equal values; a clamp whose | |
| bound is never reached; a sign-dependent shortcut; a sentinel that only | |
| matters when all values share a sign. | |
| 3. SHAPE-ALIGNMENT EVASION. The faulty code path only executes on a partial | |
| block / remainder loop / edge tile, which does not exist when every | |
| dimension is a multiple of the block size. Examples: remainder handling, | |
| the last tile of a K-loop, an edge guard on the final row. | |
| 4. BENIGN RACE. Removing or weakening synchronization only corrupts results | |
| when the racing values differ substantially; under uniform [0,1) the stale | |
| and fresh values are nearly equal. Examples: partial barrier, barrier moved | |
| one statement, reading a shared slot one iteration early, using a | |
| thread-local value where a reduced value is intended. | |
| ## Constraints | |
| - Deterministic regex rewrite, single site per mutant, must COMPILE. | |
| - Must not be a duplicate of any rule in ../mutator.py, rules/mined_rules.py, | |
| or rules/structural_rules.py (read all three). | |
| - Patterns must fire on the corpus: read at least 6 files from | |
| substrates/accepted/ plus problems_batch2.py before writing anything. | |
| A rule that never matches is worthless — prefer patterns built from syntax | |
| you have actually SEEN in those files. | |
| - No rule that changes every output element. Before adding a rule, ask: | |
| "under torch.rand input with aligned shapes, would the output differ by | |
| more than 1%?" If yes, discard it. | |
| ## Deliverable | |
| rules/fine_rules.py: | |
| ```python | |
| from mutator import Rule | |
| FINE_RULES = [ | |
| Rule("name", "category", r"pattern", r"replacement", | |
| "why it survives the original inputs, and what input would kill it"), | |
| ... | |
| ] | |
| ``` | |
| 30+ rules, categories: boundary | sync | precision | indexing | semantic. | |
| Each note MUST state the survival mechanism (1-4 above) and the killer input. | |
| Verify: every regex compiles, the module imports, and report how many of your | |
| rules actually fire across the corpus (write a small throwaway check, do not | |
| add it to the repo). | |