(graph_module: torch.fx.GraphModule)
| 102 | |
| 103 | |
| 104 | def find_singleton_start_pos_node(graph_module: torch.fx.GraphModule): |
| 105 | for node in graph_module.graph.nodes: |
| 106 | if is_update_cache_node(node): |
| 107 | return node.args[2] |
| 108 | |
| 109 | if is_sdpa_with_kv_cache_node(node): |
| 110 | return node.args[5] |
| 111 | |
| 112 | raise Exception( |
| 113 | "Could not find an instance of llama::update_cache or sdpa_with_kv_cache" |
| 114 | ) |
| 115 | |
| 116 | |
| 117 | @register_pattern_replacement("causal_sdpa") |
no test coverage detected