lmflow.models.hf_model_mixin#
Attributes#
Classes#
Module Contents#
- class lmflow.models.hf_model_mixin.HFModelMixin(model_args: lmflow.args.ModelArguments, do_train: bool, device: str | None = 'gpu', hf_auto_model_additional_args: dict | None = None, *args, **kwargs)[source]#
Bases:
lmflow.models.base_model.BaseModel- activate_model_for_inference(inference_engine: Literal['huggingface', 'vllm', 'sglang'] = 'huggingface', gpu_memory_utilization: float | None = None, tensor_parallel_size: int | None = None, data_parallel_size: int = 1, max_model_len: int | None = None, enable_deterministic_inference: bool = False, attention_backend: str | None = None)[source]#
- deactivate_model_for_inference(inference_engine: Literal['huggingface', 'vllm', 'sglang'] = 'huggingface')[source]#
Deactivate the model and release the resources.
NOTE: For vllm (>=0.8), the best-effort release below works for most single-GPU, inference-only use cases. It remains unreliable when
tensor_parallel_size > 1, CUDA graphs are enabled, or the same process also holds an HF training model — in those cases useMemorySafeVLLMInferencer, which isolates inference in a subprocess. vllm still has no official in-process shutdown API (RFC vllm-project/vllm#24885);MemorySafeVLLMInferenceris kept for backward compatibility and will be migrated to vllm sleep mode in a follow-up.