Skip to content

Commit ec4741f

Browse files
committed
Ignore the serialized Mosaic kernel when diffing HLO
The Mosaic module of a Pallas custom call is serialized into the HLO and carries the absolute path of the installed jax package, so the dump differs between a venv install and a Docker image install even though the compiled graph is identical. That made hlo_diff_test fail on the Docker image CI jobs. Normalize the payload away in filter_line, like stack_frame_id already is.
1 parent e190ed6 commit ec4741f

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

tests/integration/hlo_diff_test.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,21 @@
4343
# Filters and normalizes an HLO line to ignore environment-specific details.
4444
STACK_FRAME_REGEX = re.compile(r"stack_frame_id=\d+")
4545

46+
# The serialized Mosaic kernel of a Pallas custom call embeds the absolute path of the installed
47+
# jax package, so it differs between a venv install and a Docker image install even though the
48+
# compiled graph is the same. The kernel's shapes and block sizes are still checked, since they
49+
# appear as plain text elsewhere in the dump.
50+
CUSTOM_CALL_BODY_REGEX = re.compile(r'("custom_call_config":\{"body":")[^"]*(")')
51+
4652

4753
def filter_line(line):
4854
# Matches operation sections content like: 1234 {"sharding parameters", ...} or 1234 "operation metadata"
4955
if SECTION_CONTENT_REGEX.match(line):
5056
return None
5157
# Replace stack_frame_id=... with stack_frame_id=0
5258
line = STACK_FRAME_REGEX.sub("stack_frame_id=0", line)
59+
# Replace the serialized Mosaic kernel with a placeholder
60+
line = CUSTOM_CALL_BODY_REGEX.sub(r"\1<mosaic_body>\2", line)
5361
return line
5462

5563

0 commit comments

Comments
 (0)