Repository navigation
fix(metal): reject every malformed GEMM shape component - #1109
Conversation
There was a problem hiding this comment.
Verdict: CLEAN: Malformed shape components now produce the named error before device setup.
Checked
Duplicates: 1 new function checked; no duplicate owner. Dryer reported 0 pairs.
Complexity: crapper flagged no functions; the parser retains its existing match.
Silent failure: 1 changed error path followed; invalid components and wrong component counts return an error through main.
Tests: mac.rs:475 is protected by the malformed-input assertions. Restoring the old token-dropping parser makes them fail. The valid-input assertion also rejects narrowing from usize.
Gates: no pins or cases moved or disappeared; lab-metal now runs the binary's tests.
Escape catalog: no patterns matched.
Notes
The macOS-only regression test was not run here. The PR body includes FAIL-first and passing macOS output.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
Filed outside this PR: #1110
|
The review is done and the contribution check passed, so I'm merging this. |
Metal GEMM probe의
--shape가 잘못된 조각이 섞인 값을 정상 입력으로 받던 오류를 고쳤습니다.What and why
Fixes #1108.
metal_gemm_time --shapeparsed each:separated piece withfilter_map(parse().ok()), so a bad piece was dropped silently.1:bad:2:3came out as three valid numbers and ran, and the device path then hit a divide by zero. The parser now collects every piece as aResultand accepts a shape only when all three pieces parse asusize. A failure returns the existing--shape takes N:K:R, not <value>error before the device opens.runtakes its arguments as a parameter so a unit test can call it, and thelab-metalrecipe now runs that test.Release notes: Fixed:
metal_gemm_timerejects a--shapevalue with a malformed component instead of dropping it.Code shape
--shapeparser incrates/metal/src/bin/metal_gemm_time/mac.rsis the only N:K:R parser; I changed it in place.--shapeerror.cargo fmtandcargo clippyare clean on what I touched; the lint count did not go up.Duplication found or removed (
path:line), or "none": none.What I ran
Base
2227bd5077e0d2157fc7c43c66003d70dc4e4a5b(upstream/main), heada7e7ac2e2861f725aae6a43866910a55e9b17636.Before the fix, with only the regression test added, on an Apple M4 Pro:
After the fix, on macOS:
The test feeds eleven malformed values (bad characters, empty pieces, too few or too many pieces, a negative number, a space, a
usizeoverflow) after a valid--shape, and expects the named error for each. It also checks that repeated valid shapes, one of themusize::MAX:2:3, reach the--dump-sourceearly exit.The binary itself:
The clippy ratchet over the workspace (
cargo clippy --workspace --all-targets) reportslint rc 0 (^warning: 0, the ratchet 0 in tools/lint-ratchet.txt).Hardware (if the change is for a machine)
The change touches only the host side argument parsing of a Metal development probe, which opens no device for a rejected shape. The failing run was on an Apple M4 Pro (
applegpu_g16s, macOS); the passing runs were on an Apple Silicon Mac running macOS.AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.