Skip to content

feat(tensor): HissReshaper pure-binary QTT with reversible index mapping (STUB #254) - #5112

Merged
makr-code merged 2 commits into
developfrom
copilot/implement-pure-binary-qtt
May 13, 2026
Merged

makr-code merged 2 commits into
developfrom
copilot/implement-pure-binary-qtt

Conversation

Copilot AI commented May 13, 2026 •

Copy link
Copy Markdown
Contributor

HissReshaper::exposeQuantics() produced a valid pure-binary padded-QTT layout but exposed no way to convert between flat physical indices (original unpadded tensor) and flat QTT indices (all-2 quantics-mode tensor), making lossless roundtrips and padding detection impossible for callers.

Changes

include/tensor/hiss_structural_search.h

  • New QTTMappingDescriptor struct:
    • physicalToQTT(size_t) → size_t — O(D·B), MSB-first bit encoding per dimension
    • qttToPhysical(size_t) → optional<size_t> — inverse; std::nullopt for zero-padded QTT slots
  • QTTrain gains mapping: QTTMappingDescriptor field (always populated by built-in path)
  • Removed stale STUB-bridge comments; QuanticsFn docs note custom backends must populate mapping themselves

src/tensor/hiss_structural_search.cpp

  • Implemented both mapping methods; O(D·B) flat-index ↔ multi-index ↔ packed-bits round-trip
  • exposeQuantics() now fills qt.mapping after decomposition
  • Removed dead quanticsFactors() helper (residual-factor approach, never called)

tests/test_tensor_hiss_structural_search.cpp

Six new tests (THSS-14 – THSS-19):

ID Coverage
THSS-14 Power-of-2 bijection: all 64 physical indices round-trip, QTT results unique
THSS-15 Non-power-of-2 [3,5]→[4,8]: all 15 physical indices round-trip
THSS-16 Padding detection: exactly padded – physical slots return nullopt
THSS-17 Edge case: dimension of size 1
THSS-18 exposeQuantics() populates mapping fields consistently with QTTrain metadata
THSS-19 Dense value round-trip via mapping; padding slots ≈ 0.0

Example usage

QTTrain qtt = HissReshaper::exposeQuantics(train, {3, 5});
// qtt.mapping.grid_sizes        == {3, 5}
// qtt.mapping.padded_grid_sizes == {4, 8}
// qtt.mapping.bit_depths        == {2, 3}

size_t qtt_idx = qtt.mapping.physicalToQTT(7);          // {1,2} → bit-packed QTT flat idx
auto   phys    = qtt.mapping.qttToPhysical(qtt_idx);    // == 7
auto   padding = qtt.mapping.qttToPhysical(31);         // == nullopt  (padding slot)

Linked Issues

Closes #254

Type of Change

  • Bug fix (non-breaking)
  • New feature (non-breaking)
  • Refactoring (non-breaking)
  • Documentation
  • Breaking change (requires MAJOR version bump — see VERSIONING.md)
  • Security fix
  • Other:

Breaking Change Checklist

  • MAJOR version bump planned in VERSION and CMakeLists.txt
  • Migration guide added in docs/migration/
  • Announcement prepared for GitHub Discussions (≥ 2 weeks before release)
  • CHANGELOG ### Removed / ### Changed section updated

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed
  • Benchmarks run (if performance-sensitive change)

📚 Research & Knowledge (wenn applicable)

  • Diese PR basiert auf wissenschaftlichen Paper(s) oder Best Practices?
    • Falls JA: Research-Dateien in /docs/research/ angelegt?
    • Falls JA: Im Modul-README unter "Wissenschaftliche Grundlagen" verlinkt?
    • Falls JA: In /docs/research/implementation_influence/ eingetragen?

Relevante Quellen:

  • Paper:
  • Best Practice:
  • Architecture Decision:

AI-Generated Code (KI-generierter Code)

  • Symbol-Referenzen mit GetSymbolReferences_CppTools geprüft (siehe .github/instructions/cpp-language-service-tools.instructions.md)
  • Keine rohen Pointer und kein new/delete ohne explizites Review eingeführt
  • RAII und Exception-Safety für neue/angepasste Pfade geprüft — all mapping methods are const, exception-safe, no resource ownership
  • Keine unnötig komplexen KI-Abstraktionen eingeführt
  • Performance-Metriken geprüft, falls Hotpath betroffen

Checklist

  • Code follows project style guidelines (clang-format / clang-tidy)
  • Self-review completed
  • Documentation updated (if needed) — include/tensor/README.md updated; src/STUB_INVENTORY.md entry 254 updated
  • CHANGELOG.md updated under [Unreleased]
  • No new warnings introduced
  • Security-sensitive paths reviewed by security maintainer (if applicable)

Copilot AI changed the title [WIP] Implement pure-binary QTT with reversible index mapping feat(tensor): HissReshaper pure-binary QTT with reversible index mapping (STUB #254) May 13, 2026
Copilot AI requested a review from makr-code May 13, 2026 18:57
@makr-code
makr-code marked this pull request as ready for review May 13, 2026 18:59
@makr-code
makr-code merged commit 26eaef3 into develop May 13, 2026
14 of 18 checks passed
@github-actions github-actions Bot added type:documentation Documentation change type:test Test-only change area:storage Storage subsystem area:vector Vector search subsystem area:graph Graph subsystem area:acceleration Acceleration / GPU / CUDA subsystem ai-generated AI-assisted change; requires maintainer review before merge labels May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated AI-assisted change; requires maintainer review before merge area:acceleration Acceleration / GPU / CUDA subsystem area:graph Graph subsystem area:storage Storage subsystem area:vector Vector search subsystem type:documentation Documentation change type:test Test-only change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Tensor] HissReshaper: pure-binary QTT mit reversibler Index-Abbildung implementieren

2 participants