Repository navigation
flint/metal_native: add convTranspose1d, snake, pad1d and clamp kernels - #129
Conversation
Metal ran these four as compositions in flint/functional.cc, which had never been run on Metal. They now have kernels of their own, ported from the Vulkan shaders, in kernels/signal.metal and signal.cc; stft and istft pick them up through the operators they are composed of. Also fixes waifu-tools, which #127 broke by changing w2v_bert::graph's signature without updating parameters.rs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ling0322
left a comment
There was a problem hiding this comment.
Reviewed d440c31. No actionable correctness findings. Checked the Metal shader/host parameter layouts and buffer bindings, grouped transposed-convolution offsets and optional bias, snake's optional beta, padding indices, clamp NaN handling, and the parameters tool signature update.
Local validation: Metal-enabled unittest build succeeded, including compilation/linking of signal.metal; the unit suite reported 93 passed, 26 skipped, and 11,688 assertions passed. Metal device execution was unavailable in this sandbox, so the GPU cases were skipped and their numerical behavior was not independently verified here. cargo check -p waifu-tools --bin parameters and git diff --check also passed. Model tests were not run.
Adds Metal kernels for
convTranspose1d,snake,pad1dandclamp(kernels/signal.metal,signal.cc), ported from the Vulkan shaders, so Metal no longer falls back to theF::composed*versions from #127.stftandistftuse them through the operators they are composed of.Why
#127 left Metal on the compositions, and they had never been run on Metal.
Details
convTranspose1d: a matmul per group into columns, then anoverlap_add1dgather kernel, as on Vulkan.snake: one pass. Metal'ssinis precise when built without fast math, so the angle isn't reduced first as in the Vulkan shader.clamp: keeps a NaN as NaN, liketorch.clamp.pad1d: float32 and float16; other types still use the composition.functional.ccfor any backend without kernels. Comments and docs that said Metal composes these are updated.waifu-tools/src/bin/parameters.rs, which flint: add conv_transpose1d, snake, pad1d, clamp, stft and istft operators; remove waifu::audio's compositions #127 broke by changingw2v_bert::graph's signature.Tests
test Metal signal operators: each op against the CPU in float and half, NaN and infinity through clamp, snake at large angles, and an stft/istft round trip../build/unittest(116 passed, 3 skipped),cargo testforwaifu,waifu-modelmanagerandwaifu-cli, andcargo build -p waifu-toolsall pass on an M-series Mac.indextts,indextts_gpt,cosyvoice3) not run.🤖 Generated with Claude Code