@@ -135,6 +135,38 @@ def test_initialization_with_peft_model(self, mock_model, mock_tokenizer, mock_p
135135 )
136136 assert deployer .model == mock_peft_model .from_pretrained .return_value
137137
138+ def test_initialization_omits_tp_plan_when_none (self , mock_model , mock_tokenizer ):
139+ """A tp_plan of None is not forwarded to from_pretrained."""
140+ with (
141+ patch (
142+ "transformers.AutoModelForCausalLM.from_pretrained" ,
143+ return_value = mock_model ,
144+ ) as mock_from_pretrained ,
145+ patch (
146+ "transformers.AutoTokenizer.from_pretrained" ,
147+ return_value = mock_tokenizer ,
148+ ),
149+ ):
150+ HuggingFaceLLMDeploy (hf_model_id_path = "test/model" , task = "text-generation" , tp_plan = None )
151+ mock_from_pretrained .assert_called_once ()
152+ assert "tp_plan" not in mock_from_pretrained .call_args .kwargs
153+
154+ def test_initialization_forwards_tp_plan_when_set (self , mock_model , mock_tokenizer ):
155+ """A non-None tp_plan is forwarded to from_pretrained."""
156+ with (
157+ patch (
158+ "transformers.AutoModelForCausalLM.from_pretrained" ,
159+ return_value = mock_model ,
160+ ) as mock_from_pretrained ,
161+ patch (
162+ "transformers.AutoTokenizer.from_pretrained" ,
163+ return_value = mock_tokenizer ,
164+ ),
165+ ):
166+ HuggingFaceLLMDeploy (hf_model_id_path = "test/model" , task = "text-generation" , tp_plan = "auto" )
167+ mock_from_pretrained .assert_called_once ()
168+ assert mock_from_pretrained .call_args .kwargs ["tp_plan" ] == "auto"
169+
138170 def test_triton_input_output_config (self ):
139171 deployer = HuggingFaceLLMDeploy (model = MagicMock (), tokenizer = MagicMock (), task = "text-generation" )
140172
0 commit comments