Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions tensorrt_llm/_torch/custom_ops/torch_custom_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@
# BufferKind is bound from C++; see cpp/tensorrt_llm/thop/outputTensor.h (torch_ext::BufferKind).
from tensorrt_llm.bindings.internal.thop import BufferKind

deep_gemm.set_pdl(get_env_enable_pdl())


# Used to WAR an issue in torch.bmm that it would break the graph when the out is not contiguous.
@torch.library.custom_op("trtllm::bmm_out", mutates_args=("out", ))
Expand Down
16 changes: 16 additions & 0 deletions tensorrt_llm/_torch/pyexecutor/model_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,20 @@ def _filter_cuda_graph_batch_sizes(cuda_graph_batch_sizes: list[int],
return result


_DEEP_GEMM_PDL_CONFIGURED = False


def _configure_deep_gemm_pdl() -> None:
global _DEEP_GEMM_PDL_CONFIGURED
if _DEEP_GEMM_PDL_CONFIGURED:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if the check is really useful since that function is called from __init__, so it should only be called once. If it was called from multiple places, we should have proper locking anyway.

return

from tensorrt_llm import deep_gemm

deep_gemm.set_pdl(os.environ.get("TRTLLM_ENABLE_PDL", "1") == "1")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could re-use get_env_enable_pdl from flashinfer_utils.py here.

_DEEP_GEMM_PDL_CONFIGURED = True


class PyTorchModelEngine(ModelEngine):

def __init__(
Expand All @@ -192,6 +206,8 @@ def __init__(
model_weights_memory_tag: Optional[str] = None,
model_weights_restore_mode=None,
):
_configure_deep_gemm_pdl()

self.forward_pass_callable = None
self.ub_buffers = None
(
Expand Down
Loading