Skip to content

Fix multihost_utils.process_allgather tiled=True in hf_utils.py - #4799

Open
olufiyin19 wants to merge 1 commit into
test-pipeline-ckpt-validationfrom
fix-validation-pipeline-qwen3-0.6b-dag_verify_forward_pass_v5e-256-bodaborg-europe-west4-manual__b835e7ad-maxtext_f
Open

Fix multihost_utils.process_allgather tiled=True in hf_utils.py#4799
olufiyin19 wants to merge 1 commit into
test-pipeline-ckpt-validationfrom
fix-validation-pipeline-qwen3-0.6b-dag_verify_forward_pass_v5e-256-bodaborg-europe-west4-manual__b835e7ad-maxtext_f

Conversation

@olufiyin19

Copy link
Copy Markdown
Collaborator

Fix multihost_utils.process_allgather tiled=True in hf_utils.py

@google-cla

google-cla Bot commented Aug 9, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request removes the 'block_diffusion' attention type and its associated configurations, refactors the email alert system to use standard SMTP instead of Pub/Sub, simplifies the training engine by delegating gradient accumulation, and removes redundant parameter synchronization in RL training. Key feedback highlights a critical bug where checkpoints at step 0 fail to restore due to a falsy check, potential SMTP connection failures on mock servers due to unconditional TLS, broken attention type comparisons resulting from the removal of type resolution, and an opportunity to log rather than silently ignore exceptions during learning rate recording.

Comment on lines +322 to 323
if not restored_step:
return None

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Changing the check from restored_step is None to not restored_step introduces a critical bug. Since 0 is falsy in Python, if a checkpoint is restored at step 0, not restored_step will evaluate to True, causing the method to return None and fail to restore the checkpoint.

We should revert this check to explicitly check for None.

Suggested change
if not restored_step:
return None
if restored_step is None:
return None

Comment on lines +50 to +54
with smtplib.SMTP(smtp_server, smtp_port) as server:
server.starttls()
if smtp_user and smtp_pass:
server.login(smtp_user, smtp_pass)
server.send_message(msg)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Calling server.starttls() unconditionally will fail with an SMTPException when connecting to a local mock SMTP server (such as one running on port 1025) that does not support TLS. This will cause the script to exit with sys.exit(1) instead of successfully sending the message or falling back.

We should only initiate TLS if authentication credentials (smtp_user and smtp_pass) are provided.

Suggested change
with smtplib.SMTP(smtp_server, smtp_port) as server:
server.starttls()
if smtp_user and smtp_pass:
server.login(smtp_user, smtp_pass)
server.send_message(msg)
with smtplib.SMTP(smtp_server, smtp_port) as server:
if smtp_user and smtp_pass:
server.starttls()
server.login(smtp_user, smtp_pass)
server.send_message(msg)

raise ValueError("causal_block_size must be positive for block-diffusion attention")
if self.attention_kernel not in ("autoselected", "dot_product", "flash"):
raise ValueError("Block-diffusion attention is supported only by dot_product attention and TPU Splash attention.")
self.attention_type = attention_type

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Since AttentionType is a standard enum.Enum (not a StrEnum), comparing a string value (e.g., from the configuration) directly with AttentionType enum members will always evaluate to False (for example, "full" == AttentionType.FULL is False).

By removing _resolve_attention_type, self.attention_type can now be a string, which will break attention mask generation and attention type checks. We should ensure self.attention_type is always normalized to an AttentionType enum member.

Suggested change
self.attention_type = attention_type
self.attention_type = AttentionType(attention_type) if attention_type is not None else AttentionType.GLOBAL

self.quant = quant
self.kv_quant = kv_quant
self.attention_type = _resolve_attention_type(self.config, attention_type)
self.attention_type = attention_type

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Since AttentionType is a standard enum.Enum (not a StrEnum), comparing a string value directly with AttentionType enum members will always evaluate to False.

By removing _resolve_attention_type, self.attention_type can now be a string, which will break attention mask generation and attention type checks. We should ensure self.attention_type is always normalized to an AttentionType enum member.

Suggested change
self.attention_type = attention_type
self.attention_type = AttentionType(attention_type) if attention_type is not None else AttentionType.GLOBAL

Comment on lines +204 to +208
try:
lr = self._learning_rate_schedule(self.train_step)
self.record_metrics("learning_rate", lr)
except Exception: # pylint: disable=broad-except
pass

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Silently catching and ignoring all exceptions with pass can hide underlying bugs in the learning rate schedule or the training step state. It is highly recommended to at least log the exception using logging.warning so that any failures are visible in the logs.

Suggested change
try:
lr = self._learning_rate_schedule(self.train_step)
self.record_metrics("learning_rate", lr)
except Exception: # pylint: disable=broad-except
pass
try:
lr = self._learning_rate_schedule(self.train_step)
self.record_metrics("learning_rate", lr)
except Exception as e: # pylint: disable=broad-except
logging.warning("Failed to calculate or record learning rate: %s", e)

@olufiyin19
olufiyin19 force-pushed the test-pipeline-ckpt-validation branch 2 times, most recently from 1d4dc21 to 9015dd6 Compare August 10, 2026 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant