@@ -247,10 +247,11 @@ def test_builder_role_used_when_role_omitted(self, mb_class):
247247
248248
249249class TestDeployRecommendationSpeculativeDecoding :
250- """Speculative-decoding / kernel-tuning recommendations (ModelPackage carries
251- AdditionalModelDataSources) are collapsed to a single ModelDataSource +
252- OPTION_SPECULATIVE_DRAFT_MODEL env so the model can be hosted (Inference
253- Components reject AdditionalModelDataSources)."""
250+ """Optimized recommendations (kernel tuning / speculative decoding) carry
251+ the base weights and any draft model as AdditionalModelDataSources on the
252+ ModelPackage. The hosting stack (including Inference Components) now resolves
253+ those channels itself, so deploy just passes the ModelPackage through — no
254+ client-side collapsing of the additional sources into a primary source."""
254255
255256 def _make_builder (self , mb_class , described ):
256257 mb = mb_class (sagemaker_session = MagicMock ())
@@ -291,52 +292,16 @@ def _channel(name, uri):
291292 },
292293 }
293294
294- def test_base_model_channel_promoted_to_primary_source (self , mb_class ):
295- # Optimized recs put the weights in a base_model channel with an empty
296- # primary ModelDataSource; the base_model S3 uri becomes the primary source,
297- # and env vars that pointed at the old channel path are repointed to
298- # /opt/ml/model (where the primary source mounts).
295+ def test_optimized_recommendation_deploys_via_model_package (self , mb_class ):
296+ # An optimized rec exposes base_model + draft_model as additional data
297+ # sources; deploy no longer collapses them — it passes the ModelPackage
298+ # through and lets the hosting stack resolve the channels.
299299 described = {
300300 "ModelApprovalStatus" : "Approved" ,
301301 "InferenceSpecification" : {
302302 "Containers" : [
303303 {
304304 "Image" : "123.dkr.ecr.us-west-2.amazonaws.com/djl-inference:latest" ,
305- "Environment" : {
306- "OPTION_TENSOR_PARALLEL_DEGREE" : "1" ,
307- "HF_MODEL_ID" : "/opt/ml/additional-model-data-sources/base_model" ,
308- "option.model_id" : "/opt/ml/additional-model-data-sources/base_model" ,
309- },
310- "AdditionalModelDataSources" : [
311- self ._channel ("base_model" , "s3://base/weights/" )
312- ],
313- }
314- ]
315- },
316- }
317- mb = self ._make_builder (mb_class , described )
318- container = self ._deploy (mb ).call_args .kwargs ["primary_container" ]
319-
320- # No AdditionalModelDataSources on the created model (IC would reject it).
321- assert not getattr (container , "additional_model_data_sources" , None )
322- assert not getattr (container , "model_package_name" , None )
323- # base_model weights promoted to the primary source.
324- assert container .model_data_source .s3_data_source .s3_uri == "s3://base/weights/"
325- # Env vars that referenced the old channel path now point at the primary mount.
326- assert container .environment ["HF_MODEL_ID" ] == "/opt/ml/model"
327- assert container .environment ["option.model_id" ] == "/opt/ml/model"
328- # No draft channel here, so no draft env.
329- assert "OPTION_SPECULATIVE_DRAFT_MODEL" not in container .environment
330- assert container .environment ["OPTION_TENSOR_PARALLEL_DEGREE" ] == "1"
331-
332- def test_draft_model_channel_mounted_via_env (self , mb_class ):
333- described = {
334- "ModelApprovalStatus" : "Approved" ,
335- "InferenceSpecification" : {
336- "Containers" : [
337- {
338- "Image" : "123.dkr.ecr.us-west-2.amazonaws.com/djl-inference:latest" ,
339- "Environment" : {},
340305 "AdditionalModelDataSources" : [
341306 self ._channel ("base_model" , "s3://base/weights/" ),
342307 self ._channel ("draft_model" , "s3://draft/model/" ),
@@ -348,19 +313,10 @@ def test_draft_model_channel_mounted_via_env(self, mb_class):
348313 mb = self ._make_builder (mb_class , described )
349314 container = self ._deploy (mb ).call_args .kwargs ["primary_container" ]
350315
351- # base_model is the primary source.
352- assert container .model_data_source .s3_data_source .s3_uri == "s3://base/weights/"
353- # The draft channel stays attached as an additional model data source so
354- # the speculative-decoding env path is actually populated at runtime
355- # (a model-based endpoint supports additional model data sources).
356- assert len (container .additional_model_data_sources ) == 1
357- draft = container .additional_model_data_sources [0 ]
358- assert draft .channel_name == "draft_model"
359- assert draft .s3_data_source .s3_uri == "s3://draft/model/"
360- assert (
361- container .environment ["OPTION_SPECULATIVE_DRAFT_MODEL" ]
362- == "/opt/ml/additional-model-data-sources/draft_model/"
363- )
316+ # Deployed straight from the ModelPackage — no client-side collapsing.
317+ assert container .model_package_name == "arn:.../p/A"
318+ assert not getattr (container , "model_data_source" , None )
319+ assert not getattr (container , "additional_model_data_sources" , None )
364320
365321 def test_no_additional_sources_uses_model_package (self , mb_class ):
366322 described = {
@@ -370,7 +326,7 @@ def test_no_additional_sources_uses_model_package(self, mb_class):
370326 mb = self ._make_builder (mb_class , described )
371327 model_create = self ._deploy (mb )
372328 container = model_create .call_args .kwargs ["primary_container" ]
373- # Plain (non-speculative-decoding ) recommendation still deploys via the ModelPackage.
329+ # Plain (non-optimized ) recommendation also deploys via the ModelPackage.
374330 assert container .model_package_name == "arn:.../p/A"
375331
376332
0 commit comments