Repository navigation
refactor(kernels): neutral ownership for generic bf16 matmul + embedding helpers (#112) - #117
Merged
LiangSu8899 merged 7 commits intoJun 27, 2026
Conversation
…t#112) Move the model-neutral small-M bf16 matmul and the cuBLASLt BF16 GEMM out of the Qwen3.6-named translation unit into a neutral file, sharing one implementation. No kernel algorithm, dtype, or dispatch change. - Add csrc/kernels/bf16_matmul_bf16.{cu,cuh} with bf16_matmul_bf16 (former bf16_matmul_qwen36_bf16 body) and bf16_matmul_cublaslt_bf16 (already a neutral symbol name; only its file moved). - Reduce bf16_matmul_qwen36.cu to the Qwen3.6-specific AB96 kernels plus a thin bf16_matmul_qwen36_bf16 wrapper that forwards to bf16_matmul_bf16. - Bind the neutral name bf16_matmul_bf16 in flash_rt_kernels; keep the legacy binding for compatibility. - qwen3_vl_bindings.cpp now includes the neutral header for the cuBLASLt symbol. Both flash_rt_kernels and flash_rt_qwen3_vl_kernels compile the neutral file (the Qwen3-VL source-list now also has it; the redundant Qwen3.6 matmul TU is dropped from the VL module in the next commit). - Migrate non-Qwen3.6 call sites (qwen3_rtx, qwen3_vl_rtx, qwen3_vl_fp8_sm89) to the neutral name. Qwen3.6 call sites keep legacy names for auditability. - Activate the neutral-name binding assertion in the cleanup test.
…roject#112) The Qwen3-VL dedicated module only needs bf16_matmul_cublaslt_bf16, which now lives in the neutral bf16_matmul_bf16 translation unit. Remove bf16_matmul_qwen36.cu from QWEN3_VL_SOURCES so flash_rt_qwen3_vl_kernels no longer compiles the Qwen3.6-specific AB96/MTP-adjacent matmul code just to get one cuBLASLt wrapper. Isolated, independently revertible sub-step. Verified: flash_rt_qwen3_vl_kernels builds, exposes no AB96 symbols, still resolves bf16_matmul_cublaslt_bf16, and the Qwen3-VL-2B SM89 multimodal smoke matches the pre-cleanup baseline (prefill_graph cos_vs_eager=1.0, decode cos_vs_eager=1.0).
…roject#112) Move the model-neutral bf16 embedding lookup out of qwen36_misc into a neutral file, sharing one implementation. No kernel change. - Add csrc/kernels/embedding_lookup_bf16.{cu,cuh} with embedding_lookup_bf16 (former qwen36_embedding_lookup_bf16 body). - Reduce qwen36_misc.cu: the embedding kernel/body move out; the legacy qwen36_embedding_lookup_bf16 becomes a thin wrapper that forwards to embedding_lookup_bf16. Qwen3.6-specific misc helpers stay put. - Bind the neutral name embedding_lookup_bf16 in flash_rt_kernels; keep the legacy binding for compatibility. - Migrate non-Qwen3.6 call sites (qwen3_rtx, qwen3_vl_fp8_sm89, groot_n17_thor, groot_n17_thor_fp8) to the neutral name. Qwen3.6 call sites keep legacy names for auditability. - Activate the neutral-name binding assertion in the cleanup test. Verified: flash_rt_kernels builds, both bindings resolve, and a CUDA equivalence check confirms neutral == reference and legacy == neutral (bit-identical).
…t-project#112) - Higgs BF16/RTX docstrings now reference bf16_matmul_bf16 instead of the legacy bf16_matmul_qwen36_bf16 (comment-only; Higgs calls the matvec and GemmRunner, not this matmul). silu_mul_qwen36_bf16 is left as-is since it stays Qwen3.6-specific. - Migrate two Qwen3 lm_head matmul call sites in qwen3_rtx.py that the Unit 1 sweep missed (full_logits and the M=1 branch) to bf16_matmul_bf16. Behavior is unchanged (the legacy name is a thin wrapper); this only completes the non-Qwen3.6 ownership migration.
…t-project#112) The flash_rt_qwen3_vl_kernels SM89 cuBLASLt link comment still named the old bf16_matmul_qwen36 translation unit; the module now compiles bf16_matmul_bf16.cu for that cuBLASLt path. Comment-only.
LiangSu8899
approved these changes
Jun 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Ownership/name cleanup for issue #112. Several model-neutral CUDA helpers
still lived under Qwen3.6 file/symbol names while non-Qwen3.6 paths reused
them. This moves the generic helpers into neutral files and migrates the
non-Qwen3.6 call sites, keeping legacy names as thin wrappers.
Refactor-only. No kernel algorithm, dtype policy, dispatch, graph
capture, or runtime fallback change.
Changes
bf16_matmul_bf16(csrc/kernels/bf16_matmul_bf16.{cu,cuh}):the model-neutral small-M warp matmul (former
bf16_matmul_qwen36_bf16body) plus
bf16_matmul_cublaslt_bf16(already a neutral symbol; only itsfile moved).
bf16_matmul_qwen36.cukeeps the Qwen3.6-specific AB96kernels and a thin
bf16_matmul_qwen36_bf16wrapper that forwards.embedding_lookup_bf16(csrc/kernels/embedding_lookup_bf16.{cu,cuh}):the generic bf16 embedding gather (former
qwen36_embedding_lookup_bf16body).
qwen36_misc.cukeeps its Qwen3.6-specific helpers and a thinforwarding wrapper.
it only needed
bf16_matmul_cublaslt_bf16, now in the neutral file.GROOT N1.7) migrate to the neutral names. Qwen3.6 frontends keep the legacy
names for auditability. Higgs docstrings updated.
Commits (each independently buildable)
test: baseline binding-name net (legacy names)refactor: neutralbf16_matmul_bf16ownershipbuild: drop the Qwen3.6 matmul TU from the Qwen3-VL module (isolated, revertible)refactor: neutralembedding_lookup_bf16ownershipdocs: point non-Qwen3.6 refs at neutral names + 2 missed call sitesdocs: update a stale cuBLASLt link commentVerification (local, RTX 4090 / SM89)
flash_rt_kernels,flash_rt_fa2,flash_rt_qwen3_vl_kernelsbuild clean.bit-identical.
prefill_graph cos_vs_eager=1.0,decode cos_vs_eager=1.0.Closes #112.