Small cleanup. (#1560)
Using a single `os.getenv` statement instead of multiple. Should make truthful values easier to catch In the end didn't move towards full CLI because modifying globals in Python is error prone (depends on code import order). Added an error when mamba is launched with TP. # What does this PR do? <!-- Congratulations! You've made it this far! You're not quite done yet though. Once merged, your PR is going to appear in the release notes with the title you set, so make sure it's a great title that fully reflects the extent of your awesome contribution. Then, please replace this with a description of the change and which issue is fixed (if applicable). Please also include relevant motivation and context. List any dependencies (if any) that are required for this change. Once you're done, someone will review your PR shortly (see the section "Who can review?" below to tag some potential reviewers). They may suggest changes to make the code even better. If no one reviewed your PR after a week has passed, don't hesitate to post a new comment @-mentioning the same persons---sometimes notifications get lost. --> <!-- Remove if not applicable --> Fixes # (issue) ## Before submitting - [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case). - [ ] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests), Pull Request section? - [ ] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link to it if that's the case. - [ ] Did you make sure to update the documentation with your changes? Here are the [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation). - [ ] Did you write any new necessary tests? ## Who can review? Anyone in the community is free to review the PR once the tests have passed. Feel free to tag members/contributors who may be interested in your PR. <!-- Your PR will be replied to more quickly if you can figure out the right person to tag with @ @OlivierDehaene OR @Narsil -->
This commit is contained in:
parent
d6b0fb9e25
commit
4c2848b24b
|
@ -28,7 +28,7 @@ from text_generation_server.models.cache_manager import (
|
|||
BLOCK_SIZE,
|
||||
)
|
||||
from text_generation_server.pb import generate_pb2
|
||||
from text_generation_server.models.globals import MEM_POOL
|
||||
from text_generation_server.models.globals import MEM_POOL, ENABLE_CUDA_GRAPHS
|
||||
from text_generation_server.utils import StoppingCriteria, HeterogeneousNextTokenChooser
|
||||
from text_generation_server.utils.dist import MEMORY_FRACTION
|
||||
|
||||
|
@ -793,7 +793,7 @@ class FlashCausalLM(Model):
|
|||
self.device,
|
||||
)
|
||||
|
||||
if os.getenv("ENABLE_CUDA_GRAPHS", "False") == "True":
|
||||
if ENABLE_CUDA_GRAPHS:
|
||||
try:
|
||||
logger.info("Experimental support for Cuda Graphs is enabled")
|
||||
# Warmup cuda graphs
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
import torch
|
||||
import os
|
||||
|
||||
MEM_POOL = torch.cuda.graph_pool_handle()
|
||||
# This is overridden by the cli
|
||||
ENABLE_CUDA_GRAPHS = os.getenv("ENABLE_CUDA_GRAPHS", "false").lower() in {"1", "true"}
|
||||
|
|
|
@ -13,7 +13,7 @@ from text_generation_server.utils import (
|
|||
weight_files,
|
||||
Weights,
|
||||
)
|
||||
from text_generation_server.models.globals import MEM_POOL
|
||||
from text_generation_server.models.globals import ENABLE_CUDA_GRAPHS, MEM_POOL
|
||||
import time
|
||||
from text_generation_server.models.custom_modeling.mamba_modeling import MambaModel, InferenceParams
|
||||
from text_generation_server.models import Model
|
||||
|
@ -377,7 +377,9 @@ class Mamba(Model):
|
|||
dtype: Optional[torch.dtype] = None,
|
||||
trust_remote_code: bool = False,
|
||||
):
|
||||
self.process_group, _rank, _world_size = initialize_torch_distributed()
|
||||
self.process_group, _rank, world_size = initialize_torch_distributed()
|
||||
if world_size > 1:
|
||||
raise RuntimeError("Mamba does not support Tensor Parallelism (TP)")
|
||||
self.cuda_graphs = {}
|
||||
if torch.cuda.is_available():
|
||||
device = torch.device("cuda")
|
||||
|
@ -427,7 +429,7 @@ class Mamba(Model):
|
|||
|
||||
def warmup(self, batch) -> Optional[int]:
|
||||
# TODO: implement warmup for Mamba if needed
|
||||
if os.getenv("ENABLE_CUDA_GRAPHS", "False") == "True":
|
||||
if ENABLE_CUDA_GRAPHS:
|
||||
if self.speculate is None or self.speculate == 0:
|
||||
try:
|
||||
logger.info("Experimental support for Cuda Graphs is enabled")
|
||||
|
|
Loading…
Reference in New Issue