Skip to content

Expose gdn::causal_conv1d and gdn::gated_delta_rule as standalone torch ops with unit tests#202

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/expose-register-causal-conv1d-gated-delta-rule
Draft

Expose gdn::causal_conv1d and gdn::gated_delta_rule as standalone torch ops with unit tests#202
Copilot wants to merge 4 commits intomainfrom
copilot/expose-register-causal-conv1d-gated-delta-rule

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 19, 2026

gdn::causal_conv1d and gdn::gated_delta_rule were only accessible as internal implementation details of gdn_attention, with no way to call them independently from Python.

Changes

C++ – new wrapper functions (gdn_attn_interface.cpp, ops.h, torch_bindings.cpp)

  • Added causal_conv1d and gated_delta_rule C++ wrapper functions that forward directly to gdn::causal_conv1d / gdn::gated_delta_rule
  • Registered both ops under torch.ops._xpu_C via TORCH_LIBRARY_EXPAND, following the same pattern as gdn_attention

Python – unit tests (tests/gdn_attn/)

  • test_causal_conv1d.py: reference impl (ref_causal_conv1d) + parametrised test covering prefill/decode/mix modes, bias/no-bias, reorder_input=True/False; validates all six output tensors (q, k, v, z, b, a) and updated conv_states
  • test_gated_delta_rule.py: reference impl (ref_gated_delta_rule) + parametrised test covering all modes; validates core_attn_out and updated ssm_state

Usage

import vllm_xpu_kernels._xpu_C  # noqa: F401

# causal_conv1d – splits and convolves mixed_qkvz, fills q/k/v/z/b/a
torch.ops._xpu_C.causal_conv1d(
    q_out, k_out, v_out, z_out, b_out, a_out,
    mixed_qkvz, mixed_ba, conv_weights, conv_bias, conv_states,
    query_start_loc, cache_indices, has_initial_state,
    activation, num_prefills, num_decodes, reorder_input)

# gated_delta_rule – runs the per-token gated delta-rule state update
torch.ops._xpu_C.gated_delta_rule(
    core_attn_out, q, k, v, b, a, A_log, dt_bias, ssm_state,
    query_start_loc, cache_indices, has_initial_state,
    num_prefills, num_decodes)

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] [VLLM-189] Expose and register gdn::causal_conv1d and gdn::gated_delta_rule Expose gdn::causal_conv1d and gdn::gated_delta_rule as torch XPU ops Mar 19, 2026
Copilot AI requested a review from jikunshang March 19, 2026 04:33
Copilot AI changed the title Expose gdn::causal_conv1d and gdn::gated_delta_rule as torch XPU ops Expose gdn::causal_conv1d and gdn::gated_delta_rule as standalone torch ops with unit tests Mar 19, 2026
Copilot AI and others added 4 commits March 20, 2026 17:03
…orch ops

Co-authored-by: jikunshang <50897707+jikunshang@users.noreply.github.com>
Co-authored-by: jikunshang <50897707+jikunshang@users.noreply.github.com>
Signed-off-by: Kunshang Ji <kunshang.ji@intel.com>
@jikunshang jikunshang force-pushed the copilot/expose-register-causal-conv1d-gated-delta-rule branch from 3d8f049 to a810897 Compare March 20, 2026 09:04
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.

2 participants