Skip to content

Add tree-mode support to nnx.scan#5262

Merged
copybara-service[bot] merged 1 commit into
mainfrom
test_870199445
Feb 20, 2026
Merged

Add tree-mode support to nnx.scan#5262
copybara-service[bot] merged 1 commit into
mainfrom
test_870199445

Conversation

@copybara-service

Copy link
Copy Markdown

Add tree-mode support to nnx.scan

Adds TreeScanFn dataclass and graph parameter to nnx.scan, enabling
tree-mode operation when graph=False. Tree-mode enforces default
in_axes=(Carry, 0) and out_axes=(Carry, 0), checks carry Variable
identity preservation across iterations, and performs alias checks on scan
outputs. Also parametrizes existing scan tests and adds new tree-mode
specific tests.

Adds `TreeScanFn` dataclass and `graph` parameter to `nnx.scan`, enabling
tree-mode operation when `graph=False`. Tree-mode enforces default
`in_axes=(Carry, 0)` and `out_axes=(Carry, 0)`, checks carry Variable
identity preservation across iterations, and performs alias checks on scan
outputs. Also parametrizes existing scan tests and adds new tree-mode
specific tests.

PiperOrigin-RevId: 873044806
@copybara-service copybara-service Bot merged commit 934d53c into main Feb 20, 2026
@copybara-service copybara-service Bot deleted the test_870199445 branch February 20, 2026 21:14
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.

0 participants