Skip to content

feat: decode Tile bytecode into modules - #186

Open
drbh wants to merge 5 commits into
NVlabs:mainfrom
drbh:bytecode-decode
Open

drbh wants to merge 5 commits into
NVlabs:mainfrom
drbh:bytecode-decode

Conversation

@drbh

@drbh drbh commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

this pr adds the ability to decode tile bytecode into a module, this allows roundtrip compilations.

additionally this PR adds a tool cutile-translate that can be used like

cargo run --release --bin cutile-translate -- --bc-to-mlir \
  cuda-tile-rs/cuda-tile/test/Bytecode/versioning/Inputs/13.1/negi-op-13.1.tileirbc

outputs

cuda_tile.module @module {
  entry @basic() {
    %0 = constant <i32: [1, 2]> : tile<2xi32>
    %1 = negi %0 : tile<2xi32>
    %2 = negi %0 : tile<2xi32>
    return
  }
}

which matches the output of the reference tool

cuda-tile-translate -cudatilebc-to-mlir cuda-tile-rs/cuda-tile/test/Bytecode/versioning/Inputs/13.1/negi-op-13.1.tileirbc

seen here https://github.com/NVIDIA/cuda-tile/blob/e01244d89cd38e81dde50d60fbfee07ac6d7be22/test/Bytecode/versioning/versioned_op.mlir#L13

another simple example was added, does a full roundtrip and checks idempotency

cargo run -p cutile-ir --example decode_real -- \
  cuda-tile-rs/cuda-tile/test/Bytecode/versioning/Inputs/13.1/negi-op-13.1.tileirbc

this will read bytecode into a module, and recompile, then decode and recompile again and checks that the two re encodes are equal

orig 126 -> reencode 164 bytes
idempotent (reencode==reencode2): true
--- decoded module ---
cuda_tile.module @module {
  entry @basic() {
    %0 = constant <i32: [1, 2]> : tile<2xi32>
    %1 = negi %0 : tile<2xi32>
    %2 = negi %0 : tile<2xi32>
    return
  }
}

lastly added some more tests

cargo test -p cutile-ir --test bytecode_fixtures
cargo test -p cutile-ir --test per_op_roundtrip
cargo test -p cutile-ir --test bytecode_version

Signed-off-by: drbh <david.richard.holtz@gmail.com>
@copy-pr-bot

copy-pr-bot Bot commented Jul 6, 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.

@drbh drbh changed the title feat: decode bytecode roundtrips feat: decode Tile bytecode into modules Jul 6, 2026
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.

2 participants