MCPcopy Create free account
hub / github.com/AI-Hypercomputer/maxtext / decode_with_vllm

Function decode_with_vllm

src/MaxText/vllm_decode.py:90–185  ·  view source on GitHub ↗

Decode using vLLM with a MaxText model implementation. Args: model_name: Name of the model for MaxText. hf_model_name: Path to the Hugging Face model. hf_config_path: Path to the local Hugging Face model config. load_parameters_path: Path to load model parameters from. ici_dat

(
    model_name: str,
    hf_model_name: str,
    hf_config_path: str,
    load_parameters_path: str,
    ici_data_parallelism: int,
    ici_tensor_parallelism: int,
    ici_expert_parallelism: int,
    max_prefill_length: int,
    max_target_length: int,
    gpu_memory_utilization: float,
    enable_expert_parallel: bool,
    prompt: str,
    decode_sampling_temperature: float,
    decode_sampling_nucleus_p: float,
    decode_sampling_top_k: float,
)

Source from the content-addressed store, hash-verified

88
89
90def decode_with_vllm(
91 model_name: str,
92 hf_model_name: str,
93 hf_config_path: str,
94 load_parameters_path: str,
95 ici_data_parallelism: int,
96 ici_tensor_parallelism: int,
97 ici_expert_parallelism: int,
98 max_prefill_length: int,
99 max_target_length: int,
100 gpu_memory_utilization: float,
101 enable_expert_parallel: bool,
102 prompt: str,
103 decode_sampling_temperature: float,
104 decode_sampling_nucleus_p: float,
105 decode_sampling_top_k: float,
106) -> None:
107 """Decode using vLLM with a MaxText model implementation.
108
109 Args:
110 model_name: Name of the model for MaxText.
111 hf_model_name: Path to the Hugging Face model.
112 hf_config_path: Path to the local Hugging Face model config.
113 load_parameters_path: Path to load model parameters from.
114 ici_data_parallelism: Size of the data parallelism dimension.
115 ici_tensor_parallelism: Size of the non-expert tensor parallelism dimension.
116 ici_expert_parallelism: Size of the MoE expert parallelism dimension.
117 max_prefill_length: Maximum prefill length.
118 max_target_length: Maximum total context length (MCL).
119 gpu_memory_utilization: Fraction of GPU memory to be used for the model executor.
120 enable_expert_parallel: Whether to enable expert parallelism.
121 prompt: The prompt to decode.
122 decode_sampling_temperature: Temperature for sampling.
123 decode_sampling_nucleus_p: Nucleus sampling probability.
124 decode_sampling_top_k: Top-k sampling probability.
125 """
126
127 # Prepare vLLM Arguments
128 vllm_args = {}
129 vllm_args["additional_config"] = {}
130
131 # Core vLLM Arguments
132 vllm_args["model"] = hf_model_name
133 vllm_args["max_model_len"] = max_target_length
134 vllm_args["tensor_parallel_size"] = ici_tensor_parallelism
135 vllm_args["data_parallel_size"] = ici_data_parallelism
136 vllm_args["enable_expert_parallel"] = enable_expert_parallel
137 vllm_args["hf_config_path"] = hf_config_path
138 vllm_args["gpu_memory_utilization"] = gpu_memory_utilization
139
140 if load_parameters_path is None:
141 vllm_args["load_format"] = "dummy"
142
143 # Prepare MaxText and sharding configs (Parallelism is dynamic)
144 vllm_args["additional_config"]["maxtext_config"] = {
145 "model_name": model_name,
146 "max_target_length": max_target_length,
147 "weight_dtype": "bfloat16",

Callers 1

mainFunction · 0.85

Calls 3

SamplingParamsClass · 0.85
updateMethod · 0.80
generateMethod · 0.80

Tested by

no test coverage detected