Skip to content

[rocjitsu] Add Python execution sessions and startup activation - #13748

Open
kuhar wants to merge 1 commit into
developfrom
users/kuhar/python-execution-api
Open

kuhar wants to merge 1 commit into
developfrom
users/kuhar/python-execution-api

Conversation

@kuhar

@kuhar kuhar commented Oct 19, 2026

Copy link
Copy Markdown
Member

Run upstream ROCm PyTorch and Triton on simulated AMD GPUs from Python, including existing Colab notebooks. Support two execution styles.

Use run for a single call or Session to retain imports and runtime state across calls in a subprocess. Preload the native interposer in the worker without restarting the notebook or changing its GPU runtime:

import rocjitsu

def add_one():
    import torch
    return (torch.arange(8, device="cuda") + 1).cpu()

result = rocjitsu.run(add_one, config=rocjitsu.config.gfx1250_mi455x)

For simulation in the main process, start with python -m rocjitsu app.py to preload the interposer before Python starts. In app.py, call enable before GPU discovery or framework imports:

import rocjitsu
rocjitsu.enable(rocjitsu.config.gfx1250_mi455x)

import torch
result = (torch.arange(8, device="cuda") + 1).cpu()

Activation is one-way and keeps execution in the same interpreter. An early import alone does not prepare an ordinary interpreter for enable; use run or Session in an already running notebook.

Discover the native executable, Python worker and JSON presets from the installation. Expose presets under their existing JSON filename stems.

Stage the Python package and its metadata with CMake for TheRock wheel packaging. Using the bindings out of the box from a bundled wheel also requires TheRock packaging changes, which will follow separately. Prefer the wheel's matching native runtime and JSON presets; source installs can use the notebook environment's native prefix. PyTorch workloads need a ROCm-enabled build in the worker or prepared main interpreter. Explicit launch overrides remain available.

Include a notebook example. Cover installation discovery, worker lifetime, cancellation, error recovery and activation inheritance. Check PyTorch and Triton execution on gfx1201 and gfx1250.

@kuhar
kuhar requested review from Groverkss and a balanced review from Copilot October 19, 2026 15:59
@kuhar
kuhar requested review from a team and atgutier as code owners October 19, 2026 15:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added documentation Improvements or additions to documentation project: rocjitsu labels Oct 19, 2026
@therock-pr-bot

therock-pr-bot Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

❌ PR Check — Action Required

Check Status Details
📝 PR Description ❌ Fail Error: PR description must reference a JIRA ID, ISSUE ID, or a GitHub closing keyword.
Expected: include a JIRA ID / ISSUE ID line (separator : or -, or omitted; value may be a JIRA key, a number with/without #, or a link), OR a closing keyword + issue reference. Accepted examples:
• JIRA ID : TESTAUTO-6039
• JIRA ID - #330
• JIRA ID #330
• JIRA ID (on separate line)
ROCM-25757
• ISSUE ID : TESTUTO-3334
• ISSUE ID #3334
• ISSUE ID - TESTAUTO-3433
• ISSUE ID (on separate line)
AIRUNTIME-2352
• ISSUE ID : https://github.com/<org_name>/<repo_name>/issues/1234
• Closes #10
• Fixes octo-org/octo-repo#100
• Resolves: #123
• #123
• https://github.com/<org_name>/<repo_name>/issues/123
Current: no valid JIRA/ISSUE/closing-keyword reference found
⛔ Forbidden Files ✅ Pass —
🧪 Unit Test ✅ Pass —
🔎 pre-commit ✅ Pass —
🚫 Draft PR 🔜 To Be Enabled —
🚩 Feature Flag 🔜 To Be Enabled —
📊 Code Coverage 🔜 To Be Enabled —

⚠️ 1 policy check(s) failed. Please address the issues above before this PR can be Reviewed.

🚫 Please fix the failed policies

  • ❌ PR Description

The Not ready to Review label was added to this PR. Once all policies pass, the label is removed automatically.

📖 Need help? See the Policy FAQ for details on every check and how to fix failures.

🙋 Wish to Override Policy?

@therock-pr-bot

Copy link
Copy Markdown

🚫 Please fix the failed policies before requesting reviews.

The following policy checks failed:

  • ❌ PR Description

The Not ready to Review label has been added to this PR.
Once all policies pass, the label will be removed automatically.

@atgutier atgutier left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One agent comment

Comment thread emulation/rocjitsu/python/rocjitsu/_api.py
@kuhar
kuhar force-pushed the users/kuhar/python-execution-api branch from aeae58b to 06e5552 Compare October 19, 2026 23:34
@kuhar
kuhar requested a review from atgutier October 20, 2026 00:15
Run upstream ROCm PyTorch and Triton on simulated AMD GPUs from Python,
including existing Colab notebooks. Support two execution styles.

Use run for a single call or Session to retain imports and runtime state
across calls in a subprocess. Preload the native interposer in the worker
without restarting the notebook or changing its GPU runtime:

```python
import rocjitsu

def add_one():
    import torch
    return (torch.arange(8, device="cuda") + 1).cpu()

result = rocjitsu.run(add_one, config=rocjitsu.config.gfx1250_mi455x)
```

For simulation in the main process, start with `python -m rocjitsu app.py`
to preload the interposer before Python starts. In app.py, call enable
before GPU discovery or framework imports:

```python
import rocjitsu
rocjitsu.enable(rocjitsu.config.gfx1250_mi455x)

import torch
result = (torch.arange(8, device="cuda") + 1).cpu()
```

Activation is one-way and keeps execution in the same interpreter.
An early import alone does not prepare an ordinary interpreter for enable;
use run or Session in an already running notebook.

Discover the native executable, Python worker and JSON presets from the
installation. Expose presets under their existing JSON filename stems.

Stage the Python package and its metadata with CMake for TheRock wheel
packaging. Using the bindings out of the box from a bundled wheel also
requires TheRock packaging changes, which will follow separately.
Prefer the wheel's matching native runtime and JSON presets; source
installs can use the notebook environment's native prefix. PyTorch
workloads need a ROCm-enabled build in the worker or prepared main
interpreter. Explicit launch overrides remain available.

Include a notebook example. Cover installation discovery, worker lifetime,
cancellation, error recovery and activation inheritance. Check PyTorch
and Triton execution on gfx1201 and gfx1250.
@kuhar
kuhar force-pushed the users/kuhar/python-execution-api branch from 06e5552 to e3de35e Compare October 20, 2026 00:18

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants