Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions families/muse_glimmer/build_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

from tensorrt_model_connect.graph_transform import GraphTransform

from .vision import MEDIA_TASKS


def _validate_id(field: str, value: str) -> None:
if not isinstance(value, str) or re.fullmatch(r"[a-z][a-z0-9_]*", value) is None:
Expand All @@ -20,7 +22,7 @@ def _validate_id(field: str, value: str) -> None:

@dataclass(frozen=True)
class BuildRequest:
"""Family-owned inputs for the admitted Muse-Glimmer NVFP4 text modes."""
"""Family-owned inputs for original and prepared Muse-Glimmer checkpoints."""

model_dir: Path
output_path: Path
Expand All @@ -35,11 +37,12 @@ class BuildRequest:
max_batch_size: ClassVar[int] = 1
tensor_parallel_size: ClassVar[int] = 1
context_parallel_size: ClassVar[int] = 1
quantization: str | None = "nvfp4"
quantization: str | None = None
fp32_layers: ClassVar[tuple[int, ...]] = ()
dynamic_kv_cache: ClassVar[bool] = False
execution_variant: str = "autoregressive"
companion: Path | None = None
edge_builder_python: Path | None = None
verbose: bool = False
graph_transform: GraphTransform | None = None

Expand All @@ -48,20 +51,20 @@ def __post_init__(self) -> None:
_validate_id("task", self.task)
if self.family != "muse_glimmer":
raise ValueError("Muse-Glimmer request family must be muse_glimmer")
if self.task != "text_generation":
raise ValueError("Muse-Glimmer supports only task=text_generation")
if self.task not in ("text_generation", *MEDIA_TASKS):
raise ValueError("Unsupported Muse-Glimmer generation task")
if self.precision != "fp16":
raise ValueError("Muse-Glimmer supports only precision=fp16")
if self.backend != "trt":
raise ValueError("Muse-Glimmer supports only backend=trt")
if self.max_sequence_length is not None and self.max_sequence_length < 1:
raise ValueError("max_sequence_length must be positive")
if self.quantization not in {None, "none", "nvfp4"}:
raise ValueError("Muse-Glimmer supports only quantization=nvfp4")
if self.execution_variant not in {"autoregressive", "dflash"}:
raise ValueError("Muse-Glimmer supports autoregressive or dflash execution")
if (self.execution_variant == "dflash") != (self.companion is not None):
raise ValueError("Muse-Glimmer dflash requires exactly one companion")
raise ValueError("Muse-Glimmer requires source weights or prepared nvfp4 quantization")
if self.execution_variant not in {"autoregressive", "dflash", "dflash_tree"}:
raise ValueError("Muse-Glimmer supports autoregressive, dflash or dflash_tree execution")
if (self.execution_variant != "autoregressive") != (self.companion is not None):
raise ValueError("Muse-Glimmer paired execution requires exactly one companion")
if self.graph_transform is not None:
raise NotImplementedError("Muse-Glimmer Edge offload does not support graph_transform")

Expand Down
15 changes: 10 additions & 5 deletions families/muse_glimmer/checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,17 @@ def canonical_module(name: str) -> str:
class Checkpoint:
"""Family-local indexed safetensors reader; never calibrates or rewrites weights."""

def __init__(self, model_dir: Path):
def __init__(self, model_dir: Path, *, source_format: str = "nvfp4"):
self.path = Path(model_dir)
descriptor = json.loads((self.path / "hf_quant_config.json").read_text(encoding="utf-8"))
layers = descriptor.get("quantization", {}).get("quantized_layers")
if not isinstance(layers, dict):
raise ValueError("Muse requires an explicit per-module quantization descriptor")
if source_format == "floating":
layers = {}
elif source_format == "nvfp4":
descriptor = json.loads((self.path / "hf_quant_config.json").read_text(encoding="utf-8"))
layers = descriptor.get("quantization", {}).get("quantized_layers")
if not isinstance(layers, dict):
raise ValueError("Muse requires an explicit per-module quantization descriptor")
else:
raise ValueError(f"Unknown Muse source weight format: {source_format}")
self.formats = {}
for name, policy in layers.items():
name = canonical_module(name)
Expand Down
20 changes: 16 additions & 4 deletions families/muse_glimmer/cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"commands": [
{
"name": "build",
"help": "Build one Muse-Glimmer NVFP4 TensorRT Edge-LLM bundle",
"help": "Build a Muse-Glimmer TensorRT bundle",
"executor": "python",
"handler": "cli:build",
"arguments": [
Expand Down Expand Up @@ -35,7 +35,9 @@
],
"type": "string",
"choices": [
"text_generation"
"text_generation",
"images_text_to_text",
"video_text_to_text"
],
"default": "text_generation"
},
Expand Down Expand Up @@ -75,9 +77,10 @@
],
"type": "string",
"choices": [
"none",
"nvfp4"
],
"default": "nvfp4"
"help": "Preserve the source checkpoint format; nvfp4 explicitly requires prepared mixed weights"
},
{
"name": "verbose",
Expand All @@ -96,7 +99,8 @@
"type": "string",
"choices": [
"autoregressive",
"dflash"
"dflash",
"dflash_tree"
],
"default": "autoregressive"
},
Expand All @@ -107,6 +111,14 @@
],
"type": "string",
"help": "Matched Muse assistant or DFlash2 checkpoint"
},
{
"name": "edge_builder_python",
"flags": [
"--edge-builder-python"
],
"type": "path",
"help": "Python interpreter with the ONNX exporter matching the installed Edge SDK"
}
]
}
Expand Down
4 changes: 3 additions & 1 deletion families/muse_glimmer/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ def build(
precision: str = "fp16",
backend: str = "trt",
max_sequence_length: int | None = None,
quantization: str = "nvfp4",
quantization: str | None = None,
execution_variant: str = "autoregressive",
companion: str | None = None,
edge_builder_python: Path | None = None,
verbose: bool = False,
) -> int:
"""Resolve a checkpoint and invoke family-owned Edge or native selection."""
Expand All @@ -61,6 +62,7 @@ def build(
execution_variant=execution_variant,
companion=resolve_model(companion, None) if companion is not None else None,
verbose=verbose,
edge_builder_python=edge_builder_python,
)
build_bundle(request, output)
return 0
148 changes: 132 additions & 16 deletions families/muse_glimmer/edge_llm/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,122 @@
# Muse-Glimmer with Edge-LLM 0.11
# Muse-Glimmer with Edge-LLM

The `muse_glimmer` family owns complete-network offload, argument mapping,
engine assets, runtime orchestration, and validation. It uses the official
Edge 0.11.0 snapshot `95515c2f87fba8982db5a519f9022277667b3cc9`; no shared-core
model selection is added.
engine assets, runtime orchestration, and validation. Edge 0.11 remains the
default SDK during migration. To select 0.12, configure Model Connect with
`-DTRTMC_ENABLE_EDGELLM=ON -DTRTMC_EDGELLM_RELEASE=0.12.0`.

## Edge 0.12

Muse needs both `-DTRTMC_EDGELLM_ONNX=ON` and
`-DTRTMC_EDGELLM_ALL_KERNELS=ON`. Follow the
[SDK provisioning guide](../../../cmake/edge_llm/README.md) to build on the
target GPU. If CMake finds an external SDK, point `TRTMC_EDGELLM_SOURCE_DIR`
at the populated, pinned Edge checkout: the upstream binary SDK does not
attest which kernel groups it contains.

A packaged runner uses its own SDK. For a standalone runner, set
`CMAKE_PREFIX_PATH` to the Model Connect SDK installation containing
`share/trtmc/edge-llm.json`. Use an isolated Python environment
with the matching 0.12 exporter (wheel or source installation), Transformers
5.17.0 and the same TensorRT version as the SDK. Pass its absolute interpreter
path to the family; the wheel alone does not provide the native runtime. For example:

## Dependency and execution
```sh
trtmc muse_glimmer build /models/muse-nvfp4 \
--precision fp16 --quantization nvfp4 --max-sequence-length 1024 \
--edge-builder-python /opt/edge-exporter/bin/python -o muse.bundle
```

The optional 0.12 route uses the released ONNX exporter and C++ builders on the
target device. Its architecture and CUDA/TensorRT versions must match the
installed SDK. The 0.11 SM120 offload restriction does not apply to 0.12.
A builder failure emits a warning and retries the original request with the
family's native TensorRT implementation. Neither a change in precision nor
dropping the draft is a valid fallback.

The prepared NVFP4 checkpoint is **text-only**. Ordinary decoding and both
documented DFlash pairs have run through the 0.12 Edge backend. This is not
a lossless speculative-decoding or accuracy claim. In particular the released
runner can return different greedy outputs with and without speculation on
the same V1 or V2 paired engine. Thinking mode also affects the output boundary:
with thinking disabled, the chat template supplies the public-channel header
in the prompt, not the generated tokens. Both routes omit checkpoint-declared
special tokens from display text while retaining the actual generated IDs.
The scientific terms and generation budget are the same in both modes.

For original floating checkpoints, request `--precision fp16 --quantization none`;
the adapter uses original weights. Building a typed image/video task requires the
original processor and visual weights. For example:

```sh
trtmc muse_glimmer build /models/Muse-Glimmer-30B \
--task images_text_to_text --precision fp16 --quantization none \
--max-sequence-length 1024 --edge-builder-python /opt/edge-exporter/bin/python \
-o muse-media.bundle
```

The six documented combinations below built and ran through both Model Connect
routes at batch 1 and TP1. The results are for the tested checkpoints, prompts
and profile, not for every GPU, prompt, or sampling mode.

| Checkpoint | Decoding | Quality observed |
| --- | --- | --- |
| Original FP16 | Autoregressive | Both routes gave factual answers in both thinking modes, distinguished opposed images and both video orders, and matched token IDs on all six requests. |
| Original FP16 | DFlash V1 and V2, each with its own companion | Both routes passed the same four media checks and both factual text checks for each pair. On each backend and pair, the six greedy outputs matched target-only execution of that same engine token for token. |
| Prepared NVFP4 (text only) | Autoregressive | Both routes returned factual answers in both thinking modes. No media weights are present. |
| Prepared NVFP4 (text only) | DFlash V1 | Native matched its own target in both thinking modes. In the released Edge runner, speculative and target-only outputs differed; with thinking enabled both reached the token cap. The Model Connect Edge run returned a factual answer, so the capped result is specific to the direct control. |
| Prepared NVFP4 (text only) | DFlash V2 | Native matched its own target in both modes. The released Edge runner returned different greedy answers with and without speculation. Model Connect Edge matched the released speculative answers in both modes. |

The scientific-answer test runs both modes on one bundle. With thinking off,
it checks a direct answer without a generated private turn. With thinking on,
it checks the answer after the generated public-channel delimiter. Terms found
only in reasoning do not count. Separately, both the native and the released FP16 visual encoders exceeded the pointwise
tolerance against the eager reference on identical inputs. Correct media answers
do not establish encoder tensor parity. These quality limitations do not disable
the corresponding build or inference commands.

### DFlash2 tree decoding

Use the original FP16 or prepared NVFP4 target with its matched
`incoai/Muse-Glimmer-30B-DFlash2` companion. For example:

```sh
trtmc muse_glimmer build /models/muse-nvfp4 \
--precision fp16 --quantization nvfp4 --max-sequence-length 1024 \
--execution-variant dflash_tree --companion /models/muse-dflash2 \
--edge-builder-python /opt/edge-exporter/bin/python -o muse-tree.bundle
```

The 0.12 Edge builder sets a 32-node verification profile on the target
and keeps the draft's block size at 16. At runtime, the tree retains up to four
children per node. Native TensorRT uses the same conditional selector and
verifies tokens against the target along the accepted path; it does not batch
all nodes into one target call. Both routes reject stochastic generation for an
explicit tree. Use `dflash` for the chain. The chain results above do not
establish tree accuracy.

On the original FP16 target, the tree built and ran on both routes. Both
passed the thinking-enabled science check and distinguished the two images
and both video orders. With thinking disabled, both gave a factual answer but
did not generate the header that the earlier test expected. Native matched target-only token IDs on all
six requests; Edge matched on five. On the red-then-blue video, the Edge tree
separated the two correct colors with a comma, while target-only used a
newline. The direct Edge runner also produced different text with speculation
enabled and disabled on the same engines for the two science requests; both
settings reached the 512-token cap. These observations do not establish the
cause of the difference.

For the prepared NVFP4 target, both tree routes built and generated answers
with thinking disabled and enabled. Native returned the same 38 and 171
token IDs as its own target-only engine, respectively. Both routes missed
the earlier test's generated-header check with thinking disabled; the template
already supplies that header. With thinking
enabled, native passed; the Edge answer said “solid water” rather than either
term accepted by the test (“ice” or “crystal”). The released Edge runner also
produced different text with tree verification enabled versus disabled on the
same engine and prompt. These are accuracy limitations, not command failures.

## Edge 0.11 dependency and execution

Provision the native Edge SDK using Model Connect's optional CMake dependency
with the ONNX tools and complete native kernels. Expose its installation
Expand All @@ -20,7 +131,7 @@ has no SM allowlist: TensorRT must support its packed-format operators and the
device must have sufficient memory. Neither route cross-compiles, recalibrates,
or replaces the source precision recipe.

## Documented text configurations
## Documented prepared text configurations

The base is `RadixArk/Muse-Glimmer-NVFP4`, revision
`1416629950afdfb276618fd4810103681dd10f4a`.
Expand All @@ -46,26 +157,25 @@ trtmc muse_glimmer build /models/muse-nvfp4 \
--companion /models/matched-muse-draft
```

The recorded profile is TP1/batch1/input512/KV1024, with a full block size 16
The documented text examples use a profile of TP1/batch1/input512/KV1024, with a full block size 16
verification profile for paired execution. Both base and draft must build;
a failed pair is never replaced by an autoregressive bundle. DFlash V1 requires
greedy generation. DFlash V2 does not add the V1 greedy-only restriction; local paired
qualification uses greedy generation only. Unsupported controls, such as a
seed override, remain explicit errors in the Edge route. The native runtime
supports its seeded sampler and rejects unsupported controls before execution.
DDTree is not exposed.
The 0.11 Edge offload does not support DDTree.

## Quality and limitations
## Legacy 0.11 quality and limitations

The existing owning E2E retains its scientific prompt, low-reasoning system
message, 512-token generation budget, and final-answer semantic checks. Muse's
ATEM output must reach `assistant to=user`; a response that stops in the
reasoning channel is not a passing answer.
thinking-enabled ATEM output must reach `assistant to=user`; a response
that stops in the reasoning channel is not a passing answer.

The original `meta-models/Muse-Glimmer-30B` FP16 text/image/video checkpoint
exceeds the available compatible single-device capacity. It and its FP16
paired modes have no executed qualification or adapter route here. No
unqualified tensor-parallel alternative is implied. The documented NVFP4
The 0.11 validation did not run the original FP16 checkpoint or its paired
modes: the compatible test device had insufficient memory. This describes
that validation environment, not a general GPU requirement. The documented NVFP4
checkpoint is text-only: its results do not qualify image or video execution.

Selection and numerical qualification are separate. Accuracy-only failures
Expand All @@ -82,7 +192,7 @@ p/q rejection correction for sampled V2 requests, and commits no rejected draft
state. This is a correctness-first implementation, not a speculative speedup
claim. V1 retains its greedy-only contract.

### Native validation scope
### Legacy native validation scope

All three admitted text modes have completed full-checkpoint native build and
inference. The existing owning scientific-answer check passes for ordinary
Expand All @@ -100,3 +210,9 @@ are still required even though the native family has no GPU allowlist.
Insufficient device memory is a runtime failure, not permission to silently
change precision or remove a companion. Inference failures are returned to the
caller and are never silently retried.

For raw media requests, pass typed image or video parts rather than inserting
special tokens into prompt text. The Edge adapter formats those parts with the
checkpoint's placeholders. If the processor's resize fallback exceeds the
compiled native visual profile, the runtime reports the limit instead of
silently shrinking the image to a single token.
Loading
Loading