@@ -242,9 +242,9 @@ def init_hybrid_states(config, dtype: np.dtype = np.float32) -> dict[str, np.nda
242242 states [f"past_key_values.{ i } .conv_state" ] = np .zeros (
243243 (batch_size , conv_dim , d_conv - 1 ), dtype = dtype
244244 )
245- # ssm_state: (batch, n_heads, d_head, d_state)
245+ # ssm_state: (batch, n_heads, d_state, d_head) — LinearAttention convention
246246 states [f"past_key_values.{ i } .ssm_state" ] = np .zeros (
247- (batch_size , n_heads , d_head , d_state ),
247+ (batch_size , n_heads , d_state , d_head ),
248248 dtype = dtype ,
249249 )
250250 elif ltype in ("attention" , "full_attention" ):
@@ -593,24 +593,39 @@ def main():
593593 "--device" ,
594594 choices = ["cpu" , "cuda" ],
595595 default = "cpu" ,
596- help = "Device for ONNX Runtime and PyTorch inference (default: %(default)s)." ,
596+ help = (
597+ "Device for inference (used for ONNX Runtime and for "
598+ "HuggingFace comparison when --compare-hf is set) "
599+ "(default: %(default)s)."
600+ ),
601+ )
602+ parser .add_argument (
603+ "--ep" ,
604+ choices = ["cpu" , "cuda" , "onnx-standard" ],
605+ default = None ,
606+ help = (
607+ "Execution provider for ONNX model build. "
608+ "'onnx-standard' inlines custom ops (LinearAttention, etc.) "
609+ "into standard ONNX ops, runnable on any ORT version. "
610+ "Defaults to matching --device."
611+ ),
597612 )
598613 parser .add_argument (
599614 "--no-chat" ,
600615 action = "store_true" ,
601616 help = "Disable chat template (send raw text)." ,
602617 )
618+ parser .add_argument (
619+ "--ci" ,
620+ action = "store_true" ,
621+ help = "Exit with non-zero code on failure (for CI pipelines)." ,
622+ )
603623 parser .add_argument (
604624 "--repetition-penalty" ,
605625 type = float ,
606626 default = REPETITION_PENALTY ,
607627 help = "Repetition penalty (1.0 = none, default: %(default)s)." ,
608628 )
609- parser .add_argument (
610- "--ci" ,
611- action = "store_true" ,
612- help = "Exit with non-zero code on failure (for CI pipelines)." ,
613- )
614629 args = parser .parse_args ()
615630
616631 use_chat = not args .no_chat
@@ -632,7 +647,7 @@ def main():
632647 build_flags = {}
633648 if args .device == "cuda" :
634649 build_flags ["ort_cuda_grouped_rmsnorm_workaround" ] = True
635- ep = "cuda" if args .device == "cuda" else "cpu"
650+ ep = args . ep or ( "cuda" if args .device == "cuda" else "cpu" )
636651 print (f"Building model for { args .model !r} (dtype={ args .dtype } , ep={ ep } ) ..." )
637652 with override_flags (** build_flags ):
638653 pkg = build (
0 commit comments