---
title: thunder.jit
description: Just-in-time compile a callable (function or model).
canonical: 'https://lightning.ai/docs/thunder/stable/api-reference/generated/thunder.jit'
---
# thunder.jit {#thunder-jit}

### `thunder.jit(fn, /, *, langctx=None, executors=None, sharp_edges=None, cache=None, disable_torch_autograd=False, transforms=None, debug_options=None, **compile_options)` {#thunder.jit}

[\[source\]](https://github.com/Lightning-AI/lightning-thunder/blob/0.2.6/thunder/__init__.py#L313-L917)

Just-in-time compile a callable (function or model).

Note

Thunder’s support of PyTorch in-place support is experimental. The in-place support can be turned off with the kwarg of `skip_inplace_alias_updates`.

Parameters:

*   **fn** ([`Callable`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable "(in Python v3.15)")) – A [`Module`](https://docs.pytorch.org/docs/stable/generated/torch.nn.Module.html#torch.nn.Module "(in PyTorch v2.15)") or a function to compile.
    
*   **fn** ([_Callable_](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable "(in Python v3.15)")) –
    
*   **langctx** ([_Union_](https://docs.python.org/3/library/typing.html#typing.Union "(in Python v3.15)")_\[__None__,_ [_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")_,_ [_Any_](https://docs.python.org/3/library/typing.html#typing.Any "(in Python v3.15)")_,_ _LanguageContext__\]_) –
    
*   **executors** ([_Union_](https://docs.python.org/3/library/typing.html#typing.Union "(in Python v3.15)")_\[__None__,_ [_Sequence_](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence "(in Python v3.15)")_\[_[_thunder.extend.Executor_](/docs/thunder/0.2.6/extend/thunder.extend.Executor.md#thunder.extend.Executor "thunder.extend.Executor") _|_ [_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")_\]__\]_) –
    
*   **sharp\_edges** ([_Union_](https://docs.python.org/3/library/typing.html#typing.Union "(in Python v3.15)")_\[__None__,_ _SHARP\_EDGES\_OPTIONS__,_ [_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")_\]_) –
    
*   **cache** ([_Union_](https://docs.python.org/3/library/typing.html#typing.Union "(in Python v3.15)")_\[__None__,_ [_str_](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")_,_ [_CACHE\_OPTIONS_](/docs/thunder/0.2.6/common/generated/thunder.common.CACHE_OPTIONS.md#thunder.common.CACHE_OPTIONS "thunder.core.options.CACHE_OPTIONS")_\]_) –
    
*   **disable\_torch\_autograd** ([_bool_](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")) –
    
*   **transforms** ([_Optional_](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")_\[_[_list_](https://docs.python.org/3/builtins/stdtypes.html#list "(in Python v3.15)")_\[__thunder.core.transform\_common.Transform__\]__\]_) –
    
*   **debug\_options** ([_Optional_](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")_\[_[_DebugOptions_](/docs/thunder/0.2.6/api-reference/generated/thunder.DebugOptions.md#thunder.DebugOptions "thunder.core.options.DebugOptions")_\]_) –
    

Keyword Arguments:

*   **langctx** – the language context, which language / library to emulate. default: “torch” for PyTorch compatibility.
    
*   **executors** – list of executors to use. Defaults to the executors returned by [`thunder.extend.get_default_executors()`](/docs/thunder/0.2.6/extend/thunder.extend.get_default_executors.md#thunder.extend.get_default_executors "thunder.extend.get_default_executors") and always amended by [`thunder.extend.get_always_executors()`](/docs/thunder/0.2.6/extend/thunder.extend.get_always_executors.md#thunder.extend.get_always_executors "thunder.extend.get_always_executors"). You can get a list of all available executors with `thunder.get_all_executors()`. You can also pass the name of an executor that’s been registered, and it will be resolved with [`thunder.extend.get_executor()`](/docs/thunder/0.2.6/extend/thunder.extend.get_executor.md#thunder.extend.get_executor "thunder.extend.get_executor").
    
*   **sharp\_edges** – sharp edge detection action. What to do when thunder detects a construct that is likely to lead to errors. Can be `"allow"`, `"warn"`, `"error"`. Defaults to `"allow"`.
    
*   **cache** –
    
    caching mode. default: `` "constant values"` ``
    
    *   `"no caching"` - disable caching and always recompute,
        
    *   `"constant values"` - require Tensors to be of the same shape, device, dtype etc., and integers and strings to match exactly,
        
    *   `"same input"` - don’t check, but just assume that a cached function works if it exists.
        
    
*   **transforms** – optional list of transforms to be applied. It should be a list of instances of `thunder.core.transforms.Transform`. Default: `None`
    
*   **debug\_options** – optional [`thunder.DebugOptions`](/docs/thunder/0.2.6/api-reference/generated/thunder.DebugOptions.md#thunder.DebugOptions "thunder.DebugOptions") instance. See the doc string of [`DebugOptions`](/docs/thunder/0.2.6/api-reference/generated/thunder.DebugOptions.md#thunder.DebugOptions "thunder.DebugOptions") for supported debug options. Default: `None`
    

Return type:

[`Callable`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable "(in Python v3.15)")

---

**Navigation**

- Parent: [Generated](/docs/thunder/0.2.6/api-reference/generated.md)
