Skip to content

add nnx_scan util module#4507

Merged
copybara-service[bot] merged 1 commit into
mainfrom
aireen/pr-nnx-scan-helper
Jul 17, 2026
Merged

add nnx_scan util module#4507
copybara-service[bot] merged 1 commit into
mainfrom
aireen/pr-nnx-scan-helper

Conversation

@aireenmei

@aireenmei aireenmei commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Description

NNXDecoder._create_scanned_layers provides a generic logic for creating scanned layers. Moving it into a separate nnx_scan util module allows re-using by other modules. Use case: Gemma4 will use a custom way to implement scannable block (in an up-coming PR), and can re-use this logic. But importing from NNXDecoder will cause circular imports. A separate nnx_scan module make the code cleaner.

Also fix a bug: jnp.moveaxis(x, scan_axis, 0) -> jnp.moveaxis(x, 0, param_scan_axis), with added unit test to guard.

Tests

Unit test

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

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/maxtext/layers/nnx_scan.py 82.60% 3 Missing and 5 partials ⚠️

📢 Thoughts on this report? Let us know!

@aireenmei
aireenmei force-pushed the aireen/pr-nnx-scan-helper branch from 946c7cb to 6d78811 Compare July 16, 2026 20:09
@copybara-service
copybara-service Bot merged commit e10af2f into main Jul 17, 2026
119 of 124 checks passed
@copybara-service
copybara-service Bot deleted the aireen/pr-nnx-scan-helper branch July 17, 2026 21:14
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