Skip to content

Commit 8ab6649

Browse files
FindHaofacebook-github-bot
authored andcommitted
Add custom Vite plugin to strip 'module' attribute from script tags (#11)
Summary: - Introduced a new Vite plugin named 'strip-module-attr' that transforms script tags by replacing the 'type="module"' attribute with 'defer' to fix unidentified module type internally Pull Request resolved: #11 Reviewed By: xuzhao9 Differential Revision: D76308714 Pulled By: FindHao fbshipit-source-id: 93107d1a162126c55d9c9d159fa167031d573aae
1 parent 2a29465 commit 8ab6649

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,20 +100,21 @@ First, integrate TritonParse with your Triton/PyTorch code to generate trace fil
100100

101101
```python
102102
import torch
103+
# === TritonParse ===
103104
import tritonparse.structured_logging
104-
105105
# Initialize structured logging to capture Triton compilation events
106+
# This will generate NDJSON trace logs in ./logs/
106107
tritonparse.structured_logging.init("./logs/")
108+
# === TritonParse end ===
107109

110+
# The below is your original Triton/PyTorch 2 code
108111
# Example: Using with torch.compile
109112
def your_kernel():
110113
# Your PyTorch/Triton kernel code
111114
pass
112115

113116
compiled_kernel = torch.compile(your_kernel)
114-
result = compiled_kernel() # This will generate NDJSON trace logs in ./logs/
115-
116-
# The trace files can then be analyzed using the web interface
117+
result = compiled_kernel()
117118
```
118119

119120
### 2. Analyze with Web Interface

website/vite.config.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,17 @@ const packageJson = JSON.parse(
99

1010
export default defineConfig({
1111
plugins: [
12-
react()
12+
react(),
13+
{
14+
name: 'strip-module-attr',
15+
enforce: 'post',
16+
transformIndexHtml(html) {
17+
return html.replace(
18+
/<script\s+type=["']module["']\s+([^>]*?)src=/g,
19+
'<script defer $1src='
20+
)
21+
}
22+
}
1323
],
1424

1525
base: './',

0 commit comments

Comments
 (0)