[Refactor] Re-export History from tensordict.llm#3862
Draft
vmoens wants to merge 2 commits into
Draft
Conversation
History, ContentBase, add_chat_template and the base chat templates moved to tensordict.llm (pytorch/tensordict#1724), which is now their canonical home. torchrl/data/llm/history.py becomes a backward-compatibility shim re-exporting the public symbols and the private template registries, so all existing torchrl.data.llm.history import paths keep working and class identity is shared with tensordict.llm. No warning is emitted on import for now, as the path is used widely internally; new code should import from tensordict.llm directly. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/3862
Note: Links to docs will display an error until the docs builds have been completed. ❌ 41 New Failures, 15 Unclassified FailuresAs of commit 5021c1c with merge base 393042c ( NEW FAILURES - The following jobs have failed:
UNCLASSIFIED FAILURES - DrCI could not classify the following jobs because the workflow did not run on the merge base. The failures may be pre-existing on trunk or introduced by this PR:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
tensordict cannot depend on torchrl's spec classes, so the spec side of the History move stays here: - history_default_spec() free function in the re-export shim is the canonical way to build a Composite spec for History objects; exported from torchrl.data.llm. - History.default_spec is attached to the class in the shim so the established classmethod API (mirroring ChatHistory/Text/Tokens) keeps working unchanged for existing callers. - Internal call sites (mlgym, policies.common) migrate to the free function; test_history_spec covers both paths. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
History,ContentBase,add_chat_templateand the base chat templates moved totensordict.llm(pytorch/tensordict#1724), which is now their canonical home. This PR turnstorchrl/data/llm/history.pyinto a backward-compatibility shim that re-exports the public symbols plus the private template registries (_CHAT_TEMPLATES,_CUSTOM_INVERSE_PARSERS,_CUSTOM_MODEL_FAMILY_KEYWORDS) and mask helpers, so:torchrl.data.llm.history/torchrl.data.llm/torchrl.dataimport paths keep working;torchrl.data.llm.History is tensordict.llm.History);History.default_spec()keeps working unchanged: the tensordict implementation lazily imports theComposite/NonTensorspecs from torchrl.No deprecation warning is emitted for now — the path has many internal callers; new code should import from
tensordict.llmdirectly.Dependencies
Draft until pytorch/tensordict#1724 merges and is available in the tensordict build used by CI. At release time the tensordict floor in
pyproject.tomlshould be bumped to the first version that shipstensordict.llm.Tests
test/llm/test_data.py::TestHistoryexercises the shim unchanged; verified locally that the import paths resolve to the tensordict classes and the History construction/completion/template tests pass.🤖 Generated with Claude Code