Skip to content

fix(cutile-rs): instantiate pointer-bound type parameters as pointers - #1657

Open
veljjanoski wants to merge 1 commit into
NVIDIA:mainfrom
veljjanoski:fix/pointer-tile-method-chain
Open

veljjanoski wants to merge 1 commit into
NVIDIA:mainfrom
veljjanoski:fix/pointer-tile-method-chain

Conversation

@veljjanoski

Copy link
Copy Markdown

Summary

A PointerTile method result with no expected type, such as the receiver of another method call or a call argument, failed to compile with "return type is missing a compiled tile type" (#1596). Its type is derived inside the inlined method from PointerTile<P, R>, with P bound to * mut f32. TypeInstanceStructuredType::instantiate treated a bound type parameter as an element type, like T, so the pointer dropped out and the Tile IR type became !cuda_tile.tile<1>, which doesn't parse. A literal *mut f32 type argument already took the Type::Ptr branch and worked. This change instantiates a type parameter bound to a pointer type as a pointer, the same way.

Fixes #1596.

Changes

  • cutile-compiler generics.rs: TypeInstanceStructuredType::instantiate gets a new arm before the element-type arm. A type parameter bound to a pointer type goes through TypeInstancePtrType::instantiate, as a literal pointer type argument does. If the binding is not a pointer, or does not instantiate as one, the existing element-type arm handles it as before. The change is a pure addition; no existing line changes.
  • New compile-only test compile_ptr_tile_method_chain in cutile/tests/basics_and_inlining.rs. It covers the issue's reshape().broadcast().offset_tile() chain with a load_ptr_tko through the result, an offset().reshape() chain, and reshape_ptr(ptr_tile.offset(1), ..). It checks the pointer tile types in the IR. On main it fails with the reported error.

An alternative fix in inline_method_call gave the method body the caller's typeck type, as a let initializer does. It fixed the same cases with identical IR, but it changes the expected type of every method call that has none, so I kept the fix at the type instantiation.

Testing

Run on an RTX 3090 (sm_86), CUDA 13.3, WSL2 Ubuntu 24.04, Rust 1.98.0 (the cutile-rs pin).

I compiled 10 kernels on main and with the fix. On main these failed: the issue's chain, reshape().broadcast(), broadcast().offset_tile(), offset().reshape(), reshape().offset() and reshape_ptr(r0.offset(1), ..). With the fix all of them compile. The 4 kernels that already compiled on main (the step-by-step form, an unannotated let, a Tile chain and a helper generic over P: Pointer) give byte-identical IR before and after.

The issue's repro kernel now gives the same IR as its step-by-step form, apart from the kernel name:

%11 = reshape %0 : tile<ptr<f32>> -> tile<1xptr<f32>>
%14 = broadcast %11 : tile<1xptr<f32>> -> tile<128xptr<f32>>
%16 = offset %14, %9 : tile<128xptr<f32>>, tile<128xi32> -> tile<128xptr<f32>>
%17, %18 = load_ptr_tko weak %16 : tile<128xptr<f32>> -> tile<128xf32>, token
  • cutile-rs/scripts/run_cpu_tests.sh passes
  • run_gpu_tests.sh, run_examples.sh and test_benchmarks.sh (the rest of run_all.sh): all pass except dtype_float_ops' two fp8 tests, which need sm_90 ("F8E4M3FN requires sm_90 or newer ... target sm_86") and fail the same way on main. 24 examples pass (4 skipped by the runner), and all 8 benchmark smoke tests pass.
  • cargo fmt -- --check and cargo clippy --workspace --exclude cuda-tile-rs --all-targets are clean (clippy's one warning is an existing one in a cutile-benchmarks bench)
  • The new test fails on main and passes with the fix

Checklist

  • All commits signed off (git commit -s)
  • SPDX headers on new source files (no new files)

AI-usage disclosure: Claude (Anthropic) was used as assistant.

Signed-off-by: Daniel Veljjanoski <danielveljanoski@gmail.com>
@veljjanoski
veljjanoski requested a review from elibol as a code owner October 26, 2026 18:21
@copy-pr-bot

copy-pr-bot Bot commented Oct 26, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

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.

[BUG]: cuTile: PointerTile method chain fails with "return type is missing a compiled tile type"

1 participant