huggingface / huggingface/trl

Remove triton `AnnAssign` warning filter once no supported torch resolves a triton without the fix (>= 3.8.0)

Open
#6,466 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
19.3k
Forks
3k
Avg merge
1d 20h
Merged PRs (30d)
194

Description

### What

Many trainer test modules emit a `DeprecationWarning` in CI on Python 3.14 during Triton kernel compilation:

```
triton/compiler/code_generator.py:629: DeprecationWarning: AnnAssign.__init__ missing 1 required positional argument: 'simple'. This will become an error in Python 3.15.
init_node = ast.AnnAssign(target=st_target, value=default_value, annotation=annotation)
```

It shows up across `tests/test_grpo_trainer.py`, `tests/test_kto_trainer.py`, `tests/test_dpo_trainer.py`, `tests/test_rloo_trainer.py`, `tests/test_sft_trainer.py`, and `tests/test_utils.py`.

### Root cause

The warning originates in Triton, not TRL. In `visit_FunctionDef`, Triton builds an `ast.AnnAssign` node without the required `simple` field when a `@triton.jit` kernel argument has both an annotation and a default value. TRL only triggers it indirectly, by compiling Triton kernels during tests; there is nothing actionable on the TRL side.

### Upstream status

Reported upstream: https://github.com/triton-lang/triton/issues/10981

**Not fixed yet** — Triton `main` (3.8.0 dev, latest release v3.7.1) still constructs the node without `simple`. Note this is currently only a `DeprecationWarning`, but it **will become a hard error on Python 3.15**, which the warning filter will not suppress.

### Workaround in place

We suppress the warning via `filterwarnings` in `pyproject.toml`:

```toml
"ignore:AnnAssign.__init__ missing 1 required positional argument:DeprecationWarning",
```

### Action item

- [ ] Remove the `filterwarnings` entry once every supported `torch` resolves a triton containing #10986, confirmed by a warning-free Python 3.14 CI run.
- [ ] **Separate, harder gate: do not conflate with the item above:** before adding Python 3.15 to the CI matrix, triton must actually be upgraded past #10986. On 3.15 the `DeprecationWarning` becomes a hard error, which no `filterwarnings` entry can suppress.

The second item is the reason this issue should not be closed by a filter-removal PR alone: the filter and the 3.15 blocker have independent triggers.

Contributor guide

Open the contributing guide

Research direction

Inspect the filterwarnings entry in pyproject.toml and the affected trainer test modules, then verify that every supported torch resolves a Triton containing the upstream fix and that Python 3.14 CI is warning-free. Done means removing the filter only after that verification; Python 3.15 remains blocked until Triton is upgraded past the fix.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
ci-cd, testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.