Repository navigation
Measure ICLabel at 4 bits and keep int8 as the default - #398
neuromechanist wants to merge 4 commits into
Conversation
Builds a blocked uint4 Conv-weight artifact from the frozen float32 export and scores it against the same frozen evaluation set the int8 path uses. The check script exercises an artifact under the pinned onnxruntime-web build, since native onnxruntime support is not evidence for the browser.
1,931,262 bytes against 2,932,897 for the shipped int8 artifact, passing the same frozen gate at 100% top-1 and 100% keep-or-reject agreement. Kept beside the int8 candidates so the report's hashes stay checkable.
There was a problem hiding this comment.
If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.
Once extra usage is available, reopen this pull request to trigger a review.
|
Claude encountered an error after 0s —— View job I'll analyze this and get back to you. |
On the two classes nobody has measuredRecording this so the gap is documented rather than rediscovered. Heart and Channel Noise have zero components in every recording this repository I tried to close it inside this task and did not. I pulled four 63-channel What can be said without those components is a bound rather than a measurement. What would make 4 bits worth revisitingA single checkable threshold: if the ICLabel artifact ever has to fit under The second thing that would change the answer is a real Heart or Channel Noise |
Skips where onnxruntime predates 1.19, which refuses uint4 tensors outright, so an older runtime names the floor instead of failing obscurely.
d620ce1 to
d89a2fc
Compare
d89a2fc to
ec39ce6
Compare
|
Closing: 4-bit is shelved. It works, and there is not enough to gain. The full verdict, the size table, the parity numbers and a checkable threshold for revisiting are recorded on #379 (#379 (comment)) rather than here, so they outlive this branch. Short version: int8 at 2,932,897 B already meets the size target this was aimed at, int4 reaches 1,931,262 B but costs an opset-21 floor and an onnxruntime 1.19 minimum and buys no speed. Revisit if the artifact ever has to fit under 2.5 MB. Nothing shipped changed here: One piece of this may be worth salvaging separately from 4-bit. The branch |
Summary
Answers whether ICLabel is worth shipping at 4 bits, on measurements rather than
arithmetic. The short version: 4-bit works end to end, including in the browser,
and it should still not replace int8.
This does not change the packaged artifact.
iclabel.onnxis still theweight-only int8 network from #383, and a test now pins that.
Can ONNX Runtime Web execute 4-bit ICLabel today
Yes. This was the leg most likely to fail, so it was checked first.
The network is 10
Convnodes and nothing else: noMatMul, noGemm. SoMatMulNBits, which is where most 4-bit ONNX tooling lives, has nothing toattach to. The portable representation is a
uint4initializer behind a blockedDequantizeLinearfeeding the existing floatConv, and the pinnedonnxruntime-web1.30.0 WebAssembly build runs exactly that:graphOptimizationLevel: "disabled", so the 4-bit kernel reallyexecutes rather than being constant-folded away at session load
byte-identical to the Node WebAssembly run of the same artifact
tools/iclabel/check_iclabel_ort_web.mjsreproduces the checkMeasured sizes, and the 3-4 MB target
Naive arithmetic was right and the 3-4 MB target was not. All 2,903,817
parameters are Conv weights, with no biases of consequence, no embeddings and no
unquantizable layers to dilute the ratio, so int8 lands at a clean 3.96x and
int4 at 6.02x. int8 already sits under the 3-4 MB target; 4 bits overshoots
it to 1.9 MB rather than reaching it.
ICLabel is no longer what makes the wheel big
Worth knowing before anyone reaches for 4 bits again. Compressed members of the
current int8 wheel:
eegprep/resources/dipfiteegprep/plugins/ICLabelint8 already moved ICLabel below the DIPFIT resources. If the goal is a smaller
browser payload rather than a smaller ICLabel, the 3.8 MB of DIPFIT head-model
data is the larger lever, and 4-bit ICLabel cannot reach a 3-4 MB wheel on its
own from either side.
Parity
On the frozen 217-component subject-disjoint set from #379, int4 matches the
float32 teacher on 100% of top-1 labels and 100% of keep-or-reject decisions,
clearing the same gate int8 clears.
Pooled over every real component available (466: both frozen splits plus the
EEGLAB tutorial recording), int4 and int8 are identical at the label level,
per class:
Heart and Channel Noise do not occur in any component of the available
recordings, so neither int8 nor int4 has ever been measured on them. That gap
predates this PR and is stated rather than papered over.
int4 does perturb the probabilities about 3.4x more than int8: maximum absolute
change of 4.5e-2 against 1.3e-2. The float32 teacher's top-1-to-top-2 margin has
a 1st percentile of 0.0218, so int4's worst case could in principle reach 16 of
466 components where int8 could reach 6. One component actually flips, the same
one, for both.
Recommendation: keep int8
graph with
MLDataType for: tensor(uint4) is not currently registered, so thefloor in
pyproject.tomlwould have to move to 1.19float32 under ONNX Runtime Web, because weight-only 4-bit dequantizes to float
before the same float Conv
It is worth revisiting if the browser download budget ever forces the ICLabel
artifact below 2.5 MB, since that is a threshold int8 cannot reach and int4 can.
Testing
tests/test_iclabel_int4.py, six tests, all passing alongside the existingtests/test_iclabel_quantization.pysuite (16 passing together). The parity gatewas verified to actually fail on a deliberately 2-bit-damaged model (90.78%
top-1), so a pass means something.
Pre-existing unrelated failures on this machine: the three
test_iclabel.pyandtest_iclabel_features.pycases that need a MATLAB runtime.