Lightning-AI / Lightning-AI/lightning-thunder
InterpreterError: Encountered exception TypeError: missing a required argument: 'value' while tracing
- Dominant language
- Python
- Stars
- 1.5k
- Forks
- 121
- PR merge metrics
- No merged PRs in 30d
Description
## 🐛 Bug
A minimal repro for the fixed issue (https://github.com/Lightning-AI/lightning-thunder/issues/461#issuecomment-2178023346) doesn't work anymore with a failure in Thunder's interpreter:
```py
import transformers
import torch
import thunder
def fn(x):
return transformers.modeling_outputs.BaseModelOutput(x)
jfn = thunder.jit(fn)
x = torch.randn(5, 5)
print(jfn(x))
```
```py
TypeError: missing a required argument: 'value'
The above exception was the direct cause of the following exception:
InterpreterError Traceback (most recent call last)
Cell In[1], line 12
8 jfn = thunder.jit(fn)
10 x = torch.randn(5, 5)
---> 12 print(jfn(x))
File ~/dev/lightning-thunder/thunder/__init__.py:669, in jit..fn_(*args, **kwargs)
666 cs.last_trace_host_start = time.perf_counter_ns()
667 cs.calls += 1
--> 669 cache_entry, inps, pro_to_epi = get_computation_and_inputs(*args, **kwargs)
670 cs.last_trace_host_execution_start = time.perf_counter_ns()
672 result = cache_entry.computation_fn(*inps)
File ~/dev/lightning-thunder/thunder/__init__.py:223, in _with_cache_info_ctx..cache_info_wrapper(*args, **kwargs)
221 tok = _cache_info_ctx.set({})
222 try:
--> 223 res = fn(*args, **kwargs)
224 finally:
225 _cache_info_ctx.reset(tok)
File ~/dev/lightning-thunder/thunder/__init__.py:503, in jit..get_computation_and_inputs(*args, **kwargs)
501 prologue_trc: TraceCtx
502 computation_trc: TraceCtx
--> 503 jit_results: TraceResults = interpreter(
504 fn, args, kwargs, record_history=record_history, sharp_edges=cd.sharp_edges
505 )
506 prologue_trc = jit_results.prologue_trace
507 computation_trc = jit_results.computation_trace
File ~/dev/lightning-thunder/thunder/__init__.py:211, in _general_frontend(fn, args, kwargs, record_history, sharp_edges)
202 def _general_frontend(
203 fn: Callable,
204 args: tuple[Any, ...],
(...)
209 sharp_edges: SHARP_EDGES_OPTIONS,
210 ) -> TraceResults:
--> 211 return thunder_general_jit(fn, args, kwargs, sharp_edges=sharp_edges, record_history=record_history)
File ~/dev/lightning-thunder/thunder/core/jit_ext.py:1743, in thunder_general_jit(fn, args, kwargs, record_history, sharp_edges)
1741 with general_jit_ctx(ctx):
1742 with tracectx(computation_trace):
-> 1743 result = jfn(*args, **kwargs)
1744 prims.python_return(result)
1745 computation_trace.set_current_source_location(None, None)
File ~/dev/lightning-thunder/thunder/core/interpreter.py:6686, in interpret..fn_(*args, **kwargs)
6682 traceback_str = os.linesep.join(f.format_with_source() for f in runtimectx.frame_stack)
6683 msg = (
6684 f"Encountered exception {type(e).__name__}: {e} while tracing {fn}:{os.linesep}" f"{traceback_str}"
6685 )
-> 6686 raise InterpreterError(msg) from e
6688 # NOTE: Wrapped functions are valid to assign new attributes to.
6689 fn_._last_interpreter_log = runtimectx.interp_log # type: ignore
InterpreterError: Encountered exception TypeError: missing a required argument: 'value' while tracing :
```
I used transformers-4.35.0.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by running the minimal transformers 4.35.0 reproduction with thunder.jit(fn), then inspect thunder/core/interpreter.py around the InterpreterError wrapper and the tracing path in thunder/core/jit_ext.py. Trace why BaseModelOutput(x) reaches the missing 'value' argument and add a regression test showing the example completes without InterpreterError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100