Skip to content

Add unit tests for embeddings.py and RoPE variants#3706

Merged
copybara-service[bot] merged 1 commit intomainfrom
add-embeddings-tests
Apr 20, 2026
Merged

Add unit tests for embeddings.py and RoPE variants#3706
copybara-service[bot] merged 1 commit intomainfrom
add-embeddings-tests

Conversation

@bvandermoon
Copy link
Copy Markdown
Collaborator

@bvandermoon bvandermoon commented Apr 20, 2026

Description

This PR adds unit tests for src/maxtext/layers/embeddings.py, covering:

  • Embed class: Basic call and attend method.
  • RotaryEmbedding class: Basic call.
  • RoPE variants: PartialRotaryEmbedding, Gemma4PartialRotaryEmbedding, LLaMARotaryEmbedding, and YarnRotaryEmbedding.
  • Added snapshot assertions for RoPE variants to verify output values against current implementation.
    These tests help ensure the correctness of these complex embedding layers and protect against future regressions.

Tests

I tested this change by running the new unit tests on a TPU VM.
Command: pytest tests/unit/embeddings_test.py
Result: 7 passed

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.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@bvandermoon bvandermoon force-pushed the add-embeddings-tests branch 2 times, most recently from d7e0d44 to 5d6c0aa Compare April 20, 2026 21:22
@bvandermoon bvandermoon force-pushed the add-embeddings-tests branch from 5d6c0aa to e103e63 Compare April 20, 2026 21:34
@copybara-service copybara-service Bot merged commit 59cf305 into main Apr 20, 2026
43 checks passed
@copybara-service copybara-service Bot deleted the add-embeddings-tests branch April 20, 2026 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants