MoonshotAI / MoonshotAI/MoonEP
Replace 30+ key context dict with typed dataclass
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 134
- PR merge metrics
- No merged PRs in 30d
Description
Problem
The api.py context dictionary has 30+ keys passed around as a plain dict. This is error-prone:
- No type hints → no IDE autocompletion
- No validation → typos in key names silently fail
- No documentation → each consumer has to guess what keys exist
Example
# Current — plain dict with 30+ keys
ctx = {
"rank": 0, "num_ranks": 16, "E": 896, "B": 16,
"H": 128, "H_prime": 128, "K": 16,
# ... 20+ more
}
# Passed to every function; misspelling a key = silent KeyError at runtime
# Suggested — typed dataclass
@dataclass
class MoonEPContext:
rank: int
num_ranks: int
E: int # total experts
B: int # local prefetch slots
H: int # hidden dim
H_prime: int # expert FFN dim
K: int # top-k
# ...
Impact
- Developer experience: IDE support, autocompletion, type checking
- Maintainability: clear contract of what the context contains
- Debugging:
ctx.Hvsctx["H"]— the former fails at construction time if missing, the latter fails deep in a kernel launch
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 in api.py by locating where the 30+ key context dictionary is constructed and passed to consumers, then inventory the keys and their uses. Define the typed context contract from that usage and update the affected consumers. Done means the context is no longer passed as a plain dict and its fields provide the stated typing and validation benefits.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend-api-design
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100