@@ -313,26 +313,19 @@ def _validate_channelwise_gated_delta_rule_params(
313313 tensor .dtype == torch .float32
314314 ), f"Expected { name } to be float32 but got { tensor .dtype } "
315315
316- assert (
317- query .shape == key .shape
318- ), f"Expected query and key to have matching shapes but got { query .shape } and { key .shape } "
319- assert (
320- query .shape == decay .shape
321- ), f"Expected query and decay to have matching shapes but got { query .shape } and { decay .shape } "
322- assert (
323- query .shape [:3 ] == value .shape [:3 ]
324- ), f"Expected query and value to match in batch/head/sequence dims but got { query .shape } and { value .shape } "
325- assert (
326- beta .shape == query .shape [:3 ]
327- ), f"Expected beta to match query batch/head/sequence dims but got { beta .shape } and { query .shape } "
316+ assert query .size (0 ) == key .size (0 ) and query .shape [2 :] == key .shape [2 :]
317+ assert key .shape == decay .shape
318+ assert key .shape [:3 ] == value .shape [:3 ]
319+ assert beta .shape == key .shape [:3 ]
320+ assert query .size (1 ) % key .size (1 ) == 0
328321 assert initial_state .shape == (
329- query .size (0 ),
330- query .size (1 ),
322+ key .size (0 ),
323+ key .size (1 ),
331324 query .size (3 ),
332325 value .size (3 ),
333326 ), (
334327 "Expected initial_state to have shape "
335- f"{ (query .size (0 ), query .size (1 ), query .size (3 ), value .size (3 ))} "
328+ f"{ (key .size (0 ), key .size (1 ), query .size (3 ), value .size (3 ))} "
336329 f"but got { initial_state .shape } "
337330 )
338331
@@ -354,7 +347,8 @@ def channelwise_gated_delta_rule_meta(
354347 beta ,
355348 initial_state ,
356349 )
357- return torch .empty_like (value ), torch .empty_like (initial_state )
350+ output_shape = (* query .shape [:3 ], value .size (3 ))
351+ return query .new_empty (output_shape ), torch .empty_like (initial_state )
358352
359353
360354def _validate_quantized_sdpa_params (
0 commit comments