pytorch - ✅(Solved) Fix torch.compile streams support in AOTI [1 pull requests, 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
pytorch/pytorch#178132Fetched 2026-04-08 01:16:28
View on GitHub
Comments
0
Participants
1
Timeline
44
Reactions
0
Author
Participants
Assignees
Timeline (top)
mentioned ×18subscribed ×18labeled ×6assigned ×1

Fix Action

Fixed

PR fix notes

PR #177694: [user-streams] read streams from dynamo-populated lookup table

Description (problem / solution / changelog)

In this PR, instead of generating streams based on the indices at compile time, we use the indices that dynamo generates and retrieve the actual stream objects from the dynamo-populated lookup table.

Stack from ghstack (oldest at bottom):

  • #177718
  • -> #177694

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo

Changed files

  • test/inductor/test_user_streams.py (modified, +62/-7)
  • torch/_inductor/codegen/wrapper.py (modified, +18/-5)
  • torch/_inductor/scheduler.py (modified, +8/-1)
RAW_BUFFERClick to expand / collapse

🚀 The feature, motivation and pitch

Currently today the streams impl relies on a dynamo-populated lookup table of python objects to track streams and events passed by the user - we may need to use opaque objects or an equivalent C++ construct to enable streams support in AOTI

Alternatives

No response

Additional context

No response

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo

extent analysis

Fix Plan

To enable streams support in AOTI, we need to replace the Python objects lookup table with an equivalent C++ construct. We can use opaque objects or a similar approach.

Steps to Implement the Fix

  • Create a C++ struct to hold the stream and event data
  • Use a std::unordered_map to store the stream and event data
  • Implement functions to add, remove, and retrieve stream and event data

Example Code

// stream_data.h
struct StreamData {
    std::string streamName;
    std::string eventData;
};

class StreamManager {
public:
    void addStream(const std::string& streamName, const std::string& eventData);
    void removeStream(const std::string& streamName);
    StreamData getStream(const std::string& streamName);

private:
    std::unordered_map<std::string, StreamData> streamMap;
};

// stream_data.cpp
void StreamManager::addStream(const std::string& streamName, const std::string& eventData) {
    StreamData data;
    data.streamName = streamName;
    data.eventData = eventData;
    streamMap[streamName] = data;
}

void StreamManager::removeStream(const std::string& streamName) {
    streamMap.erase(streamName);
}

StreamData StreamManager::getStream(const std::string& streamName) {
    auto it = streamMap.find(streamName);
    if (it != streamMap.end()) {
        return it->second;
    }
    // Return an empty StreamData object if not found
    return StreamData();
}

Verification

To verify the fix, create a test case that adds, removes, and retrieves stream and event data using the StreamManager class. Check that the data is correctly stored and retrieved.

Extra Tips

  • Use smart pointers to manage memory and avoid memory leaks.
  • Consider using a more robust data structure, such as a database, to store the stream and event data.
  • Ensure that the StreamManager class is thread-safe if it will be accessed by multiple threads.

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