[12/n] final _C library kernel migration - #45415
Conversation
| VLLM_STABLE_DISPATCH_FLOATING_TYPES( \ | ||
| input.scalar_type(), "act_and_mul_kernel", [&] { \ | ||
| VLLM_STABLE_DISPATCH_FP8_TYPES( \ | ||
| out.scalar_type(), "act_and_mul_quant_kernel_fp8_type", [&] { \ |
There was a problem hiding this comment.
Note, this kernel string was renamed to indicate what kernel was actually being called.
There was a problem hiding this comment.
how did this work before?
| void* data_ptr = const_cast<void*>(tensor.mutable_data_ptr()); | ||
|
|
||
| // Create a new tensor from the raw data pointer | ||
| return torch::stable::from_blob(data_ptr, tensor.sizes(), tensor.strides(), |
There was a problem hiding this comment.
Can pass tensor.sizes() and tensor.strides() straight into stable::from_blob without having to convert them to std::vectors first
| // Create a new tensor from the raw data pointer | ||
| return torch::stable::from_blob(data_ptr, tensor.sizes(), tensor.strides(), | ||
| tensor.device(), tensor.scalar_type(), | ||
| [base = tensor](void*) {}); |
There was a problem hiding this comment.
Note, this only works because we are on torch >= 2.11, this would not build on torch 2.10
| // See the following document for more info on custom types and ops that use | ||
| // custom types: | ||
| // https://docs.google.com/document/d/18fBMPuOJ0fY5ZQ6YyrHUppw9FA332CpNtgB6SOIgyuA | ||
|
|
There was a problem hiding this comment.
This comment should have been moved over during the marlin/machete migrations
| // kernels from being torch.compile'd. | ||
| // See the following document for more info on custom types and ops that use | ||
| // custom types: | ||
| // https://docs.google.com/document/d/18fBMPuOJ0fY5ZQ6YyrHUppw9FA332CpNtgB6SOIgyuA |
|
|
||
| # | ||
| # _C extension | ||
| # Legacy _C extension (ROCm only — CUDA ops migrated to _C_stable_libtorch) |
There was a problem hiding this comment.
updated comment to encourage others to use _C_stable_libtorch for cuda kernels,
|
@Harry-Chen, reminder to add the |
|
Please fix the pre-commit format error, thanks! |
|
This pull request has merge conflicts that must be resolved before it can be |
|
I think my PR #45277 has created some conflicts -- sorry for that, could you rebase / merge again? |
765e48f to
3469b5c
Compare
Done! |
|
Seems qutlass is expecting a |
Fixed. Also, there was an issue with the ROCm build since the new stable |
|
This pull request has merge conflicts that must be resolved before it can be |
Sorry I do not have much idea either :-(. BTW we just have #44681 merged, which removed some MoE kernels and caused some conflicts. I'm just thinking -- if you are intereseted -- you can also invetigate if there are more unused kernels during migration, so that we could just remove it instead of putting extra work into it. |
@Harry-Chen, Yes, I can definitely look into that while I am migrating over. After this PR, I am planning on doing another PR to clean up anything I missed during the migration (like moving some headers I missed over to the libtorch_stable directory) and I can check for unused kernels as well when I am doing this. |
…/quantization/activation_kernels.cu Signed-off-by: Chris Leonard <chleonar@redhat.com>
…e abi stable and removed the last cuda kernels from csrc/ops.h and csrc/torch_bindings.cpp and moved them to the libtorch_stable files Signed-off-by: Chris Leonard <chleonar@redhat.com>
… to clearly indicate where _C HIP ends in CMakeLists.txt Signed-off-by: Chris Leonard <chleonar@redhat.com>
Signed-off-by: Chris Leonard <chleonar@redhat.com>
…s no longer built with cuda. Also, the new stable version of weak_ref_tensor requires torch 2.11 but ROCm is still built with 2.10, so I added the old implementation back in csrc/ops.h which is no longer built on cuda. Signed-off-by: Chris Leonard <chleonar@redhat.com>
…elow the set_gencode_flags_for_srcs to avoid conflicting sm_100 and sm_100f flags Signed-off-by: Chris Leonard <chleonar@redhat.com>
…istration. Signed-off-by: Chris Leonard <chleonar@redhat.com>
…ensions via import_kernels. Signed-off-by: Chris Leonard <chleonar@redhat.com>
…that should of been const_data_ptr. Signed-off-by: Chris Leonard <chleonar@redhat.com>
84ee0e3 to
549bae4
Compare
…erge conflict, removing it again Signed-off-by: Chris Leonard <chleonar@redhat.com>
…eter was saving the tensor data, causing the memory buildup to cascade until we reached OOM errors. This should fix that. Also, Since from_blob was replaced with an overload that is on torch 2.10, we no longer need the ifndef ROCM flag or the legacy weak_ref_tensor method in the non-stable ops.h file. Signed-off-by: Chris Leonard <chleonar@redhat.com>
|
@Harry-Chen, I figure out the issue. The custom deleter in the I believe the three test failures are flaky test, are you able to rerun them to check? |
That's really great! I think you can also fix some existing issues (e.g. constness of parameters) that were kept as-is during the whole migration. I think @janeyx99 has pointed out a lot of them in the PR series. |
Signed-off-by: divineearthly <divineearthly@gmail.com>
Signed-off-by: Qiang Li <qiang.li2@amd.com>
Purpose
This PR continues the libtorch stable ABI migration (see #26946) for vLLM and is the final
_Clibrary kernels to move to the_C_stable_libtorchlibrary. The PR movescsrc/quantization/activation_kernels.cutocsrc/libtorch_stable/quantization/activation_kernels.cu, along with theweak_ref_tensor(defined in ops.h),silu_and_mul_quant, andpersistent_masked_m_silu_mul_quantkernels.Test Plan
pytest tests/kernels/test_fused_quant_activation.py
pytest tests/kernels/moe/test_silu_mul_fp8_quant_deep_gemm.py
pytest tests/compile/passes/test_silu_mul_quant_fusion.py
pytest tests/compile/passes/test_functionalization.py
Test Result
Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.Note, no more
C_.abi.solibrary! It has all been moved to_C_stable_libtorch.abi3.so(similarly for_moe_C).