Skip to content

[Bug] perf utils #1020

@Bob-Chen222

Description

@Bob-Chen222

Checklist

  • 1. I have searched related issues but cannot get the expected help.
  • 2. The bug has not been fixed in the latest version.
  • 3. Please note that if the bug-related issue you submitted lacks corresponding environment info and a minimal reproducible demo, it will be challenging for us to reproduce and resolve the issue, reducing the likelihood of receiving feedback.
  • 4. If the issue you raised is not a bug but a question, please raise a discussion at https://github.com/sgl-project/sgl-jax/discussions/new/choose Otherwise, it will be closed.
  • 5. Please use English, otherwise it will be closed.

Describe the bug

multiple_iteration_timeit_from_trace](https://github.com/sgl-project/sglang-jax/blob/main/python/sgl_jax/srt/kernels/utils/perf.py#L77-L102) in python/sgl_jax/srt/kernels/utils/perf.py was reporting host wall time, not device kernel time — inflating measurements 4–10× and ranking candidates by host noise.

Two compounding issues in _extract_marker_durations_ms:

  1. The intended MARKER in args.tf_op filter found zero events, because [jax.named_scope](https://github.com/sgl-project/sglang-jax/
    blob/main/python/sgl_jax/srt/kernels/utils/perf.py#L96) wrapping an already-compiled jit at runtime doesn't propagate into HLO op_name (named_scope only injects metadata when active during tracing).
  2. The fallback regex match against task matched the host StepTraceAnnotation event, then min_pid biased to the host plane. Those events have no device_duration_ps, so the code read dur — host wall time including block_until_ready.

I want to confirm whether this makes sense and ask for suggestions and I will make a PR to search directly for device plane's event for more accurate kernel time.

Reproduction

Any kernel measurement

Environment

attention-upgrade branch

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions