AINative commited on
Commit
d776fee
·
1 Parent(s): ed795b3

Fix endpoint startup: load weights from upstream diffusers model ID

Browse files

The HF Inference Toolkit passes the local endpoint repo dir as path, but that
dir has no model_index.json (only handler.py + requirements.txt), causing
OSError on startup. Always load from the upstream model ID instead.

Files changed (1) hide show
  1. handler.py +13 -3
handler.py CHANGED
@@ -16,15 +16,25 @@ if device.type != 'cuda':
16
  dtype = torch.bfloat16 if torch.cuda.is_bf16_supported() else torch.float16
17
 
18
  class EndpointHandler():
 
 
 
 
 
 
 
 
 
 
19
  def __init__(self, path=""):
20
  """
21
  Initialize HunyuanVideo pipeline for video generation.
22
  Args:
23
- path: Path to model weights (will be tencent/HunyuanVideo)
24
  """
25
- # Load HunyuanVideo pipeline
26
  self.pipe = HunyuanVideoPipeline.from_pretrained(
27
- path if path else "tencent/HunyuanVideo",
28
  torch_dtype=dtype
29
  )
30
  self.pipe.to(device)
 
16
  dtype = torch.bfloat16 if torch.cuda.is_bf16_supported() else torch.float16
17
 
18
  class EndpointHandler():
19
+ # Upstream model that actually holds the weights. The HF Inference Toolkit
20
+ # passes the local endpoint repo dir (/repository) as `path`, but that repo
21
+ # only contains handler.py + requirements.txt — no model_index.json. So we
22
+ # always load from the upstream model ID, ignoring the passed-in path.
23
+ #
24
+ # NOTE: use the diffusers-format community repo, NOT tencent/HunyuanVideo —
25
+ # the official repo ships raw .pt checkpoints with no model_index.json and
26
+ # is not loadable via HunyuanVideoPipeline.from_pretrained.
27
+ MODEL_ID = "hunyuanvideo-community/HunyuanVideo"
28
+
29
  def __init__(self, path=""):
30
  """
31
  Initialize HunyuanVideo pipeline for video generation.
32
  Args:
33
+ path: Local endpoint dir from the toolkit (ignored has no weights).
34
  """
35
+ # Load HunyuanVideo pipeline from the upstream model ID.
36
  self.pipe = HunyuanVideoPipeline.from_pretrained(
37
+ self.MODEL_ID,
38
  torch_dtype=dtype
39
  )
40
  self.pipe.to(device)