Repository navigation
Conversation
…ator tile At the 256 MiB default a head_dim 512 array-mask call is cut into 419-row chunks, which differs from the single call by 3.05e-5 (1 to 2 fp16 ulp) on M5. A chunk size that is not a tile multiple changes the kernel's reduction. `query_chunk_len` now rounds its result down to a multiple of `NA_TILE_SIZE` (32) through a new `align_to_na_tile_floor`, the counterpart to the existing ceiling helper: rounding up would spend budget the caller already decided it did not have, so the floor never exceeds its input. A count below one tile is returned unchanged for the same reason. Verified: - `layers::tests::query_chunk_len_splits_evenly_within_budget` asserts the alignment on cells that really need it (209 -> 192, 100 -> 96 rows) and that the budget still bounds every chunk; mutation-checked by removing the floor, which fails it with `chunk 209 is not a tile multiple`. - `utils::tests::test_align_to_na_tile_floor_never_exceeds_its_input` sweeps 0..=1024 and pins that the floor never grows its input. - `cargo test -p mlxcel-core --lib -- --test-threads=1`: 2688 passed, 7 ignored, 0 failed. `cargo fmt --check` and `cargo clippy -p mlxcel-core --lib --tests -- -D warnings` clean. Not verified here: the issue's `sdpa_chunk_peak_memory_probe` run needs an M5-class host. On this 32 GB M1 Pro the probe aborts with `Insufficient Memory (kIOGPUCommandBufferCallbackErrorOutOfMemory)` before it can report a max abs diff, so the 256 MiB equality claim still needs an M5 session. Refs lablup#3052
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses item 2 of #3052 (
Tile-align the query-chunk row count).At the 256 MiB default a head_dim 512 array-mask call is cut into
419-row chunks, which differs from the single call by 3.05e-5 (1 to 2 fp16
ulp) on M5. The hypothesis in the issue: a chunk size that is not a tile
multiple changes the kernel's reduction.
Change
query_chunk_lenrounds its result down to a wholeNA_TILE_SIZEtilethrough a new
align_to_na_tile_floorinutils.rs, the counterpart to theexisting
align_to_na_tileceiling.One decision worth reviewing: the floor never exceeds its input, and a
count below one tile is returned unchanged.
A one-tile-minimum version is wrong here, and the existing
chunk * per_row <= budgetassertion caught it atper_row 1000, q_len 100, budget 7000(7 rows -> 32 rows = 32 000 B over 7 000 B).returning zero rows and never advancing.
Verification
layers::tests::query_chunk_len_splits_evenly_within_budgetasserts thealignment on cells where the floor does real work — the head_dim 512 shape
from the issue (209 rows -> 192) and a smaller one (100 -> 96) — plus the
budget bound for every cell. Mutation-checked by removing the floor, which
fails it with
chunk 209 is not a tile multiple.utils::tests::test_align_to_na_tile_floor_never_exceeds_its_inputsweeps0..=1024 and pins
floor(len) <= lenplus the sub-tile identity.cargo test -p mlxcel-core --lib -- --test-threads=1on this base:2720 passed, 7 ignored, 2 failed — and both failures are the
pre-existing [nightly-verify] main is red #3652 flake, reproduced identically on
upstream/mainwithout this change (
left: [3, 3, 0, 0, 7, ...]/right: [3, 3, 0, 0, 4, ...]). PR fix(kv): compare Turbo codebook boundaries in the integer domain #3733 fixes them; this branch is orthogonal to them.With fix(kv): compare Turbo codebook boundaries in the integer domain #3733 applied, the same suite is 2722 passed, 0 failed.
cargo fmt --checkandcargo clippy -p mlxcel-core --lib --tests -- -D warningsclean.Not verified here
The issue's first acceptance criterion needs an M5-class host. On this 32 GB
M1 Pro,
aborts before reporting:
so the "max abs diff 0 at 256 MiB" claim still needs an M5 session. The
alignment itself (the second criterion) is covered by the unit test.