Skip to content

Preserve promoted dtype in optimized batching - #1447

Open
DiadkoShmek wants to merge 1 commit into
google:mainfrom
DiadkoShmek:lezo3-batch-dtype-promotion
Open

DiadkoShmek wants to merge 1 commit into
google:mainfrom
DiadkoShmek:lezo3-batch-dtype-promotion

Conversation

@DiadkoShmek

@DiadkoShmek DiadkoShmek commented Nov 2, 2026 •

Copy link
Copy Markdown

Shared-memory batching changes the dtype inferred by ordinary Dataset.batch: an accepted batch containing int8 [1] followed by int64 [300] becomes int8 [[1], [44]] after enable_shared_memory_output(). The parallel-copy helper has the same first-element allocation assumption, including its non-shared output path.

Infer the output dtype from every input leaf before allocating the output, matching np.stack promotion. Apply this at the three optimized allocation sites while retaining object/string fallback behavior.

The regression uses real Map/Iter datasets and parallel-copy paths with both input orders, integer widths, bool/integer, integer/float and wider float/complex inputs. On the exact base 15 cases fail or error and 13 controls pass; all 28 pass after the fix. The selected supported batch suite passes 96 tests, including the new regressions. Separate property checks cover 288 ordered dtype/pipeline cases and noncontiguous inputs; independent real shared-memory/thread-copy checks also pass.

The unrestricted batch file retains the same 12 baseline errors: nine need optional JAX, and three are existing no-JAX tree-error message mismatches. No full-suite, multiprocess-prefetch, JAX/TF or throughput claim is made. Shared-memory tests close/unlink the allocations they own.


📚 Documentation preview 📚: https://google-grain--1447.org.readthedocs.build/

This branch has not been deployed

No deployments
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