es-ude / es-ude/OnDeviceTraining

serial: LINEAR arm serializes/deserializes bias unconditionally — BIAS_FALSE Linear crashes ODTS round-trip

Open
#391 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C
Stars
1
Forks
3
Avg merge
1d 1h
Merged PRs (30d)
8

Description

## Problem

Found during #380 PR1 review (pre-existing, unrelated to freezing):

- `src/serial/Serialize.c:147` — the LINEAR arm calls `serializeParameter(linearConfig->bias, f)` **unconditionally**. A Linear layer built with `.bias = BIAS_FALSE` has `cfg->bias == NULL` (header-sanctioned), so serializing it NULL-derefs.
- `src/serial/Deserialize.c:204` — the LINEAR arm has the **mirror bug** on the read side.

The Conv1d and Conv1dTransposed arms already handle this correctly with a `hasBias` presence byte (`Serialize.c:160/179`) — the fix is to copy that pattern into both LINEAR arms.

## Impact

Any BIAS_FALSE Linear model crashes `serializeModel`/`deserializeModel`. Currently latent because all serial-test fixtures use default (present) bias.

## Fix sketch

- LINEAR serialize arm: write `u8 hasBias` before the bias record, skip when NULL (Conv1d arm as template).
- LINEAR deserialize arm: read + validate against the skeleton (same presence-vs-skeleton mismatch fail-fast the parameter-tier grad byte got in #380 PR1).
- Wire format: this changes the LINEAR record layout → needs a version bump (v3→v4) or can ride along with the next planned bump; update the wire pins in `test/unit/serial/UnitTestSerialize.c`.
- Regression tests: BIAS_FALSE Linear round-trip + mismatch death test.

Contributor guide

Open the contributing guide

Research direction

Start in src/serial/Serialize.c:147 and src/serial/Deserialize.c:204, using the Conv1d presence-byte handling at the nearby serialization arms as the reference. Then inspect the wire pins in test/unit/serial/UnitTestSerialize.c and the existing serialization versioning before updating the format. Done means BIAS_FALSE Linear models round-trip safely, presence mismatches fail fast, and the regression and wire-format tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
embedded-iot
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.