Skip to content

Dedup prev_outs and cur_inps in looped_opt_barrier. As you can see below, we get rid of the redundant opt_barriers. - #40337

Merged
copybara-service[bot] merged 1 commit into
mainfrom
test_974098303
Aug 31, 2026
Merged

Dedup prev_outs and cur_inps in looped_opt_barrier. As you can see below, we get rid of the redundant opt_barriers.#40337
copybara-service[bot] merged 1 commit into
mainfrom
test_974098303

Conversation

@copybara-service

Copy link
Copy Markdown

Dedup prev_outs and cur_inps in looped_opt_barrier. As you can see below, we get rid of the redundant opt_barriers.

Before jaxpr:

{ lambda ; a:f64[8@x] b:f64[8@x] c:f64[8@x]. let
    d:f64[8@x] = sin a
    e:Tok = create_token
    f:Tok _:f64[8@x] = optimization_barrier e d
    _:Tok g:f64[8@x] = optimization_barrier f d
    h:f64[8@x] = program_order[
      call_jaxpr={ lambda ; i:f64[8@x]. let
          j:f64[8@x] = add i 1.0:f64[]
        in (j,) }
      exclude_mask=(False,)
    ] g
    k:Tok = create_token
    l:Tok _:f64[8@x] = optimization_barrier k h
    _:Tok m:f64[8@x] = optimization_barrier l h
    _:Tok n:f64[8@x] = optimization_barrier l b
    _:Tok o:f64[8@x] = optimization_barrier l c
    p:f64[8@x] = program_order[
      call_jaxpr={ lambda ; q:f64[8@x] r:f64[8@x] s:f64[8@x]. let
          t:f64[8@x] = mul q r
          u:f64[8@x] = add t s
        in (u,) }
      exclude_mask=(False, False, False)
    ] m n o
  in (p,) }

After jaxpr:

{ lambda ; a:f64[8@x] b:f64[8@x] c:f64[8@x]. let
    d:f64[8@x] = sin a
    e:Tok = create_token
    _:Tok f:f64[8@x] = optimization_barrier e d
    g:f64[8@x] = program_order[
      call_jaxpr={ lambda ; h:f64[8@x]. let
          i:f64[8@x] = add h 1.0:f64[]
        in (i,) }
      exclude_mask=(False,)
    ] f
    j:Tok = create_token
    k:Tok l:f64[8@x] = optimization_barrier j g
    _:Tok m:f64[8@x] = optimization_barrier k b
    _:Tok n:f64[8@x] = optimization_barrier k c
    o:f64[8@x] = program_order[
      call_jaxpr={ lambda ; p:f64[8@x] q:f64[8@x] r:f64[8@x]. let
          s:f64[8@x] = mul p q
          t:f64[8@x] = add s r
        in (t,) }
      exclude_mask=(False, False, False)
    ] l m n
  in (o,) }
@copybara-service
copybara-service Bot force-pushed the test_974098303 branch 2 times, most recently from b566ee7 to e082cfd Compare August 31, 2026 23:02
…low, we get rid of the redundant opt_barriers.

Before jaxpr:

```
{ lambda ; a:f64[8@x] b:f64[8@x] c:f64[8@x]. let
    d:f64[8@x] = sin a
    e:Tok = create_token
    f:Tok _:f64[8@x] = optimization_barrier e d
    _:Tok g:f64[8@x] = optimization_barrier f d
    h:f64[8@x] = program_order[
      call_jaxpr={ lambda ; i:f64[8@x]. let
          j:f64[8@x] = add i 1.0:f64[]
        in (j,) }
      exclude_mask=(False,)
    ] g
    k:Tok = create_token
    l:Tok _:f64[8@x] = optimization_barrier k h
    _:Tok m:f64[8@x] = optimization_barrier l h
    _:Tok n:f64[8@x] = optimization_barrier l b
    _:Tok o:f64[8@x] = optimization_barrier l c
    p:f64[8@x] = program_order[
      call_jaxpr={ lambda ; q:f64[8@x] r:f64[8@x] s:f64[8@x]. let
          t:f64[8@x] = mul q r
          u:f64[8@x] = add t s
        in (u,) }
      exclude_mask=(False, False, False)
    ] m n o
  in (p,) }
```

After jaxpr:

```
{ lambda ; a:f64[8@x] b:f64[8@x] c:f64[8@x]. let
    d:f64[8@x] = sin a
    e:Tok = create_token
    _:Tok f:f64[8@x] = optimization_barrier e d
    g:f64[8@x] = program_order[
      call_jaxpr={ lambda ; h:f64[8@x]. let
          i:f64[8@x] = add h 1.0:f64[]
        in (i,) }
      exclude_mask=(False,)
    ] f
    j:Tok = create_token
    k:Tok l:f64[8@x] = optimization_barrier j g
    _:Tok m:f64[8@x] = optimization_barrier k b
    _:Tok n:f64[8@x] = optimization_barrier k c
    o:f64[8@x] = program_order[
      call_jaxpr={ lambda ; p:f64[8@x] q:f64[8@x] r:f64[8@x]. let
          s:f64[8@x] = mul p q
          t:f64[8@x] = add s r
        in (t,) }
      exclude_mask=(False, False, False)
    ] l m n
  in (o,) }
```

PiperOrigin-RevId: 974128517
@copybara-service
copybara-service Bot merged commit 73535a9 into main Aug 31, 2026
18 checks passed
@copybara-service
copybara-service Bot deleted the test_974098303 branch August 31, 2026 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant