
    -`i                         d dl Z d dlmZ d dlZd dlmZ  ee          Zdej        j	        de
e         defdZe j        de
e         dz  ded         fd	            ZdS )
    N)	Generator)init_loggernodesplitting_opsreturnc                    | j         dk    rdS | j        }t          |t          j        j                  r	|j        |v S t          |t          j        j                  r(|                                }| d|j	         }||v p||v S dS )z
    Check if a node should be split for dynamo graph partition.
    It operates on dynamo graph, so the node.target can be anything.
    We need to check and split only on OpOverload and OpOverloadPacket.
    call_functionF.)
optarget
isinstancetorch_opsOpOverloadPacket_qualified_op_name
OpOverloadname_overloadname)r   r   r   packet_nameop_overload_names        t/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/vllm/compilation/partition_rules.pyshould_splitr      s     w/!!u[F&%*566 :(M99&%*/00 Qkkmm *BBF,@BB=0PK=4PP5    )NNNc              #     K   | s t                               d           dV  dS t          t          j        j        j                  }| t          j        j        _        t                               dt          |                      	 dV  |t          j        j        _        t                               d           dS # |t          j        j        _        t                               d           w xY w)ag  Context manager to temporarily register Inductor partition rules.

    Registers custom partition rules for specified operators, forcing the
    Inductor scheduler to partition the graph at these operators. The rules
    are automatically restored to their previous state on exit.

    Args:
        splitting_ops: List of operator names to partition on.
    z6No partition ops provided; skipping rule registration.Nz4Registered inductor partition rules for %d operatorsz(Restored previous partition rules state.)loggerdebuglistr   	_inductorconfigcustom_should_partition_opslen)r   saved_splitting_opss     r   inductor_partition_rule_contextr#   )   s        MNNN &*:& & :GEO6
LL>M@R@R  A >Q:?@@@@@ >Q:?@@@@s   B= =2C/)
contextlibcollections.abcr   r   vllm.loggerr   __name__r   fxNoder   strboolr   contextmanagerr#    r   r   <module>r.      s        % % % % % %  # # # # # #	X		ux} T#Y 4    6 !A9t#!A !A !A !A !A !A !Ar   