Lightning-AI / Lightning-AI/lightning-thunder
__bool__ (and data dependent control flow)
Open
Nobody has claimed this yet.
program-coverage
- Dominant language
- Python
- Stars
- 1.5k
- Forks
- 121
- PR merge metrics
- No merged PRs in 30d
Description
HF BERT data-dependent control flow:
if self.config.pad_token_id in input_ids[:, [-1, 0]]:
4348 warn_string = (
4349 "We strongly recommend passing in an `attention_mask` since your input_ids may be padded. See "
4350 "https://huggingface.co/docs/transformers/troubleshooting"
4351 "#incorrect-output-when-padding-tokens-arent-masked."
4352 )
4354 # If the pad token is equal to either BOS, EOS, or SEP, we do not know whether the user should use an
4355 # attention_mask or not. In this case, we should still show a warning because this is a rare case.
input_ids is a tensor, that ultimately makes us fail on __bool__ for tensors.
Repro:
import torch, thunder, transformers
m = transformers.BertForSequenceClassification(transformers.BertConfig())
jm = thunder.jit(m)
a = torch.randint(1, 20, (1, 25))
jm(a)
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 running the provided Python repro with PyTorch, Thunder, and the BERT model, then trace the tensor bool failure during data-dependent control flow. Done means the repro compiles and invokes BertForSequenceClassification without failing on tensor truth-value evaluation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100