Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/maxtext/layers/attention_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,7 @@ def apply_attention(
self.attention_kernel == "dot_product"
or (self.attention_kernel == "autoselected" and model_mode == MODEL_MODE_AUTOREGRESSIVE)
or (self.attention_kernel == "autoselected" and length < 128)
or (self.attention_kernel == "autoselected" and target_hardware == "cpu")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this change gonna silently twist all results using AOT on CPU platform

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi @NuojCheng, thanks for the review! I've double-checked the AOT compilation behavior, and this change works safely without twisting results.

1. AOT correctly bypasses the fallback:
Even when cross-compiling on a CPU host, AOT (via train_compile.py) uses get_topology_desc(platform="tpu") to generate mock devices. These mock devices strictly retain device.platform == "tpu". Thus, target_hardware remains "tpu", properly preserving the flash or autoselected kernels without triggering a fallback to dot_product.

2. aot_identical_test.py passes flawlessly:
I just ran the test manually on my TPU VM and can confirm the generated HLO graphs remain identical and it passes perfectly:

  • tests/integration/aot_identical_test.py::AotHloIdenticalTest::test_default_hlo_match PASSED

Log: https://paste.googleplex.com/4608946768838656

If it’s missing in recent CI job logs, it’s likely because the test classes are wrapped with @pytest.mark.skip_on_tpu7x. If a GitHub Action runner happens to execute on a Trillium (tpu7x) node, Pytest naturally skips it.

Let me know if this clears up the concerns!

or (self.attention_kernel == "paged")
or (self.attention_kernel in ("vllm_rpa", "vllm_batched_rpa"))
):
Expand Down
Loading