Skip to content

Commit

Permalink
fix(server): T5 weights names. (#582)
Browse files Browse the repository at this point in the history
Fixes #541
  • Loading branch information
Narsil committed Jul 12, 2023
1 parent f063ebd commit db4efbf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1006,12 +1006,7 @@ def __init__(self, config: T5Config, weights):
super().__init__(config)
self.model_dim = config.d_model

try:
self.shared = TensorParallelEmbedding(prefix="shared", weights=weights)
except RuntimeError:
self.shared = TensorParallelEmbedding(
prefix="encoder.embed_tokens", weights=weights
)
self.shared = TensorParallelEmbedding(prefix="shared", weights=weights)

encoder_config = copy.deepcopy(config)
encoder_config.is_decoder = False
Expand Down
11 changes: 10 additions & 1 deletion server/text_generation_server/models/t5.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,16 @@ def __init__(
torch.distributed.barrier(group=self.process_group)
filenames = weight_files(model_id, revision=revision, extension=".safetensors")
weights = Weights(
filenames, device=device, dtype=dtype, process_group=self.process_group
filenames,
device=device,
dtype=dtype,
process_group=self.process_group,
aliases={
"shared.weight": [
"encoder.embed_tokens.weight",
"decoder.embed_tokens.weight",
]
},
)

model = T5ForConditionalGeneration(config, weights)
Expand Down

0 comments on commit db4efbf

Please sign in to comment.