patrick-kidger / patrick-kidger/jaxtyping
will runtime type checking go beyond function parameters and return type?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.9k
- Forks
- 96
- PR merge metrics
- No merged PRs in 30d
Description
Great project, helps me understand DL code a lot.
I used it like this:
Patch_embed = Float32[torch.Tensor, f"B {PATCH_H} {PATCH_W} {PATCH_EMBED_DIM}"]
Mlp_mid = Float32[torch.Tensor, f"B {PATCH_H} {PATCH_W} {MLP_HIDDEN}"]
...
@jaxtyped(typechecker=beartype)
def forward(self, x: Patch_embed) -> Patch_embed:
x: Mlp_mid = self.act(self.lin1(x))
return self.lin2(x)
but turns out, it doesn't do runtime type check on this x: Mlp_mid = self.act(self.lin1(x)) line. And this makes me feel insecure.
So, my question is, will this feature be added in the future? Or is it in confilct with some design intention?
BTW, I mainly use it when I am trying to understand others code. But can I include it in production? How much does it slow down the training and inference?
Contributor guide
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
The report names @jaxtyped(typechecker=beartype), local variable annotations, and PyTorch examples, but no source file or test. Start by reviewing the runtime-checking behavior around that decorator and local assignments. Done would require a clear decision on whether local annotations should be checked, plus documented production overhead and design intent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100