Skip to content

Conversation

@giordano
Copy link
Member

@giordano giordano commented Nov 13, 2025

No description provided.

@giordano giordano force-pushed the mg/reactant-default-var branch from 386197e to 2c169ef Compare November 13, 2025 18:31
@giordano giordano force-pushed the mg/reactant-default-var branch from 444cf6b to 3f9be82 Compare November 13, 2025 18:49
@giordano
Copy link
Member Author

To demonstrate this works, on top of #1860 I get

julia> using Reactant

julia> Reactant.XLA.default_device()
Reactant.XLA.PJRT.Device(Ptr{Nothing}(0x0000000042369bd0), "TT:0 Wormhole_b0")

julia> ENV["REACTANT_DEFAULT_DEVICE"] = "31"
"31"

julia> Reactant.XLA.default_device()
Reactant.XLA.PJRT.Device(Ptr{Nothing}(0x000000004d618490), "TT:31 Wormhole_b0")

@giordano giordano changed the title Use REACTANT_DEFAULT_DEVICE to set default device ID with env var Define XLA.DEFAULT_DEVICE to set default device ID Nov 13, 2025
0-based index of default device to use, by default 0 (first available device).
"""
const DEFAULT_DEVICE = Ref{Int}(0)
Copy link
Member

Choose a reason for hiding this comment

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

if we're not doing an env var we can leave this as 1-indexed. [reason for env var is cuz cuda_visible_devices and friends are 0-indexed]

Copy link
Member

Choose a reason for hiding this comment

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

also if you want we can still do DEFAULT_DEVICE = Ref{Int}(something(tryparse, ...)

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@giordano giordano force-pushed the mg/reactant-default-var branch from af67d52 to 3bb3be9 Compare December 3, 2025 11:58
@giordano giordano force-pushed the mg/reactant-default-var branch from b840fb3 to 8ea159a Compare December 3, 2025 12:18
@giordano
Copy link
Member Author

giordano commented Dec 3, 2025

Just confirming this still works:

julia> using Reactant

julia> Reactant.XLA.default_device()
Reactant.XLA.PJRT.Device(Ptr{Nothing} @0x00000000321be750, "TT:0 Wormhole_b0")

julia> Reactant.XLA.DEFAULT_DEVICE[] = 16
16

julia> Reactant.XLA.default_device()
Reactant.XLA.PJRT.Device(Ptr{Nothing} @0x0000000032833c10, "TT:16 Wormhole_b0")

julia> Reactant.XLA.DEFAULT_DEVICE[] = 31
31

julia> Reactant.XLA.default_device()
Reactant.XLA.PJRT.Device(Ptr{Nothing} @0x0000000032834660, "TT:31 Wormhole_b0")

Yay!

@codecov
Copy link

codecov bot commented Dec 3, 2025

Codecov Report

❌ Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.92%. Comparing base (b39a1fc) to head (8ea159a).
⚠️ Report is 217 commits behind head on main.

Files with missing lines Patch % Lines
src/xla/XLA.jl 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1866      +/-   ##
==========================================
+ Coverage   68.16%   69.92%   +1.76%     
==========================================
  Files         109      122      +13     
  Lines       11779    13233    +1454     
==========================================
+ Hits         8029     9253    +1224     
- Misses       3750     3980     +230     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants