Skip to content

Commit dce9cd9

Browse files
committed
Tensorboard Profiling
1 parent 0db58bd commit dce9cd9

34 files changed

+5953
-5728
lines changed

.github/workflows/ubuntu-build-dependencies.yml

Lines changed: 70 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -232,54 +232,70 @@ jobs:
232232
build --host_cxxopt=-std=c++17
233233
EOF
234234
235-
- name: Build PJRT CPU Plugin
235+
- name: Copy SwiftIR patch sources to XLA
236+
run: |
237+
# Copy SwiftIR profiler BUILD and source files to XLA repo
238+
# These files build libswiftir_profiler.so which wraps TSL profiler
239+
cp -r $GITHUB_WORKSPACE/xla-patches/swiftir ~/swiftir-build/xla/
240+
echo "Copied SwiftIR profiler sources:"
241+
ls -la ~/swiftir-build/xla/swiftir/
242+
243+
# Copy patched PJRT CPU plugin with profiler extension and TraceMe API
244+
# This replaces the standard CPU plugin with one that includes:
245+
# - Profiler extension for TensorBoard integration
246+
# - TraceMe C API for unified Swift/XLA tracing
247+
cp -r $GITHUB_WORKSPACE/xla-patches/pjrt_cpu ~/swiftir-build/xla/
248+
echo "Copied patched PJRT CPU plugin sources:"
249+
ls -la ~/swiftir-build/xla/pjrt_cpu/
250+
251+
- name: Build PJRT CPU Plugin and SwiftIR Profiler
236252
run: |
237253
cd ~/swiftir-build/xla
238254
239255
# Clean previous builds
240256
bazelisk shutdown || true
241257
bazelisk clean --expunge || true
242258
243-
# Build PJRT plugin
259+
# Build patched PJRT plugin (with profiler extension + TraceMe API) and SwiftIR profiler
260+
# - pjrt_c_api_cpu_plugin_profiler.so: CPU plugin with profiler extension and TraceMe API
261+
# - libswiftir_profiler.so: Standalone profiler (~42MB) for fallback/legacy use
244262
bazelisk --output_user_root=~/swiftir-build/xla-bazelisk-build \
245-
build //xla/pjrt/c:pjrt_c_api_cpu_plugin.so \
246-
//xla/pjrt/proto:compile_options_proto
263+
build //pjrt_cpu:pjrt_c_api_cpu_plugin_profiler.so \
264+
//swiftir:libswiftir_profiler.so
247265
248-
- name: Install PJRT Plugin and Libraries
266+
- name: Install PJRT Plugin and SwiftIR Profiler
249267
run: |
250268
cd ~/swiftir-build/xla
269+
BAZEL_OUT=~/swiftir-build/xla-bazelisk-build
251270
252-
# Find and copy plugin
253-
PLUGIN_PATH=$(find ~/swiftir-build/xla-bazelisk-build -name "pjrt_c_api_cpu_plugin.so" -type f 2>/dev/null | head -1)
271+
# Find and copy patched PJRT plugin (rename to standard name for compatibility)
272+
PLUGIN_PATH=$(find $BAZEL_OUT -name "pjrt_c_api_cpu_plugin_profiler.so" -type f 2>/dev/null | head -1)
254273
if [ -n "$PLUGIN_PATH" ]; then
255-
cp "$PLUGIN_PATH" /opt/swiftir-deps/lib/
256-
echo "✅ PJRT CPU plugin installed"
274+
cp "$PLUGIN_PATH" /opt/swiftir-deps/lib/pjrt_c_api_cpu_plugin.so
275+
echo "✅ PJRT CPU plugin (with profiler + TraceMe) installed"
257276
else
258277
echo "❌ PJRT plugin not found"
259278
exit 1
260279
fi
261280
262-
# Copy XLA proto libraries
263-
mkdir -p /opt/swiftir-deps/lib/xla
264-
find ~/swiftir-build/xla-bazelisk-build -name "*_proto*.pic.a" -path "*/xla/*" -exec cp {} /opt/swiftir-deps/lib/xla/ \; 2>/dev/null || true
265-
266-
# Copy protobuf libraries
267-
mkdir -p /opt/swiftir-deps/lib/protobuf
268-
find ~/swiftir-build/xla-bazelisk-build -path "*/com_google_protobuf/*.pic.a" -exec cp {} /opt/swiftir-deps/lib/protobuf/ \; 2>/dev/null || true
269-
270-
# Copy abseil libraries
271-
mkdir -p /opt/swiftir-deps/lib/absl
272-
find ~/swiftir-build/xla-bazelisk-build -path "*/com_google_absl/*.pic.a" -exec cp {} /opt/swiftir-deps/lib/absl/ \; 2>/dev/null || true
281+
# Find and copy SwiftIR profiler library
282+
# This is a monolithic ~42MB library with all TSL profiler dependencies
283+
PROFILER_PATH=$(find $BAZEL_OUT -name "libswiftir_profiler.so" -type f 2>/dev/null | head -1)
284+
if [ -n "$PROFILER_PATH" ]; then
285+
cp "$PROFILER_PATH" /opt/swiftir-deps/lib/
286+
echo "✅ SwiftIR profiler installed ($(du -h "$PROFILER_PATH" | cut -f1))"
287+
else
288+
echo "❌ SwiftIR profiler not found"
289+
exit 1
290+
fi
273291
274292
# Copy PJRT headers
275293
mkdir -p /opt/swiftir-deps/include/xla/pjrt/c
276294
cp xla/pjrt/c/*.h /opt/swiftir-deps/include/xla/pjrt/c/ 2>/dev/null || true
277295
296+
echo ""
278297
echo "Installed libraries:"
279298
ls -la /opt/swiftir-deps/lib/*.so 2>/dev/null || true
280-
echo "XLA proto libs: $(ls /opt/swiftir-deps/lib/xla/*.a 2>/dev/null | wc -l)"
281-
echo "Protobuf libs: $(ls /opt/swiftir-deps/lib/protobuf/*.a 2>/dev/null | wc -l)"
282-
echo "Abseil libs: $(ls /opt/swiftir-deps/lib/absl/*.a 2>/dev/null | wc -l)"
283299
284300
# ============================================================
285301
# 5. Build SwiftIRMLIR Library
@@ -302,15 +318,15 @@ jobs:
302318
exit 1
303319
fi
304320
305-
- name: Build PJRTProtoHelper
321+
- name: Build PJRTProtoHelper and PJRTSimpleWrapper
306322
run: |
307323
cd $GITHUB_WORKSPACE/Sources/PJRTCWrappers
308324
mkdir -p build && cd build
309325
310326
cmake .. -DCMAKE_BUILD_TYPE=Release
311327
cmake --build . --parallel $(nproc)
312328
313-
# Copy library to deps dir
329+
# Copy libraries to deps dir
314330
if [ -f "libPJRTProtoHelper.so" ]; then
315331
cp libPJRTProtoHelper.so /opt/swiftir-deps/lib/
316332
echo "✅ PJRTProtoHelper built and installed"
@@ -319,6 +335,35 @@ jobs:
319335
exit 1
320336
fi
321337
338+
if [ -f "libPJRTSimpleWrapper.so" ]; then
339+
cp libPJRTSimpleWrapper.so /opt/swiftir-deps/lib/
340+
echo "✅ PJRTSimpleWrapper built and installed"
341+
else
342+
echo "❌ PJRTSimpleWrapper not found"
343+
exit 1
344+
fi
345+
346+
- name: Build JupyterMLIRWrapper
347+
run: |
348+
cd $GITHUB_WORKSPACE/Sources/JupyterCWrappers
349+
mkdir -p build && cd build
350+
351+
export SWIFTIR_DEPS=/opt/swiftir-deps
352+
cmake .. -DCMAKE_BUILD_TYPE=Release
353+
cmake --build . --parallel $(nproc)
354+
355+
# Copy library to deps dir
356+
if [ -f "libJupyterMLIRWrapper.so" ]; then
357+
cp libJupyterMLIRWrapper.so /opt/swiftir-deps/lib/
358+
echo "✅ JupyterMLIRWrapper built and installed"
359+
else
360+
echo "❌ JupyterMLIRWrapper not found"
361+
exit 1
362+
fi
363+
364+
# Note: SwiftIRProfiler (libswiftir_profiler.so) is built via Bazel
365+
# alongside the PJRT plugin and already installed above
366+
322367
# ============================================================
323368
# 6. Build and Test SwiftIR
324369
# ============================================================

0 commit comments

Comments
 (0)