`_deploy_for_ic` passes `instance_type` twice to `_deploy()` causing `TypeError` when deploying `CustomOrchestrator` as Inference Component
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 88/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- aws, python
调研方向
从 sagemaker-serve/src/sagemaker/serve/model_builder.py 中的 _deploy_for_ic() 以及 6189-6196 行附近的 deploy() 调用开始。复现文档中所述的 CustomOrchestrator 部署,然后检查 instance_type 和 initial_instance_count 如何传递到 _deploy()。当 deploy() 能够在不出现重复关键字 TypeError 的情况下创建推理组件时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
PySDK Version
- PySDK V2 (2.x)
- PySDK V3 (3.x)
Describe the bug
When deploying a CustomOrchestrator as an Inference Component — as documented in the Build and deploy AI inference workflows with new enhancements to the Amazon SageMaker Python SDK blog post and the Llama3.1-Mistral reference notebook — calling deploy() raises a TypeError: got multiple values for keyword argument 'instance_type'.
The issue is in _deploy_for_ic() (model_builder.py L4227-4237): instance_type and initial_instance_count are passed both as explicit keyword arguments and via **kwargs spread to self._deploy().
To reproduce
from sagemaker.serve.model_builder import ModelBuilder, SchemaBuilder
from sagemaker.serve.spec.inference_base import CustomOrchestrator
from sagemaker.core.inference_config import ResourceRequirements
from sagemaker.core.helper.session_helper import Session, get_execution_role
class MyOrchestrator(CustomOrchestrator):
def __init__(self, endpoint_name, component_names):
super().__init__()
self.endpoint_name = endpoint_name
self.component_names = component_names
def handle(self, data, context=None):
import json
response = self.client.invoke_endpoint(
EndpointName=self.endpoint_name,
InferenceComponentName=self.component_names[0],
Body=data if isinstance(data, (str, bytes)) else json.dumps(data),
ContentType="application/json"
)
return json.loads(response["Body"].read())
role = get_execution_role()
sess = Session()
# Step 1: Build the orchestrator
orchestrator = ModelBuilder(
inference_spec=MyOrchestrator(
endpoint_name="my-existing-endpoint",
component_names=["base-ic", "adapter-ic"],
),
dependencies={"auto": False, "custom": ["cloudpickle"]},
sagemaker_session=sess,
role_arn=role,
schema_builder=SchemaBuilder(sample_input="Test", sample_output={"generated_text": "test"}),
)
# Workaround for missing constructor fields (separate issue)
orchestrator.resource_requirements = ResourceRequirements(
requests={"memory": 4096, "num_accelerators": 1, "copies": 1, "num_cpus": 2}
)
orchestrator.inference_component_name = "my-orchestrator-ic"
orchestrator.build()
# Step 2: Deploy — this triggers the bug
orchestrator.deploy(
endpoint_name="my-existing-endpoint",
custom_orchestrator_instance_type="ml.g6.12xlarge",
initial_instance_count=1,
)
Expected behavior
deploy() should deploy the CustomOrchestrator as an Inference Component on the specified endpoint without error.
Screenshots or logs
│ 4226 │ │ │ # Create new IC via _deploy() │
│ ❱ 4227 │ │ │ return self._deploy( │
│ 4228 │ │ │ │ built_model=built_model, │
│ 4229 │ │ │ │ endpoint_name=endpoint_name, │
│ 4230 │ │ │ │ endpoint_type=EndpointType.INFERENCE_COMPONENT_BASED, │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: sagemaker.serve.model_builder.ModelBuilder._deploy() got multiple values for keyword argument
'instance_type'
Full traceback:
/opt/conda/lib/python3.12/site-packages/sagemaker/serve/model_builder.py:6189 in deploy
│ ❱ 6189 │ │ │ │ │ │ self._deploy_for_ic(
│ 6190 │ │ │ │ │ │ │ ic_data=custom_orchestrator,
│ 6191 │ │ │ │ │ │ │ container_timeout_in_seconds=container_timeout_in_seconds,
│ 6192 │ │ │ │ │ │ │ instance_type=custom_orchestrator_instance_type or instance_type,
/opt/conda/lib/python3.12/site-packages/sagemaker/serve/model_builder.py:4227 in _deploy_for_ic
│ ❱ 4227 │ │ │ return self._deploy(
│ 4228 │ │ │ │ built_model=built_model,
│ 4229 │ │ │ │ endpoint_name=endpoint_name,
│ 4230 │ │ │ │ endpoint_type=EndpointType.INFERENCE_COMPONENT_BASED,
TypeError: sagemaker.serve.model_builder.ModelBuilder._deploy() got multiple values for keyword argument 'instance_type'
System information
- SageMaker Python SDK version: sagemaker-serve 1.20.0 (SDK V3)
- Framework name: SageMaker Distribution (SMD) container
- Framework version:
sagemaker-distribution-prod:3.2.0-cpu - Python version: 3.12
- CPU or GPU: GPU (
ml.g6.2xlargeendpoint) - Custom Docker image (Y/N): N
Additional context
Root cause analysis:
In deploy() (L6189-6196), _deploy_for_ic is called with instance_type as an explicit kwarg:
self._deploy_for_ic(
ic_data=custom_orchestrator,
container_timeout_in_seconds=container_timeout_in_seconds,
instance_type=custom_orchestrator_instance_type or instance_type, # explicit
initial_instance_count=custom_orchestrator_initial_instance_count or initial_instance_count, # explicit
endpoint_name=endpoint_name,
**kwargs,
)
Then in _deploy_for_ic() (L4227-4237):
def _deploy_for_ic(self, ic_data, endpoint_name, **kwargs):
...
return self._deploy(
built_model=built_model,
endpoint_name=endpoint_name,
endpoint_type=EndpointType.INFERENCE_COMPONENT_BASED,
resources=resource_requirements,
inference_component_name=ic_name,
instance_type=kwargs.get("instance_type", self.instance_type), # extracted from kwargs
initial_instance_count=kwargs.get("initial_instance_count", 1), # extracted from kwargs
**kwargs, # ← kwargs STILL contains instance_type → duplicate!
)
instance_type is extracted from kwargs on one line, then **kwargs is spread on the next — passing the same key twice to _deploy().
- 主要语言
- Python
- 星标
- 2.3k
- 派生
- 1.3k
- 平均合并
- 3 天 14 小时
- 30 天内合并 PR
- 47
环境准备
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
aws/sagemaker-python-sdk 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 86/100
aws/sagemaker-python-sdk#6278 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
aws/sagemaker-python-sdk#6253 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 93/100
aws/sagemaker-python-sdk#6232 ·
维护者通常 1 天内回复
-
component: model monitor type: bug
难度 1/5 1-3 小时 新手友好度 88/100
aws/sagemaker-python-sdk#6206 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
aws/sagemaker-python-sdk#6156 · 2 条评论 ·
维护者通常 1 天内回复
查看 aws/sagemaker-python-sdk 的全部 Issue
相似的 Issue
-
correction metadata
难度 2/5 1-3 小时 新手友好度 68/100
acl-org/acl-anthology#10104 · 1 条评论 ·
维护者通常 1 天内回复
-
bug status/needs-triage
难度 2/5 1-3 小时 新手友好度 86/100
prowler-cloud/prowler#12885 · 1 条评论 ·
维护者通常 1 天内回复
-
Bug in GaussianTailProbabilityCalibrator: running_statistics=False still uses a windowed variance未关闭bug good first issue
难度 2/5 1-3 小时 新手友好度 88/100
selimfirat/pysad#107 ·
维护者通常 1 天内回复
-
bug ci-failure high priority
难度 1/5 1 小时以内 新手友好度 88/100
vllm-project/vllm-omni#8194 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复