Repository navigation
fix(cutile): validate full tensor shapes before allocation - #1452
Conversation
Signed-off-by: Raul Estrada <[email protected]>
0437c81 to
b7c0568
Compare
Signed-off-by: Melih Elibol <[email protected]>
|
/ok to test 05a8be0 |
elibol
left a comment
There was a problem hiding this comment.
Re-reviewed 05a8be035dcbb1cf1a0c5c8c72497a112e51c8c4 after merging current main. The conflict resolution retains main's DType + DeviceCopy bound and this PR's checked shape calculation before allocation. The PR diff remains limited to the original two files. No additional correctness blockers found.
Validation on RTX 5090 / CUDA 13.3: all five shape unit tests and all three GPU regressions pass in both debug and release builds; formatting and strict Clippy pass. The full serial scripts/run_all.sh run also passes, including CPU/assembler tests, GPU tests, 27 examples (one expected toolkit-dependent skip), and all eight benchmarks.
Requested CI for this exact head with /ok to test; the fresh runs are pending. #1451 remains linked for automatic closure on merge and now carries the v0.5.0 milestone.
…#1684) Older bindgen can emit a one-byte placeholder instead of the fields of a forward-declared C struct when using libclang 22. This produces incorrect CUDA bindings and failing layout checks. Upgrade `cuda-bindings` to bindgen 0.72.1, which includes the upstream type-completeness fix in [rust-lang/rust-bindgen#3278](rust-lang/rust-bindgen#3278). The regression test uses a self-contained C typedef chain and verifies that both fields of the completed struct survive binding generation. With bindgen 0.69.5 and libclang 22 it fails because only `_address` is emitted; with 0.72.1 it passes. It runs as part of the existing `cuda-bindings` test suite. Use libclang 22 to exercise the original failure. The large diff is generated lockfile maintenance: 263 affected workspace/example lockfiles now resolve the updated shared bindings dependency. Package additions are limited to the new bindgen and its required rustc-hash version; obsolete transitive dependencies disappear. Archived benchmarks that use separately published crates are unchanged. Validation: - The regression fails with bindgen 0.69.5/libclang 22 and passes with 0.72.1/libclang 22. - Full `cuda-bindings` tests pass, including a CUDA 13.3/libclang 21 compatibility run. Bindgen now emits compile-time layout assertions, so validation includes compiling the generated bindings rather than filtering for old runtime layout-test names. - Shared-host workspace all-target checks, Tile all-target checks, 108 SIMT host tests, and SIMT codegen/Cargo frontend checks pass. - All 263 updated lockfiles resolve with `--offline --locked`; the example lockfile consistency gate also passes after aligning six existing rustc-hash pins with the other examples; dependency policy checks pass for the host, Tile, SIMT, backend, and device-only workspaces. - Formatting, strict bindings Clippy, license inventory, shared-crate pin, and SPDX checks pass. - The new binding-generation regression remains required in the CPU/build suite, which passes with libclang 22 (15 tests; two live-driver cases filtered). The archive-only GPU runner excludes that one compiler-dependent test because its image has no libclang. Reproduced the unfiltered failure in the CI CUDA 13.3.0 image, then verified all 16 runtime tests pass with the corrected filter, including live CUDA/cuRAND. - The head includes merged #1452; its five shape unit tests and three GPU regressions pass on the combined branch. Target: cuTile Rust v0.5.0. --------- Signed-off-by: Melih Elibol <[email protected]> Co-authored-by: Melih Elibol <[email protected]>
Closes #1451
api::fullcurrently uses unchecked multiplication to calculate its flattened element count. Invalid shapes can panic during construction or wrap before allocation and initialization, with shape validation occurring later duringreshape.Validate the element count with checked multiplication and reject zero dimensions and flattened lengths above
i32::MAX. Invalid inputs returnDeviceError::Internalwhen the operation executes, before GPU allocation or kernel execution.zerosandonesinherit the validation throughfull.Add five host tests and three GPU tests covering overflow, zero dimensions, the
i32boundary, construction without panics, and valid tensor shapes and values. Preserve scalar shape[].Validation
Run from
cutile-rs:All commands passed. The serial full run passed CPU and GPU tests, 24 examples, and all eight benchmark smoke tests. Three examples were skipped because they require newer Tile IR versions.
The default parallel run failed in
warmup_composed::composed_builder_compile_terminal_warms_the_dispatched_specialization, with a JIT compile count of 17 instead of 18. That test passed in isolation, and all 16warmup_suitetests passed serially. These results suggest a cache state or test ordering dependency; no warmup code is changed in this PR.