Skip to content

Prevent CPU HLO profiling crashes - #103

Open
stevenvar wants to merge 1 commit into
joeyye-work:for-serving-2.20from
stevenvar:steven.cpu_hlo_profile_fix
Open

Prevent CPU HLO profiling crashes#103
stevenvar wants to merge 1 commit into
joeyye-work:for-serving-2.20from
stevenvar:steven.cpu_hlo_profile_fix

Conversation

@stevenvar

@stevenvar stevenvar commented May 5, 2026

Copy link
Copy Markdown
Collaborator

This PR fixes a crash when using --xla_hlo_profile=true with XLA:CPU.

Before this change, XLA could generate profiling code, but at runtime the profiling counter buffer could be missing. The generated code then tried to write to a null pointer and crashed.

This change:

  • creates the profiling counter buffer before running the compiled CPU function
  • passes that buffer to the generated code
  • adds a safety check so profiling does not crash if the buffer is missing
  • disables HLO profiling for the CPU thunk runtime, because that path does not support profiling counters yet

On non-x86 CPUs, it also uses a safer runtime timer instead of a low-level LLVM cycle counter.

@stevenvar
stevenvar force-pushed the steven.cpu_hlo_profile_fix branch from 16b72a3 to 1a3aa6c Compare July 30, 2026 10:41
@stevenvar
stevenvar force-pushed the steven.cpu_hlo_profile_fix branch from 1a3aa6c to 76586bb Compare July 30, 2026 10:43
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.

1 participant