Skip to content

fix(mhc test): let the batch scale with the device count - #5133

Open
gulsumgudukbay wants to merge 1 commit into
AI-Hypercomputer:mainfrom
ROCm:fix-mhc-test-batch-vs-mesh
Open

fix(mhc test): let the batch scale with the device count#5133
gulsumgudukbay wants to merge 1 commit into
AI-Hypercomputer:mainfrom
ROCm:fix-mhc-test-batch-vs-mesh

Conversation

@gulsumgudukbay

@gulsumgudukbay gulsumgudukbay commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Description

_setup_mhc uses per_device_batch_size as the global batch of self.x, which is why it defaults to jax.device_count(). Three tests override it to 1, so on any host with more than one device the batch is smaller than the mesh: the FSDP axis tries to partition axis 0 four ways on a 4-device host and the layer fails with IndivisibleError: array axis 0 is partitioned 4 times, but the dimension size is 1.

They pass in CI only because the job that runs them (cpu-unit) has a single device. These tests are auto-marked cpu_only, so the 4-GPU gpu-unit job deselects them. Dropping the override and taking the helper's default keeps single-device behavior identical while making the batch divide the mesh anywhere else. Batch size is irrelevant to what these tests assert (kernel dispatch and block-size plumbing).

Tests

Reproduce the failure on main and the fix on this branch with:

XLA_FLAGS=--xla_force_host_platform_device_count=4 python -m pytest \
  tests/unit/mhc_test.py -k use_mhc_pallas_kernel

Verified on 4x AMD Instinct MI355X (ROCm 10, jax 0.11.1): the three tests fail on main with the
IndivisibleError above and pass on this branch. The full tests/unit/mhc_test.py file also passes there
(25 passed, 2 skipped).

Checklist

  • I have performed a self-review of my code. For an optional AI review, add the gemini-review label.
  • I have necessary comments in my code, particularly in hard-to-understand areas.
  • I have run end-to-end tests tests and provided workload links above if applicable.
  • I have made or will make corresponding changes to the doc if needed.

`_setup_mhc` uses `per_device_batch_size` as the *global* batch of `self.x`,
which is why it defaults to `jax.device_count()`. These three tests overrode it
to 1, so on any host with more than one device the batch is smaller than the
mesh: the FSDP axis wants to partition axis 0 four ways on a 4-device runner and
the layer dies with `IndivisibleError`. They pass on a single-device CPU, which
is the only place CI runs them. Drop the override and take the default, as the
rest of the file does; batch size is irrelevant to what these tests assert.

@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 unused per_device_batch_size=1 parameter from the test configurations in tests/unit/mhc_test.py. There are no review comments, and I have no feedback to provide.

@codecov

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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