Skip to content

Fix conv1d/conv3d static shape loss in HLO trace (#530)#531

Merged
michalharakal merged 1 commit intodevelopfrom
fix/530-static-conv1d-hlo-shape
Apr 19, 2026
Merged

Fix conv1d/conv3d static shape loss in HLO trace (#530)#531
michalharakal merged 1 commit intodevelopfrom
fix/530-static-conv1d-hlo-shape

Conversation

@michalharakal
Copy link
Copy Markdown
Contributor

Fixes #530.

Summary

  • DefaultExecutionTape.recordTrace now falls back to TensorRef.shape.dimensions.toList() and TensorRef.dtype.name when the trace's inputShapes / outputShapes / inputDTypes / outputDTypes attributes are absent.
  • The KSP tracer wrapper only emits those attributes for a conv2d-specific factory and an allowlist of unary/binary/scalar/shape ops. conv1d and conv3d fell through AttributeStrategy.DefaultMapping and recorded only scalar params — producing TensorSpec(shape = null) and tensor<?xf32> in the emitted MLIR (12 occurrences in the Whisper encoder, which blocks iree-compile).
  • The TensorRef already carries the correct static Shape captured from the runtime tensor, so this is a free, always-correct fallback.

Test plan

  • New regression test DefaultExecutionTapeTest.recordTrace_without_shape_attributes_falls_back_to_tensor_ref_shape synthesizes a conv1d OpTrace with only stride/padding/dilation/groups and asserts the recorded TensorSpec.shape is the static [1, 384, 3000] (output) / [1, 80, 3000] (input) / [384, 80, 3] (weight) from the TensorRef.
  • ./gradlew :skainet-compile:skainet-compile-dag:jvmTest --tests 'sk.ainet.compile.grad.DefaultExecutionTapeTest.*' passes locally.
  • End-to-end verification on skainet-whisper's WhisperHloExportTest + iree-compile (depends on bumping the skainet version in that repo).

Out of scope

  • RecordingTensorOpsDecorator.conv1d / .conv3d in skainet-compile-core still skip record(...) entirely (unlike conv2d). Filed as a separate follow-up — the Whisper path doesn't exercise that decorator today, so it isn't load-bearing for the reported bug.

🤖 Generated with Claude Code

The KSP-generated tracer wrapper only populates outputShapes/inputShapes
attributes for a hard-coded allowlist (conv2d, unary/binary/scalar ops,
shape ops). conv1d and conv3d fall through AttributeStrategy.DefaultMapping,
which records only stride/padding/dilation/groups.

Without the shape attributes, DefaultExecutionTape.recordTrace built
TensorSpecs with shape=null, and the StableHLO converter emitted
tensor<?xf32> for conv1d output (12 occurrences in the Whisper encoder),
which iree-compile rejects as a type mismatch against the static bias.

The TensorRef in the trace already carries the correct static Shape
captured from the runtime tensor, so use it as the fallback. Same
treatment for dtype.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@michalharakal michalharakal merged commit 2e3a959 into develop Apr 19, 2026
4 checks passed
@michalharakal michalharakal deleted the fix/530-static-conv1d-hlo-shape branch April 19, 2026 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

conv1d/conv3d emit tensor<?xf32> in HLO output due to missing shape attributes on tape

1 participant