Skip to content

Mhc optimization: Rewrites einsums for better xla fusion - #4664

Open
h1t35h wants to merge 1 commit into
AI-Hypercomputer:mainfrom
h1t35h:mhc-optimization
Open

Mhc optimization: Rewrites einsums for better xla fusion#4664
h1t35h wants to merge 1 commit into
AI-Hypercomputer:mainfrom
h1t35h:mhc-optimization

Conversation

@h1t35h

@h1t35h h1t35h commented Jul 29, 2026

Copy link
Copy Markdown

Description

XLA optimizations does not seem to gel well with einsum for cases where dimensions are being expanded. Leading to a ~10- 15% performance drop in the current implementation. This change implements expanded einsums with jnp.expand_dims leading to better XLA fusion.

Before (110us):
image
After (97us):
image

Tests

All existing tests passing.

Checklist

Before submitting this PR, please make sure (put X in square brackets):

  • 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, including adding new documentation pages to the relevant Table of Contents (toctree directive) as explained in our documentation.

@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

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