Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
a32acfe
feat(jit): add explicit module registration
kacper-kleczewski Sep 28, 2026
ba9e603
fix(jit): harden registration cleanup and report ownership
kacper-kleczewski Oct 5, 2026
e7099a6
fix(jit): preserve registrations and defer session binding
kacper-kleczewski Oct 5, 2026
856faf5
fix(jit): block registration after incomplete module cleanup
kacper-kleczewski Oct 5, 2026
be71c05
chore(jit): merge latest main into registration branch
kacper-kleczewski Oct 6, 2026
4baad0f
fix(jit): preserve forward when hook setup fails
kacper-kleczewski Oct 6, 2026
63eb1d0
fix(jit): configure deferred tests before model creation
kacper-kleczewski Oct 8, 2026
5ee8f93
chore(jit): merge latest main into registration branch
kacper-kleczewski Oct 9, 2026
fcbedde
docs(jit): clarify explicit registration and restore overview
kacper-kleczewski Oct 12, 2026
1ae97f2
refactor(jit)!: simplify registration to one worker lifetime
kacper-kleczewski Oct 13, 2026
6f7a65e
fix(jit): preserve prepared hooks during forwarding
kacper-kleczewski Oct 13, 2026
33d5e2f
test(jit): assert compiled prepared-unit wrappers
kacper-kleczewski Oct 13, 2026
314934e
fix(jit): preserve forwards across tuning finalization
kacper-kleczewski Oct 13, 2026
113a9a5
test(jit): narrow uncalled child wrapper type
kacper-kleczewski Oct 13, 2026
3b6c7ff
fix(tests): preserve isolated pytest reports and fixture cleanup
kacper-kleczewski Oct 13, 2026
7e449d2
fix(tests): avoid uninitialized parent report hooks
kacper-kleczewski Oct 13, 2026
cef4deb
test(dataloader): build the padding tokenizer locally
kacper-kleczewski Oct 13, 2026
be01fec
test(jit): check constructor ownership around compilation
kacper-kleczewski Oct 14, 2026
e9659c6
ci: allow time for isolated gpu tests
kacper-kleczewski Oct 15, 2026
1e37ac1
chore(jit): merge main into registration branch
kacper-kleczewski Oct 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ jobs:
${{ !cancelled() && needs.wheel.result == 'success' &&
(needs.pytorch-image.result == 'success' || needs.pytorch-image.result == 'skipped') }}
runs-on: prod-aitune-tester-rtx-pro-4500-v1
timeout-minutes: 40
# Fresh-process JIT cases include native backend import time for every test.
timeout-minutes: 60
permissions:
contents: read
packages: read
Expand Down
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Key fixtures in `conftest.py` (all autouse unless noted):

- `module_registry_cleanup` — clears the global module registry after each test.
- `aitune_cache_dir` — isolates the AITune cache in a temporary path per test.
- `jit_cleanup` — calls `jit_reset()` before and after each test.
- JIT-mutating tests and JIT doctests run in fresh Python processes; there is no production JIT reset API.
- `aitune_logging_setup` — initializes logging; set `AITUNE_TESTS_LOG_LEVEL=DEBUG`
for verbose test logs.
- `torch_device` (not autouse) — selects the test device; override with
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ title: "Changelog"

## 0.7.0 (unreleased)

- feat: explicitly register existing module instances as targeted JIT tuning heads
- breaking change: JIT registration is one complete batch per worker; remove JIT reset and registration rollback
- feat: support tuning existing ONNX models with ONNX Runtime and TensorRT
- feat: expose portable deployment artifacts for ONNX Runtime, TensorRT, and TorchInductor AOT models, including required additional files and representative inputs
- feat: publish tuned artifacts or existing ONNX, TensorRT, and PT2 files as Triton model repositories with backend-specific configurations
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,20 @@ A new process starts tuning again; use the explicit workflow below for saved art
See the [JIT guide](https://docs.nvidia.com/aitune/guides/just-in-time-tuning/) for configuration and deferred tuning
for pipelines.

If another library or runtime has already constructed the modules you want to tune, register the final instances
directly:

```python
from aitune.torch import register_for_jit_tuning

registration = register_for_jit_tuning([pipe.unet])
```

Each registered module is an independent top-level JIT target. Do not combine explicit registration with automatic
constructor interception in the same live JIT session. The returned registration exposes live inspection reports,
state counts, and an `all_tuned` snapshot. See the
[JIT tuning guide](docs/guides/jit_tuning.md#registering-existing-modules) for the complete contract.

### Ahead-of-time (AOT): prepare a reusable tuning artifact

Ahead-of-time tuning prepares your model for deployment with a consistent flow:
Expand Down
3 changes: 3 additions & 0 deletions aitune/torch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from aitune.torch.jit.config import config as jit_config
from aitune.torch.jit.patched_module import PatchedModule
from aitune.torch.jit.patcher import patch_for_jit_tuning
from aitune.torch.jit.registration import JITRegistration, register_for_jit_tuning

__all__ = [
"aitune_cache_dir",
Expand Down Expand Up @@ -58,6 +59,8 @@
"LocalTorchStorage",
"DataLoaderFactory",
"patch_for_jit_tuning",
"register_for_jit_tuning",
"JITRegistration",
]

if config.enable_diffusers_integration:
Expand Down
13 changes: 6 additions & 7 deletions aitune/torch/jit/inspect_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ def _forward_init(self, wrapped, instance, args, kwargs):
This method is called when the module is first called.
It initializes the module and sets the state to INSPECT.
"""
from aitune.torch.jit.patcher import Patcher # avoid circular deps

Patcher._check_mode()
params = count_parameters(self.__wrapped__)
self._name += f" 📊{params}"
if self._should_be_skipped():
Expand Down Expand Up @@ -123,6 +126,9 @@ def _forward_init(self, wrapped, instance, args, kwargs):

def _forward_inspect(self, wrapped, instance, args, kwargs):
"""Forward call for the inspect time."""
from aitune.torch.jit.patcher import Patcher # avoid circular deps

Patcher._check_mode()
self._call_count += 1
self._gather_args_kwargs(args, kwargs)
self._restore_original_forward()
Expand Down Expand Up @@ -250,13 +256,6 @@ def print_history(sink=print):
"""Prints history to the sink."""
sink("\n".join(InspectModule.history))

@staticmethod
def reset():
"""Reset PatchedModule state."""
InspectModule.history.clear()
InspectModule.heads.clear()
InspectModule.stack.clear()

@staticmethod
def save_report(path: str | Path, model_name: str = "Model"):
"""Save module hierarchy to interactive HTML with folding/unfolding capabilities.
Expand Down
Loading
Loading