Skip to content

metal: implement upsample_nearest1d kernel support#3563

Open
oglego wants to merge 1 commit into
huggingface:mainfrom
oglego:feature/upsample-nearest1d-metal
Open

metal: implement upsample_nearest1d kernel support#3563
oglego wants to merge 1 commit into
huggingface:mainfrom
oglego:feature/upsample-nearest1d-metal

Conversation

@oglego

@oglego oglego commented May 24, 2026

Copy link
Copy Markdown

Summary

I noticed that upsample_nearest1d was dropping an unimplemented fallback error for the Metal backend package:

fn upsample_nearest1d(&self, _: &Layout, _: usize) -> Result<Self> {
    crate::bail!("Metal upsample_nearest1d not implemented")
}

This PR introduces metal support for upsample_nearest1d. To develop this I followed the structure of the implementation of upsample_nearest2d.

Changes

  • MSL Kernel Implementation: Added the upsample_nearest1d shader code and macro variants inside candle-metal-kernels/src/metal_src/conv.metal.
  • Kernel Registry: Registered the new shader symbols inside candle-metal-kernels/src/kernels/convolution.rs so the library can load the kernel.
  • Backend Dispatch: Updated candle-core/src/metal_backend/mod.rs to route the 1D upsample operation from the frontend down to the new Metal kernel using the existing set_params! framework.
  • Testing: Expanded the test suite inside candle-core/tests/pool_tests.rs by adding a test for upsample_nearest1d.

Test plan

Verified locally on Apple Silicon:

  • Formatting & Quality: Workspace runs completely clean through cargo fmt --all and cargo clippy.
  • Testing: Tests pass when running the below:
cargo test -p candle-core --test pool_tests --features metal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant