Repository navigation
[HIP] [Bugfix] Fix topk_sigmoid pybind conversion - #6592
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
|
@valarLip any chance you could take a look at this? |
|
@vgokhale could you review this when you have time? |
…ion.h moe_topk_ck_pybind.cu declares topk_sigmoid with torch::Tensor parameters for its PYBIND11_MODULE binding, but included torch/all.h, which provides the core ATen/torch C++ API without pybind11's tensor type caster. Without that caster, pybind11 cannot convert a Python torch.Tensor argument into the C++ torch::Tensor parameter, so calling topk_sigmoid from Python fails at the binding layer. torch/extension.h pulls in the same pybind11 tensor conversion support, fixing the binding. Add test_topk_sigmoid_binding_loads to op_tests/test_topk_softmax.py, which calls topk_sigmoid directly to catch this regression. Signed-off-by: Ryan Rock <[email protected]>
Signed-off-by: Ryan Rock <[email protected]>
093f0b2 to
0d5fb3e
Compare
|
@rjrock Could you remove the newly added For sigmoid routing, I recommend migrating callers to the HIP aiter.topk_gating(
topk_weights,
topk_indices,
gating_output,
correction_bias=None,
score_func="sigmoid",
need_renorm=False,
)This HIP path is already covered by
The binding fix remains useful for existing CK callers, while migrating to the HIP implementation would also provide the performance benefit. |
Hi @junhaha666, I squash-merged including the new test. There were no Thanks for the pointer on |
|
@valarLip @junhaha666 please reconcile @vgokhale approving with your decision to revert. Why do you think a test is unnecessary |
Motivation
The sigmoid fused_topk tests in vllm fail with
VLLM_ROCM_USE_AITER=1set.Technical Details
moe_topk_ck_pybind.cudeclarestopk_sigmoidwithtorch::Tensorparameters in itsPYBIND11_MODULEbinding, but includestorch/all.h, which provides the core ATen/torch C++ API without pybind11’s tensor type caster.Without that caster, pybind11 cannot convert a Python
torch.Tensorargument totorch::Tensor, so calls totopk_sigmoidfail at the binding layer. Includingtorch/extension.hprovides the required conversion support.Test Plan
Added
test_topk_sigmoid_binding_loadstoop_tests/test_topk_softmax.py, which callstopk_sigmoiddirectly to catch this regression.Test Result
PASSEDSubmission Checklist