[GH-ISSUE #4714] [Engine] Proposal: native Flint Q4_K_M support with hybrid expert execution #2159

Open
opened 2026-11-04 01:57:08 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @ec0byte on GitHub (Oct 30, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4714

Problem and goal

I would like RecursiveSI/Flint to become a first-class native model family in Strata:
selectable for download in the desktop app and runnable through the Terminal, alongside the
existing families.

I currently run Flint Q4_K_M in LM Studio with offloading. The goal is to bring Strata’s GPU
expert caching and CPU/GPU expert execution to Flint, with correct reasoning and coding-tool
support—not to connect Strata to an external inference runtime.

Related: #4649 requests Flint support using an NVFP4 pack. This proposal describes an
implementation starting with Q4_K_M. Please consolidate the discussions if preferred.

Initial target

  • Model: RecursiveSI/flint, 39.8B total parameters, approximately 2.5B active per token.
  • Pack: https://huggingface.co/lmstudio-community/flint-GGUF
  • File: flint-Q4_K_M.gguf
  • File size: 24,166,841,184 bytes.
  • First validation platform: Windows, NVIDIA CUDA.
  • Available test hardware: RTX 5070 Ti 16 GB, Ryzen 7 9850X3D, 32 GB DDR5.
  • Context: short-context correctness first, then qualification of a 65,536-token configuration.
  • Source revision inspected: 870aedd9e1ebe1c91f94da93b59af17729f6c5c0 (engine version 0.1.54 in CMakeLists.txt).

Additional packs and backends would require separate validation. The model’s configured 262,144-token capacity would not be advertised as validated Strata support.

Proposed implementation

Add an isolated Flint execution path, following the separate-family-driver pattern used for
Qwen3.6, while reusing compatible Strata components.

Flint-specific requirements include:

  • Two dense layers followed by 47 MoE layers.
  • Sigmoid routing to six of 256 experts, with selected weights normalized.
  • An always-active, ungated shared expert.
  • Per-head QK RMS normalization and learned attention sinks.
  • 35 sliding-window attention layers, using RoPE and a 513-token window.
  • 14 full-attention layers without RoPE.
  • Flint-specific pre-tokenization, chat template, stop conditions, reasoning history, and
    tool-call parsing.

Hybrid execution should retain frequently used experts in VRAM and execute nonresident experts
on the CPU. Placement must not alter routing decisions or substitute experts.

New functionality would be explicitly selected. Existing model families and default execution
paths should remain unchanged.

Investigation so far

This proposal was prepared with AI-assisted source inspection. The observations below
distinguish executed header checks from unconfirmed static analysis.

Performed

A read-only Python check used the repository’s tools/gguf_reader.py to inspect my local GGUF
header and compare it against an independently specified Flint tensor-layout table.

Observed output:

EXPECTED_TENSORS 779 ACTUAL_TENSORS 779 SHAPE_ERRORS [] EXTRA [] SPAN_ERRORS []
PATTERN_LENGTHS 49 49 SLIDING 35 FULL 14 ROPE_MATCHES_SLIDING True
HEADER_CONTRACT_PASS True

The check found:

  • All 779 expected tensors, with no unexpected tensor names.
  • No shape mismatches.
  • No tensor payload spans exceeding the next tensor offset or file boundary.
  • Matching 49-entry attention and RoPE patterns: 35 sliding layers and 14 full-attention
    layers.
  • Approximately 21.31 GiB of routed expert weights.
  • Q4_K gate/up weights throughout the routed experts.
  • Q4_K down weights in 24 MoE layers and Q6_K down weights in 23.

These checks establish structural consistency, not numerical correctness or full-file
integrity.

Unconfirmed static analysis

  • Existing CPU expert dispatch appears reusable for Flint’s quantization pairs, subject to
    compilation and runtime tests.
  • In src/kernels/cuda/iq_kernels.cu, grouped GPU expert dispatch lists Q4_K gate/up and
    conditionally Q6_K down, but does not list Q4_K down, which this pack requires.
  • Existing Qwen attention paths cannot be reused unchanged for Flint’s head dimensions,
    attention sinks, and ungated attention output.
  • tools/strata_tokenizer.py needs explicit Flint pre-tokenization rather than the current
    non-DeepSeek fallback.
  • Flint’s tool-call format differs from the existing Qwen-oriented format.
  • The native desktop catalog flows through setup.py and tools/strata_mcp.py; desktop-only
    catalog changes would be insufficient.
  • Own-path family handling contains Qwen-specific assumptions, including engine-version
    gating, that would need to be addressed for Flint.

Not performed

  • Native Flint implementation or compilation.
  • Numerical parity tests or Strata inference with Flint.
  • Hardware execution of the proposed kernel changes.
  • Controlled performance comparison.
  • Full-file checksum verification.

No speedup or native Strata memory-fit result is claimed.

Suggested milestones

  1. Model contract:

    • Family recognition and metadata/tensor-layout validation.
    • Explicit Flint geometry and per-layer attention patterns.
    • Reference tokenizer and chat-template tests.
    • Clear refusal when a build recognizes Flint but cannot execute it.
  2. Expert kernels:

    • Q4_K down-projection support in the grouped GPU path.
    • CPU/CUDA tests for Q4_K/Q4_K and Q4_K/Q6_K experts at Flint’s 2048 hidden / 512 expert
      dimensions.
    • Validation of both decode and prompt-processing paths.
  3. Native execution:

    • Correct prefill/decode.
    • Sigmoid top-six routing and ungated shared experts.
    • Sink-aware attention and per-layer RoPE behavior.
    • Bounded sliding-layer caches, including correct handling across prompt chunks.
  4. Hybrid execution:

    • GPU expert caching and CPU execution for misses.
    • Adaptive expert replacement without changing routing.
    • Startup and steady-state memory accounting.
  5. Coding-agent serving:

    • Streamed reasoning and tool calls.
    • Preservation of reasoning history where required by the template.
    • Tool-result follow-ups, cancellation, stop conditions, and conversation-cache
      correctness.
  6. Product integration:

    • Verified, resumable Q4_K_M download.
    • Local-file import/reuse.
    • Hardware-fit planning.
    • Normal desktop family selection and Terminal launch.
    • Packaged engine capability/version checks.
  7. Qualification:

    • 64K context testing on the hardware above.
    • Controlled comparison against LM Studio using the same GGUF and workloads.

Memory considerations

The initial target machine has 16 GB VRAM and 32 GB RAM. Combined capacity should not be
treated as a single interchangeable memory pool.

Planning and validation need to account for:

  • Host copies of GPU-cached experts.
  • Alignment and repacking overhead.
  • Full-attention KV storage.
  • Bounded sliding-layer KV storage.
  • Prompt staging and runtime buffers.
  • Startup peak memory and Windows headroom.

For one 65,536-token sequence, arithmetic estimates from Flint’s geometry put raw KV storage
at approximately 1.78 GiB with FP16 storage or 3.57 GiB with FP32 storage when sliding-layer
history is bounded.

These are calculations, not measured allocations, and exclude padding, staging, and runtime
overhead. Cache precision and context limits should be selected through correctness and
hardware validation.

Acceptance and regression requirements

  • Existing families and default execution paths remain unchanged, with explicit regression
    evidence.
  • Flint remains opt-in.
  • Numerical checks use pinned reference revisions, including a GGUF-capable reference using
    the same quantized file.
  • CPU/GPU placement is checked for numerical agreement without assuming bit-identical
    arithmetic across devices.
  • Tokenizer tests compare exact token IDs, not just encode/decode round trips.
  • Sliding-cache tests cover window boundaries, chunked prefill, and follow-up turns.
  • Coding-agent tests cover structured arguments, streamed tool calls, and tool-result history.
  • Performance measurements separate prompt processing, generation, and time to first token.
  • Comparisons use fresh runs on the same hardware and identify all relevant settings.
  • Every backend touched by shared changes receives the builds required by CONTRIBUTING.md.
    Hardware execution is reported separately from compilation.
  • Missing validation remains explicit, and implementation PRs remain draft where required.

Maintainer feedback requested

Before implementation, would this initial scope and separate-driver approach be acceptable?

In particular:

  • Is Q4_K_M a suitable first pack?
  • Is Windows/NVIDIA qualification acceptable as the initial target, with other platforms
    explicitly gated until validated?
  • Which existing expert-cache/offloading implementation should the Flint driver build upon?
  • How would you prefer this divided into reviewable PRs?

I can provide testing on the hardware above. Broader backend qualification would need
additional environments or contributors.

Originally created by @ec0byte on GitHub (Oct 30, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/4714 ## Problem and goal I would like RecursiveSI/Flint to become a first-class native model family in Strata: selectable for download in the desktop app and runnable through the Terminal, alongside the existing families. I currently run Flint Q4_K_M in LM Studio with offloading. The goal is to bring Strata’s GPU expert caching and CPU/GPU expert execution to Flint, with correct reasoning and coding-tool support—not to connect Strata to an external inference runtime. Related: #4649 requests Flint support using an NVFP4 pack. This proposal describes an implementation starting with Q4_K_M. Please consolidate the discussions if preferred. ## Initial target - Model: RecursiveSI/flint, 39.8B total parameters, approximately 2.5B active per token. - Pack: https://huggingface.co/lmstudio-community/flint-GGUF - File: `flint-Q4_K_M.gguf` - File size: 24,166,841,184 bytes. - First validation platform: Windows, NVIDIA CUDA. - Available test hardware: RTX 5070 Ti 16 GB, Ryzen 7 9850X3D, 32 GB DDR5. - Context: short-context correctness first, then qualification of a 65,536-token configuration. - Source revision inspected: `870aedd9e1ebe1c91f94da93b59af17729f6c5c0` (engine version 0.1.54 in CMakeLists.txt). Additional packs and backends would require separate validation. The model’s configured 262,144-token capacity would not be advertised as validated Strata support. ## Proposed implementation Add an isolated Flint execution path, following the separate-family-driver pattern used for Qwen3.6, while reusing compatible Strata components. Flint-specific requirements include: - Two dense layers followed by 47 MoE layers. - Sigmoid routing to six of 256 experts, with selected weights normalized. - An always-active, ungated shared expert. - Per-head QK RMS normalization and learned attention sinks. - 35 sliding-window attention layers, using RoPE and a 513-token window. - 14 full-attention layers without RoPE. - Flint-specific pre-tokenization, chat template, stop conditions, reasoning history, and tool-call parsing. Hybrid execution should retain frequently used experts in VRAM and execute nonresident experts on the CPU. Placement must not alter routing decisions or substitute experts. New functionality would be explicitly selected. Existing model families and default execution paths should remain unchanged. ## Investigation so far This proposal was prepared with AI-assisted source inspection. The observations below distinguish executed header checks from unconfirmed static analysis. ### Performed A read-only Python check used the repository’s `tools/gguf_reader.py` to inspect my local GGUF header and compare it against an independently specified Flint tensor-layout table. Observed output: EXPECTED_TENSORS 779 ACTUAL_TENSORS 779 SHAPE_ERRORS [] EXTRA [] SPAN_ERRORS [] PATTERN_LENGTHS 49 49 SLIDING 35 FULL 14 ROPE_MATCHES_SLIDING True HEADER_CONTRACT_PASS True The check found: - All 779 expected tensors, with no unexpected tensor names. - No shape mismatches. - No tensor payload spans exceeding the next tensor offset or file boundary. - Matching 49-entry attention and RoPE patterns: 35 sliding layers and 14 full-attention layers. - Approximately 21.31 GiB of routed expert weights. - Q4_K gate/up weights throughout the routed experts. - Q4_K down weights in 24 MoE layers and Q6_K down weights in 23. These checks establish structural consistency, not numerical correctness or full-file integrity. ### Unconfirmed static analysis - Existing CPU expert dispatch appears reusable for Flint’s quantization pairs, subject to compilation and runtime tests. - In `src/kernels/cuda/iq_kernels.cu`, grouped GPU expert dispatch lists Q4_K gate/up and conditionally Q6_K down, but does not list Q4_K down, which this pack requires. - Existing Qwen attention paths cannot be reused unchanged for Flint’s head dimensions, attention sinks, and ungated attention output. - `tools/strata_tokenizer.py` needs explicit Flint pre-tokenization rather than the current non-DeepSeek fallback. - Flint’s tool-call format differs from the existing Qwen-oriented format. - The native desktop catalog flows through `setup.py` and `tools/strata_mcp.py`; desktop-only catalog changes would be insufficient. - Own-path family handling contains Qwen-specific assumptions, including engine-version gating, that would need to be addressed for Flint. ### Not performed - Native Flint implementation or compilation. - Numerical parity tests or Strata inference with Flint. - Hardware execution of the proposed kernel changes. - Controlled performance comparison. - Full-file checksum verification. No speedup or native Strata memory-fit result is claimed. ## Suggested milestones 1. Model contract: - Family recognition and metadata/tensor-layout validation. - Explicit Flint geometry and per-layer attention patterns. - Reference tokenizer and chat-template tests. - Clear refusal when a build recognizes Flint but cannot execute it. 2. Expert kernels: - Q4_K down-projection support in the grouped GPU path. - CPU/CUDA tests for Q4_K/Q4_K and Q4_K/Q6_K experts at Flint’s 2048 hidden / 512 expert dimensions. - Validation of both decode and prompt-processing paths. 3. Native execution: - Correct prefill/decode. - Sigmoid top-six routing and ungated shared experts. - Sink-aware attention and per-layer RoPE behavior. - Bounded sliding-layer caches, including correct handling across prompt chunks. 4. Hybrid execution: - GPU expert caching and CPU execution for misses. - Adaptive expert replacement without changing routing. - Startup and steady-state memory accounting. 5. Coding-agent serving: - Streamed reasoning and tool calls. - Preservation of reasoning history where required by the template. - Tool-result follow-ups, cancellation, stop conditions, and conversation-cache correctness. 6. Product integration: - Verified, resumable Q4_K_M download. - Local-file import/reuse. - Hardware-fit planning. - Normal desktop family selection and Terminal launch. - Packaged engine capability/version checks. 7. Qualification: - 64K context testing on the hardware above. - Controlled comparison against LM Studio using the same GGUF and workloads. ## Memory considerations The initial target machine has 16 GB VRAM and 32 GB RAM. Combined capacity should not be treated as a single interchangeable memory pool. Planning and validation need to account for: - Host copies of GPU-cached experts. - Alignment and repacking overhead. - Full-attention KV storage. - Bounded sliding-layer KV storage. - Prompt staging and runtime buffers. - Startup peak memory and Windows headroom. For one 65,536-token sequence, arithmetic estimates from Flint’s geometry put raw KV storage at approximately 1.78 GiB with FP16 storage or 3.57 GiB with FP32 storage when sliding-layer history is bounded. These are calculations, not measured allocations, and exclude padding, staging, and runtime overhead. Cache precision and context limits should be selected through correctness and hardware validation. ## Acceptance and regression requirements - Existing families and default execution paths remain unchanged, with explicit regression evidence. - Flint remains opt-in. - Numerical checks use pinned reference revisions, including a GGUF-capable reference using the same quantized file. - CPU/GPU placement is checked for numerical agreement without assuming bit-identical arithmetic across devices. - Tokenizer tests compare exact token IDs, not just encode/decode round trips. - Sliding-cache tests cover window boundaries, chunked prefill, and follow-up turns. - Coding-agent tests cover structured arguments, streamed tool calls, and tool-result history. - Performance measurements separate prompt processing, generation, and time to first token. - Comparisons use fresh runs on the same hardware and identify all relevant settings. - Every backend touched by shared changes receives the builds required by CONTRIBUTING.md. Hardware execution is reported separately from compilation. - Missing validation remains explicit, and implementation PRs remain draft where required. ## Maintainer feedback requested Before implementation, would this initial scope and separate-driver approach be acceptable? In particular: - Is Q4_K_M a suitable first pack? - Is Windows/NVIDIA qualification acceptable as the initial target, with other platforms explicitly gated until validated? - Which existing expert-cache/offloading implementation should the Flint driver build upon? - How would you prefer this divided into reviewable PRs? I can provide testing on the hardware above. Broader backend qualification would need additional environments or contributors.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#2159
No description provided.