Skip to content

Commit

Permalink
Use repr instead of str in BasePartitioner's error messages
Browse files Browse the repository at this point in the history
It can give the user a hint when they're accidentally passing a value as a string, e.g. `model_parallel_submesh='(2,2,1,1)'` instead of `model_parallel_submesh=(2,2,1,1)`, which can easily happen with Gin.

PiperOrigin-RevId: 566905780
  • Loading branch information
T5X Team authored and t5-copybara committed Sep 20, 2023
1 parent 9e80329 commit 24df7a5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions t5x/partitioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ def __init__(self,
logging.error(
(
'`model_parallel_submesh` must be either None or a 4-tuple. Got'
' `model_parallel_submesh`=%s. A ValueError will be raised'
' `model_parallel_submesh`=%r. A ValueError will be raised'
' beginning March 1, 2022.'
),
model_parallel_submesh,
Expand All @@ -592,9 +592,11 @@ def __init__(self,
if bool(num_partitions) and bool(model_parallel_submesh):
logging.error(
'At most one of `num_partitions` or `model_parallel_submesh` can be '
'set. Got `num_partitions=%s` and `model_parallel_submesh`=%s. A '
'ValueError will be raised beginning March 21, 2022.', num_partitions,
model_parallel_submesh)
'set. Got `num_partitions=%r` and `model_parallel_submesh`=%r. A '
'ValueError will be raised beginning March 21, 2022.',
num_partitions,
model_parallel_submesh,
)

self._num_partitions = num_partitions
self._model_parallel_submesh = model_parallel_submesh
Expand Down

0 comments on commit 24df7a5

Please sign in to comment.