Repository navigation
fix: avoid runtime compilation in regression target encoding (ENG-1093) #1338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jmkuebler
merged 4 commits into
main
from
jonas/eng-1093-fix-nightly-container-accuracy-failure-missing-c-compiler
Oct 1, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
612b9d9
fix: avoid eager Triton compilation in regression target encoding
jmkuebler fd12fe7
test: reject target encoder compilation in a fresh process
jmkuebler 1932834
docs: add regression target encoding changelog
jmkuebler b66bb3b
test: trim target projection coverage and gate eager Triton check
jmkuebler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Avoid a runtime C compiler requirement in batched v3 and v3.5 regression target encoding on recent PyTorch versions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
tests/test_architectures/test_regression_target_projection.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| # Copyright (c) Prior Labs GmbH 2026. | ||
|
|
||
| """Regression target projections must not require a runtime compiler.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import os | ||
| import subprocess | ||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| import pytest | ||
| import torch | ||
| from torch.torch_version import TorchVersion | ||
|
|
||
| from tests.test_architectures.test_tabpfn_v3 import _get_regression_model | ||
| from tests.test_architectures.test_tabpfn_v3_5 import _get_model | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("version", ["v3", "v3.5"]) | ||
| def test_regression_target_projection(version: str) -> None: | ||
| device = "cuda" if torch.cuda.is_available() else "cpu" | ||
| model = (_get_regression_model() if version == "v3" else _get_model()).to(device) | ||
| targets = torch.randn(1002, 8, device=device).T.requires_grad_() | ||
| kwargs = {} if version == "v3" else {"task_type": "regression"} | ||
| for stage in ("col", "icl"): | ||
| project = getattr(model, f"_embed_{stage}_y") | ||
| expected = torch.cat([project(row[None], **kwargs) for row in targets]) | ||
| expected_grad = torch.autograd.grad(expected.square().sum(), targets)[0] | ||
| actual = project(targets, **kwargs) | ||
| actual_grad = torch.autograd.grad(actual.square().sum(), targets)[0] | ||
| torch.testing.assert_close(actual, expected) | ||
| torch.testing.assert_close(actual_grad, expected_grad) | ||
|
|
||
|
|
||
| @pytest.mark.skipif(not torch.cuda.is_available(), reason="CUDA unavailable") | ||
| @pytest.mark.skipif( | ||
| TorchVersion(torch.__version__) < TorchVersion("2.13"), | ||
| reason="Eager Triton outer-product dispatch requires Torch 2.13+", | ||
| ) | ||
| def test_regression_target_projection_without_compiler(tmp_path: Path) -> None: | ||
| result = subprocess.run( | ||
| [ | ||
| sys.executable, | ||
| "-m", | ||
| "tests.test_architectures.test_regression_target_projection", | ||
| ], | ||
| cwd=Path(__file__).resolve().parents[2], | ||
| env={**os.environ, "TRITON_CACHE_DIR": str(tmp_path)}, | ||
| capture_output=True, | ||
| text=True, | ||
| check=False, | ||
| ) | ||
| assert result.returncode == 0, result.stdout + result.stderr | ||
|
|
||
|
|
||
| def _check_without_compiler() -> None: | ||
| from triton.runtime import build # noqa: PLC0415 | ||
|
|
||
| def reject_compilation(*_args: object, **_kwargs: object) -> None: | ||
| raise AssertionError("Regression target encoding requested a C compiler") | ||
|
|
||
| build._build = reject_compilation | ||
| targets = torch.randn(1002, 8, device="cuda").T | ||
| with torch.inference_mode(), torch.autocast("cuda", dtype=torch.bfloat16): | ||
| for version in ("v3", "v3.5"): | ||
| model = ( | ||
| _get_regression_model() if version == "v3" else _get_model() | ||
| ).cuda() | ||
| kwargs = {} if version == "v3" else {"task_type": "regression"} | ||
| for stage in ("col", "icl"): | ||
| getattr(model, f"_embed_{stage}_y")(targets, **kwargs) | ||
| torch.cuda.synchronize() | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| _check_without_compiler() | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.