transformers - 💡(How to fix) Fix A nice UX for generating dynamic tensors that break torch.compile/torch.export [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
huggingface/transformers#45571Fetched 2026-04-23 07:22:59
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
1
Participants
Timeline (top)
subscribed ×2labeled ×1
RAW_BUFFERClick to expand / collapse

Feature request

We have a couple tensors whose construction is highly dynamic and can't be captured while tracing (cu_seqlens, vision(image/video)_cu_seqlens, ... , vision(image/video)_position_ids, ...). I'm opening this issue to track what we are gonna do about them. The two options are either using the processor since that's where we have the most of dynamism / per-sample processing loops. or unifying the collator API (processor - > collator -> inference) as part of the default path.

Motivation

see #45396

Your contribution

can implement it :)

extent analysis

TL;DR

Implementing a dynamic tensor construction solution, either by utilizing the processor for per-sample processing loops or unifying the collator API, is likely the most effective fix.

Guidance

  • Investigate the feasibility of using the processor to handle dynamic tensor construction, considering its existing role in per-sample processing loops.
  • Explore unifying the collator API as a potential solution, examining how it could be integrated into the default path (processor -> collator -> inference).
  • Review the related issue #45396 for additional context and motivation behind addressing dynamic tensor construction.
  • Consider the trade-offs between the two potential solutions, weighing factors such as complexity, performance, and maintainability.

Notes

The ideal solution may depend on specific requirements and constraints not fully detailed in the issue, so careful evaluation of both options is necessary.

Recommendation

Apply workaround: Utilize the processor for dynamic tensor construction, as it appears to be the most direct and potentially efficient solution, given its existing involvement in per-sample processing loops.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING