Repository navigation
[Feat] [CPU] glm_ocr: Add model support - #37597
Conversation
|
your local base is too old. rebase to master. |
baa5055 to
1e7f9dc
Compare
|
I have rebase it to master |
| using weight_t = scalar_t; | ||
| if (bias.has_value()) { | ||
| AT_DISPATCH_REDUCED_FLOATING_TYPES_AND(at::kFloat, bias.value().scalar_type(), "layernorm_bias", [&] { | ||
| using bias_t = scalar_t; |
There was a problem hiding this comment.
bias can either be float32 or the same dtype with input.
aka. you will not likely to have input bf16 and bias f16.
what is the real use case in your concerned models?
can you make a table listing :
- model name
- input type
- weight type
- bias type
There was a problem hiding this comment.
The input/weight/bias of Layernorm support fp16/bf16/fp32 and these three dtypes are independent of one another.
output/gate/residual has the same dtype with input.
residual and bias is optional.
There was a problem hiding this comment.
The models of GLM series have text module and vision module, and they call the different norm OP (They will finally use the kernel modified in this PR).
The type value in table means input_type/weight_type/bias_type.
| Model | text module(RMSnorm) | vision module(layernorm) |
|---|---|---|
| GLM4.x | BF16/BF16/BF16 | / |
| GLM4.xV/GLM_ocr | FP16/FP16/FP16 | BF16/FP32/FP32 |
There was a problem hiding this comment.
therefore:
- scalar_t (input) is either bf16 or fp16;
- param_t (weight and bias) is either same as scalar_t or acc_t (fp32)
weight and bias must be the same dtype.
use CPU_DISPATCH_FLOATING_TYPES_EXT and AT_DISPATCH_BOOL
| using weight_t = scalar_t; | ||
| if (bias.has_value()) { | ||
| AT_DISPATCH_REDUCED_FLOATING_TYPES_AND(at::kFloat, bias.value().scalar_type(), "layernorm_bias", [&] { | ||
| using bias_t = scalar_t; |
There was a problem hiding this comment.
therefore:
- scalar_t (input) is either bf16 or fp16;
- param_t (weight and bias) is either same as scalar_t or acc_t (fp32)
weight and bias must be the same dtype.
use CPU_DISPATCH_FLOATING_TYPES_EXT and AT_DISPATCH_BOOL
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| atol = rtol = precision[dtype] | ||
| atol = rtol = 5e-2 |
There was a problem hiding this comment.
why we have to do this ?
| vsum2 = _mm512_dpbf16_ps(vsum2, va[col], va[col]); | ||
| vsum2 = _mm512_fmadd_ps(va0[col], va0[col], vsum2); | ||
| vsum2 = _mm512_fmadd_ps(va1[col], va1[col], vsum2); |
There was a problem hiding this comment.
don't quite prefer this, but shouldn't be a big issue.
There was a problem hiding this comment.
We cannot assume the input is BF16, so I rewrote load and reduce here to support a wider range of input types.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@yuchengliu1 fix lint |
Enable GLM_OCR on XEON.
The input/weight/bias of Layernorm support fp16/bf16/fp32 and these three dtypes are independent of one another.
output/gate/residual has the same dtype with input.
residual and bias is optional.
Accuracy (using lmms_eval as cookbook advised):
CI States
Latest PR Test (Base): 🚫 Run #41797587595
Latest PR Test (Extra): ❌ Run #41797587468
Latest PR Test (AMD ROCm 10): ❌ Run #41797587439
Tip
Base CI only covers the core cases, and its workload may not exercise your change. Use
/rerun-testto run the tests your change touches, or copy this prompt for an agent: