-
Notifications
You must be signed in to change notification settings - Fork 473
refactor: Improved metainfo for trtllm-gen kernels #1328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c5a6ca1
rebase
cyx-6 2f8d2e6
upd
cyx-6 11c7bf9
upd
cyx-6 d4138f5
fix
cyx-6 1219360
Merge commit '7c4541228d1255311f472d882182b841ef8fd4f2' into gemm-metβ¦
cyx-6 c3945bf
add documentation
cyx-6 d3356ac
Update flashinfer/gemm.py
cyx-6 7aafe0d
upd
cyx-6 927a110
upd hash
cyx-6 349133f
Merge commit '30319e7680fa2640c54b28c0691f596df6e5cc54' into gemm-metβ¦
cyx-6 a368bb2
use `FLASHINFER_CUBIN_DIR`
cyx-6 cf3e0e0
fix
cyx-6 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,13 +16,12 @@ | |
|
||
import functools | ||
from enum import IntEnum | ||
from pathlib import Path | ||
from types import SimpleNamespace | ||
from typing import Any, Dict, List, Optional, Tuple, Union | ||
|
||
import torch | ||
|
||
from ..artifacts import ArtifactPath | ||
from ..artifacts import ArtifactPath, MetaInfoHash | ||
from ..autotuner import ( | ||
AutoTuner, | ||
DynamicTensorSpec, | ||
|
@@ -33,6 +32,7 @@ | |
from ..jit import JitSpec | ||
from ..jit import env as jit_env | ||
from ..jit import gen_jit_spec, setup_cubin_loader, sm100a_nvcc_flags | ||
from ..jit.cubin_loader import get_cubin | ||
from ..jit.cutlass_gemm.generate_kernels import generate_gemm_operations | ||
from ..utils import ( | ||
_check_shape_dtype_device, | ||
|
@@ -808,15 +808,18 @@ def cutlass_fused_moe( | |
|
||
|
||
def trtllm_gen_fused_moe_sm100_module() -> JitSpec: | ||
debug_cubin_path = ( | ||
jit_env.FLASHINFER_INCLUDE_DIR | ||
/ "flashinfer/trtllm/batched_gemm/trtllmGen_bmm_export/cubins" | ||
# Fetch "flashinferMetaInfo.h" from the online kernel cache. This file | ||
# contains the `tllmGenBatchedGemmList` as the list of available kernels | ||
# online. It is included when compiling `trtllm_fused_moe_runner.cu`, etc. | ||
include_path = f"{ArtifactPath.TRTLLM_GEN_BMM}/include" | ||
header_name = "flashinferMetaInfo" | ||
|
||
# use `get_cubin` to get "flashinferMetaInfo.h" | ||
metainfo = get_cubin( | ||
f"{include_path}/{header_name}", MetaInfoHash.TRTLLM_GEN_BMM, ".h" | ||
) | ||
import glob | ||
|
||
debug_cubin_files = [ | ||
Path(p) for p in glob.glob(str(debug_cubin_path / "Bmm_*.cpp")) | ||
] | ||
# make sure "flashinferMetaInfo.h" is downloaded or cached | ||
assert metainfo, f"{header_name}.h not found" | ||
|
||
return gen_jit_spec( | ||
"fused_moe_sm100", | ||
|
@@ -833,8 +836,7 @@ def trtllm_gen_fused_moe_sm100_module() -> JitSpec: | |
jit_env.FLASHINFER_CSRC_DIR / "trtllm_fused_moe_routing_renormalize.cu", | ||
jit_env.FLASHINFER_CSRC_DIR / "trtllm_fused_moe_dev_kernel.cu", | ||
jit_env.FLASHINFER_CSRC_DIR / "trtllm_batched_gemm_runner.cu", | ||
] | ||
+ debug_cubin_files, | ||
], | ||
extra_cuda_cflags=[ | ||
"-DTLLM_GEN_EXPORT_INTERFACE", | ||
"-DTLLM_ENABLE_CUDA", | ||
|
@@ -846,6 +848,8 @@ def trtllm_gen_fused_moe_sm100_module() -> JitSpec: | |
+ sm100a_nvcc_flags, | ||
extra_ldflags=["-lcuda"], | ||
extra_include_paths=[ | ||
# link "include" sub-directory in cache | ||
jit_env.FLASHINFER_CACHE_DIR / "cubins" / include_path, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might be conflicting with #1462, considering using "FLASHINFER_CUBIN_DIR" instead |
||
jit_env.FLASHINFER_CSRC_DIR / "nv_internal", | ||
jit_env.FLASHINFER_CSRC_DIR / "nv_internal/include", | ||
], | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -349,12 +349,19 @@ def get_gemm_sm100_module(): | |
|
||
|
||
def trtllm_gemm_gen_module() -> JitSpec: | ||
header_name = "KernelMetaInfo" | ||
# Fetch "flashinferMetaInfo.h" from the online kernel cache. This file | ||
# contains the `tllmGenGemmList` as the list of available kernels online. | ||
# It is included when compiling `trtllm_gemm_runner.cu`. | ||
include_path = f"{ArtifactPath.TRTLLM_GEN_GEMM}/include" | ||
header_name = "flashinferMetaInfo" | ||
|
||
# use `get_cubin` to get "flashinferMetaInfo.h" | ||
metainfo = get_cubin( | ||
f"{ArtifactPath.TRTLLM_GEN_GEMM}/{header_name}", | ||
f"{include_path}/{header_name}", | ||
MetaInfoHash.TRTLLM_GEN_GEMM, | ||
".h", | ||
) | ||
# make sure "flashinferMetaInfo.h" is downloaded or cached | ||
assert metainfo, f"{header_name}.h not found" | ||
return gen_jit_spec( | ||
"trtllm_gemm", | ||
|
@@ -367,11 +374,8 @@ def trtllm_gemm_gen_module() -> JitSpec: | |
f'-DTLLM_GEN_GEMM_CUBIN_PATH=\\"{ArtifactPath.TRTLLM_GEN_GEMM}\\"', | ||
] | ||
+ sm100a_nvcc_flags, | ||
extra_include_paths=[ | ||
jit_env.FLASHINFER_CACHE_DIR / "cubins" / ArtifactPath.TRTLLM_GEN_GEMM, | ||
jit_env.FLASHINFER_INCLUDE_DIR | ||
/ "flashinfer/trtllm/gemm/trtllmGen_gemm_export", | ||
], | ||
# link "include" sub-directory in cache | ||
extra_include_paths=[jit_env.FLASHINFER_CACHE_DIR / "cubins" / include_path], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
extra_ldflags=["-lcuda"], | ||
) | ||
|
||
|
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.