[Fix][Manifest] adopt documented shape/workload format in new elementwise families

- Convert signature shape values from YAML lists to string form ("[M, N]")
  in elementwise_generative.yaml and elementwise_fused_gated.yaml to match
  docs/design/manifest.md R8 + the convolution.yaml precedent so the
  validator can bind shape symbols.
- Add per-input workload shape keys (device_carrier_shape, x_shape) to
  every workload row to satisfy the workload schema documented in
  docs/design/manifest.md and used across normalization.yaml etc.
- Restore exception class/message in check_c4_forward_signature_parity's
  warning when inspect.signature(forward) raises.

Co-Authored-By: Ibuki 🍃 — a wind born from GPTs <Ibuki-wind@users.noreply.github.com>
This commit is contained in:
lcy-seso 2026-05-12 12:24:23 +08:00 committed by Cao Ying
parent a1973b36d5
commit c2e01ac8d4
3 changed files with 40 additions and 23 deletions

View File

@ -738,7 +738,13 @@ def _forward_positional_params(cls) -> list[str] | None:
p for p, v in sig.parameters.items()
if p != "self" and v.kind in _POSITIONAL_KINDS
]
except (ValueError, TypeError):
except (ValueError, TypeError) as exc:
# Stash exception text so callers that surface diagnostics can
# report ``exc.__class__.__name__: exc`` without changing the
# ``None`` return contract for "not inspectable".
_forward_positional_params._last_error = ( # type: ignore[attr-defined]
f"{exc.__class__.__name__}: {exc}"
)
return None
@ -3367,9 +3373,20 @@ def check_c4_forward_signature_parity(
positional = _forward_positional_params(cls)
if positional is None:
if warnings is not None:
warnings.append(
f"[forward] {op_name}: inspect.signature(forward) failed"
detail = getattr(
_forward_positional_params, "_last_error", None
)
if detail:
warnings.append(
f"[forward] {op_name}: inspect.signature(forward) "
f"raised {detail}"
)
# Clear so a later call site sees only its own failure.
_forward_positional_params._last_error = None # type: ignore[attr-defined]
else:
warnings.append(
f"[forward] {op_name}: inspect.signature(forward) failed"
)
return errors
# Generative-op carve-out: ``ref_api: "none"`` plus zero forward()

View File

@ -18,17 +18,17 @@ SiluAndMulFwdOp:
signature:
inputs:
x: {dtype: "float16 | bfloat16 | float32", shape: [M, two_N]}
x: {dtype: "float16 | bfloat16 | float32", shape: "[M, two_N]"}
outputs:
output: {dtype: "same_as(x)", shape: [M, N]}
output: {dtype: "same_as(x)", shape: "[M, N]"}
shape_rules:
- "x.shape[1] == 2 * output.shape[1]"
- "x.shape[0] == output.shape[0]"
workloads:
# SwiGLU FFN intermediate (Llama-3.1-8B, hidden_dim=14336)
- {M: 2048, N: 14336, dtypes: [float16, bfloat16], label: "llama-3.1-8b-swiglu-prefill"}
- {M: 1, N: 14336, dtypes: [bfloat16], label: "llama-3.1-8b-swiglu-decode"}
- {x_shape: [2048, 28672], dtypes: [float16, bfloat16], label: "llama-3.1-8b-swiglu-prefill"}
- {x_shape: [1, 28672], dtypes: [bfloat16], label: "llama-3.1-8b-swiglu-decode"}
roofline:
vars:
@ -60,16 +60,16 @@ GeluAndMulFwdOp:
signature:
inputs:
x: {dtype: "float16 | bfloat16 | float32", shape: [M, two_N]}
x: {dtype: "float16 | bfloat16 | float32", shape: "[M, two_N]"}
outputs:
output: {dtype: "same_as(x)", shape: [M, N]}
output: {dtype: "same_as(x)", shape: "[M, N]"}
shape_rules:
- "x.shape[1] == 2 * output.shape[1]"
- "x.shape[0] == output.shape[0]"
workloads:
- {M: 2048, N: 14336, dtypes: [float16, bfloat16], label: "ffn-gelu-prefill"}
- {M: 1, N: 14336, dtypes: [bfloat16], label: "ffn-gelu-decode"}
- {x_shape: [2048, 28672], dtypes: [float16, bfloat16], label: "ffn-gelu-prefill"}
- {x_shape: [1, 28672], dtypes: [bfloat16], label: "ffn-gelu-decode"}
roofline:
vars:
@ -100,16 +100,16 @@ GeluTanhAndMulFwdOp:
signature:
inputs:
x: {dtype: "float16 | bfloat16 | float32", shape: [M, two_N]}
x: {dtype: "float16 | bfloat16 | float32", shape: "[M, two_N]"}
outputs:
output: {dtype: "same_as(x)", shape: [M, N]}
output: {dtype: "same_as(x)", shape: "[M, N]"}
shape_rules:
- "x.shape[1] == 2 * output.shape[1]"
- "x.shape[0] == output.shape[0]"
workloads:
- {M: 2048, N: 14336, dtypes: [float16, bfloat16], label: "ffn-gelu-tanh-prefill"}
- {M: 1, N: 14336, dtypes: [bfloat16], label: "ffn-gelu-tanh-decode"}
- {x_shape: [2048, 28672], dtypes: [float16, bfloat16], label: "ffn-gelu-tanh-prefill"}
- {x_shape: [1, 28672], dtypes: [bfloat16], label: "ffn-gelu-tanh-decode"}
roofline:
vars:

View File

@ -29,9 +29,9 @@ AlibiFwdOp:
signature:
inputs:
device_carrier: {dtype: "float16 | bfloat16 | float32", shape: []}
device_carrier: {dtype: "float16 | bfloat16 | float32", shape: "[]"}
outputs:
output: {dtype: "same_as(device_carrier)", shape: [num_heads, seq_len, seq_len]}
output: {dtype: "same_as(device_carrier)", shape: "[num_heads, seq_len, seq_len]"}
params:
seq_len: {type: int}
num_heads: {type: int}
@ -41,8 +41,8 @@ AlibiFwdOp:
workloads:
# Llama-style attention bias dimensions
- {seq_len: 2048, num_heads: 32, dtypes: [float16, bfloat16], label: "llama-prefill-2k"}
- {seq_len: 4096, num_heads: 32, dtypes: [float16, bfloat16], label: "llama-prefill-4k"}
- {device_carrier_shape: [], seq_len: 2048, num_heads: 32, dtypes: [float16, bfloat16], label: "llama-prefill-2k"}
- {device_carrier_shape: [], seq_len: 4096, num_heads: 32, dtypes: [float16, bfloat16], label: "llama-prefill-4k"}
roofline:
vars:
@ -76,9 +76,9 @@ SinusoidalFwdOp:
signature:
inputs:
device_carrier: {dtype: "float16 | bfloat16 | float32", shape: []}
device_carrier: {dtype: "float16 | bfloat16 | float32", shape: "[]"}
outputs:
output: {dtype: "same_as(device_carrier)", shape: [seq_len, d_model]}
output: {dtype: "same_as(device_carrier)", shape: "[seq_len, d_model]"}
params:
seq_len: {type: int}
d_model: {type: int}
@ -89,8 +89,8 @@ SinusoidalFwdOp:
workloads:
# Transformer-style positional encodings
- {seq_len: 2048, d_model: 4096, dtypes: [float16, bfloat16], label: "transformer-2k-4k"}
- {seq_len: 4096, d_model: 4096, dtypes: [float16, bfloat16], label: "transformer-4k-4k"}
- {device_carrier_shape: [], seq_len: 2048, d_model: 4096, dtypes: [float16, bfloat16], label: "transformer-2k-4k"}
- {device_carrier_shape: [], seq_len: 4096, d_model: 4096, dtypes: [float16, bfloat16], label: "transformer-4k-4k"}
roofline:
vars: