Skip to content

kernels.cu is about 40% dead code and ffi.rs no longer mirrors it #25

Description

@CanReader

The module doc on src/cuda/ffi.rs says it holds "every raw declaration of a
symbol in cuda/kernels.cu, in one place", and that adding a kernel means adding
its signature there and a wrapper in kernels.rs. That's broken in both
directions now.

kernels.cu exports 82 symbols, ffi.rs declares 55. Exported and unreachable:

fastnn_cuda_conv2d_forward / _backward_data / _backward_weight
fastnn_cuda_max_pool2d / _backward, _avg_pool2d, _adaptive_avg_pool2d
fastnn_cuda_batch_norm_forward / _backward
fastnn_cuda_rms_norm_forward
fastnn_cuda_dropout_forward / _backward
fastnn_cuda_cross_entropy_loss, _mse_loss, _binary_cross_entropy
fastnn_cuda_scaled_dot_product_attention
fastnn_cuda_sgd_step, _adam_step
fastnn_cuda_copy, _arange, _where, _gather
fastnn_cuda_leaky_relu_backward

None of them are covered by cuda_parity. One is known broken
(fastnn_cuda_argmax, #9), and fastnn_cuda_conv2d_forward does a D2H
cudaMemcpy per output channel per batch item just to read one bias scalar
(kernels.cu:951). There are also two overloads each of kernel_im2col and
kernel_col2im, and the older pair silently ignores dilation.

A few of these are worth wiring up rather than deleting.
fastnn_cuda_leaky_relu_backward works fine but LeakyReluBackward
(src/autograd/ops/activation.rs:111) still takes the host round trip because the
symbol isn't in ffi.rs. Same for the pooling kernels (#23) and dropout (#20).

Delete what isn't reachable, wire up what should be, and add a CI check that the
two symbol sets match.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions