MoonshotAI / MoonshotAI/FlashKDA

Centralize CHUNK and D constants as single source of truth

Open
#20 0 comments 0 reactions 0 assignees View on GitHub

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.cppstatic_assert and workspace size calculation
  • csrc/smxx/fwd_kernel1.cuh — kernel constants
  • csrc/smxx/fwd_kernel2.cuh — kernel constants
  • tests/torch_ref.py — reference implementation
  • tests/test_fwd.py — test parameters
  • docs/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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.