EXHIBIT 05 / ACCELERATOR PORTING
Why can’t the same model move straight to a different accelerator?
A model definition may stay recognisable while the software stack underneath it changes. Porting means aligning versions, supplying operator implementations, converting representations, and checking numerical behaviour before performance tuning begins.
THE SHORT ANSWERRun. Match. Validate. Then optimise.
7–12 MIN · STEP-BY-STEP · NO ACCOUNTThree lines of application code can hide four engineering gates.
- 01 / VERSIONSAlign the stack
Driver, firmware, runtime, framework adapter, and Python packages must describe a supported combination.
- 02 / OPERATORSCover the graph
Every operation the model uses needs a correct implementation; an available but slow fallback is a separate problem.
- 03 / FORMATSTranslate representations
Weights and activations may need supported numerical formats. Changing representation changes storage and error behaviour.
- 04 / VALIDATIONCompare several signals
Running without an exception is not the same as matching a reference, and matching is not the same as being fast.
The porting sequence is based on public Ascend practice records. The terminal messages, version numbers, and operator counts in the teaching trace are illustrative; this museum did not benchmark two accelerators.
Move through the gates in the order failures usually surface.
Use the step controls to separate compatibility, correctness, and performance. They are different release decisions.
GATE 01
Compatibility before diagnosis
A low-level runtime error can be the visible symptom of a mismatched driver, toolkit, or framework adapter.
Check an official compatibility matrix before changing model code.
Keyboard: focus this record and use ← or →. Nothing advances automatically.
One recorded run, three failure shapes.
Choose a case from the real one-machine Python simulation. It compares code paths, not physical accelerators.
Only matrix-multiply inputs are rounded to BF16 representation; multiplication and accumulation still use Python double precision.
- Layer 1 cosine
- 0.999997
- Layer 1 max abs error
- 7.264e-03
- Layer 1 relative RMSE
- 2.362e-03
No single metric or universal threshold validates every operator. Maximum absolute error changes with scale; relative metrics and task-specific tolerances answer different questions.
The executable evidence isolates a blind spot in cosine similarity.
Four input rows, fixed seed 0, one machine, Python floating-point reference.
Illustrative threshold 0.999; layer 1 displays 1.000000 at six decimals.
Layer 1 maximum absolute error on the same values; it reveals a difference hidden by the displayed cosine.
One-machine code comparison
The Python script runs a reference path and three deliberately altered paths with fixed inputs.
Four error views
It reports cosine similarity, one minus cosine, maximum absolute error, RMSE, and relative RMSE by layer.
A hardware benchmark
No accelerator was measured. The first porting gates are teaching examples; only the alignment simulation was executed.
RECORDED RUN / EXECUTED
Inspect the result behind the interpretation.
In the recorded wrong-variance case, all eight layers passed cosine ≥ 0.999, while layer 1 maximum absolute error was 1.539e-02. The metrics exposed different properties of the same values.
Tracked content revision: d3c2df1da471433f3ff98b8b9c0c41b376b91993399e5aa50d0d7aac4227fc8c
Show exact lines from the original stdout
The program’s original labels are in Simplified Chinese; the lines and numbers below are copied without translation.
【情况二 · 算子写错了:方差除以 n-1 而不是 n】
1 1.000000 4.441e-16 1.539e-02 7.843e-03 7.843e-03 通过
余弦判定(门槛 0.999):8/8 层通过
三张表放在一起看:余弦判定在 3/3 种情况里都是「全部通过」, PRIMARY & PRACTICE SOURCES