Skip to content

[FEA]: Random Number Generation #17

Open

Description

@tomasruizt

Is this a new feature, an improvement, or a change to existing functionality?

New Feature

How would you describe the priority of this feature request?

Critical (currently preventing usage)

Please provide a clear description of problem this feature solves

I searched in the documentation for random number generation functions but have not found any so far.

As a reference, see Triton's API: https://triton-lang.org/main/python-api/triton.language.html#random-number-generation

Feature Description

One usage example is to create noise shaped with the size of the tiles. E.g for gumbel-max sampling.

Describe your ideal solution

The Triton API is a good starting point.

Describe any alternatives you have considered

No response

Additional context

No response

Contributing Guidelines

  • I agree to follow cuTile Python's contributing guidelines
  • I have searched the open feature requests and have found no duplicates for this feature request

Activity

  1. changed the title [-][FEA]: random functions[/-] [+][FEA]: Random Number Generation[/+] on Dec 10, 2025
  2. HiralThadeshwar31 commented on Dec 10, 2025

    @HiralThadeshwar31

    @tomasruizt Could you assign me this issue?
    Thanks,
    Hiral

  3. tomasruizt commented on Dec 10, 2025

    @tomasruizt
    Author

    I don't own the repository and I don't have the authority to assign issues exclusively to people. @HiralThadeshwar31

  4. haijieg commented on Dec 10, 2025

    @haijieg
    Collaborator

    @tomasruizt thank you for your interest. This feature will requires CUDA TileIR support. Please stay in tuned.

  5. added
    dep: cuda-tileirDepend on a feature or bug fix in cuda-tileir and tileiras compiler
    on Dec 10, 2025
  6. ZhangZhiPku commented on Dec 19, 2025

    @ZhangZhiPku

    I don't own the repository and I don't have the authority to assign issues exclusively to people. @HiralThadeshwar31

    following code would serve as an alternative way:

    import torch
    import cuda.tile as ct
    
    @ct.function
    def tile_rnd(seed: ct.Tile) -> ct.Tile:
        return seed * 1103515245 + 12345
    
    @ct.kernel
    def device_rnd(rnd: ct.Tile, tile_size: ct.Constant):
        block_idx = ct.bid(0)
        seed = ct.arange(tile_size, dtype=ct.int32) + block_idx * tile_size
        ct.store(rnd, (block_idx, ), tile_rnd(seed))
    
    
    n, tile_size = 2048, 512
    num_blocks = (n // tile_size, )
    out = torch.empty(size=[n], device="cuda", dtype=torch.int)
    
    ct.launch(
        torch.cuda.current_stream(), num_blocks, 
        device_rnd, (out, tile_size)
    )
    
    print(out)
  7. tomasruizt commented on Dec 23, 2025

    @tomasruizt
    Author

    @haijieg now that Tile IR is announced, do you have a rough idea what building blocks / changes are needed to add the functions of the random API?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    dep: cuda-tileirDepend on a feature or bug fix in cuda-tileir and tileiras compilerfeature request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions