Skip to content

fix(easy/rainbow-table): align hash helpers with uint32 iterative semantics#237

Merged
kunal-mansukhani merged 1 commit intoAlphaGPU:mainfrom
agicy:main
Apr 19, 2026
Merged

fix(easy/rainbow-table): align hash helpers with uint32 iterative semantics#237
kunal-mansukhani merged 1 commit intoAlphaGPU:mainfrom
agicy:main

Conversation

@agicy
Copy link
Copy Markdown
Contributor

@agicy agicy commented Apr 5, 2026

Summary

Resolves #214.

The Rainbow Table challenge requires R rounds of iterative hashing, meaning the output of one round feeds directly into the next. Several starter templates previously declared their fnv1a_hash helpers with signed integers or performed internal type casting, creating an inconsistent internal state.

This PR ensures the hash helpers consistently operate on unsigned 32-bit integers, leaving initial type normalization to the caller.

Changes

  • CUDA: Changed fnv1a_hash(int input) to unsigned int. Used 0xFFu.
  • Mojo: Changed fnv1a_hash(input: Int32) to UInt32.
  • JAX / CuTe: Removed internal type casting (astype / cute.Uint32) from the helper body. Added Python type hints to CuTe.

(Note: PyTorch uses int64 to bypass missing uint32 bitwise op support in the framework. Triton remains untyped per Triton DSL conventions. Both are left unchanged.)

Copy link
Copy Markdown
Contributor

@kunal-mansukhani kunal-mansukhani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

…tive semantics

The FNV-1a hash is applied iteratively R times, so the helper's input and
output must be consistently typed as unsigned 32-bit integers.

- CUDA: change `fnv1a_hash` input to `unsigned int` and mask to `0xFFu`
- Mojo: change `fnv1a_hash` input/mask to `UInt32`
- JAX/CuTe: remove internal casting so the helper expects normalized state
- PyTorch/Triton: left unchanged due to framework specific constraints

Resolves AlphaGPU#214
@kunal-mansukhani kunal-mansukhani merged commit 269e7a0 into AlphaGPU:main Apr 19, 2026
4 checks passed
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.

[Easy][Rainbow Table] input and output's type mismatch

2 participants