MoonshotAI / MoonshotAI/FlashKDA
Centralize CHUNK and D constants as single source of truth
Nobody has claimed this yet.
- Dominant language
- Cuda
- Stars
- 1.3k
- Forks
- 122
- PR merge metrics
- No merged PRs in 30d
Description
Problem
CHUNK=16 and D=128 appear as magic numbers in multiple locations:
csrc/flash_kda.cpp—static_assertand workspace size calculationcsrc/smxx/fwd_kernel1.cuh— kernel constantscsrc/smxx/fwd_kernel2.cuh— kernel constantstests/torch_ref.py— reference implementationtests/test_fwd.py— test parametersdocs/20260420-flashkda-v1-deep-dive.md— documentation
There is no single source of truth. If someone wanted to support D=64 or D=256, they'd need to change dozens of locations.
Recommendation
Define CHUNK and D as compile-time constants in one place (e.g., setup.py as compiler defines, or a shared header), and reference them everywhere else. Add a test that verifies the error message when D != 128.
Impact
Extensibility. Makes it possible to support different D values without a multi-file hunt for magic numbers.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the constant definitions and uses in csrc/flash_kda.cpp, csrc/smxx/fwd_kernel1.cuh, csrc/smxx/fwd_kernel2.cuh, tests/torch_ref.py, tests/test_fwd.py, and docs/20260420-flashkda-v1-deep-dive.md. Choose a shared compile-time source, update the listed references, and add a test covering the D != 128 error message. Done means the constants are defined once and the affected tests pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- build-system, performance, testing
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100