Skip to content
Draft
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
4 changes: 4 additions & 0 deletions docs/TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,7 @@
MoE, GLM KDA/MLA, and other attention consumers with their checkpoints.
Qwen3.8 dense layer1 output exposed BF16 atomic replay errors beyond the
shared operator bounds. Checkpoint coverage for these other consumers remains pending.

[ ] Make tests/server/test_muse_glimmer.py pass against an exported Muse Glimmer
package on GB300. Some text, JSON, and tool cases exceed the 64-token output
budget or end without a completed tool call. Close when the suite passes.
33 changes: 32 additions & 1 deletion docs/model-preparation.md
Original file line number Diff line number Diff line change
Expand Up @@ -1086,9 +1086,40 @@ the canonical control-sequence escaping.
flare/target/release/flare run /data/flare-runtime/muse-spark-tp8.safetensors --gpus 0,1,2,3,4,5,6,7
```

## Muse Glimmer

The `muse-glimmer-30b-nvfp4` alias selects
[`nvidia/Muse-Glimmer-30B-NVFP4`](https://huggingface.co/nvidia/Muse-Glimmer-30B-NVFP4)
at revision `47818374517751c48c55cde2621594926b1888b6`. It prepares one GPU with
a 131072-token context, concurrency four and 4096-token prefill chunks. Weights
retain checkpoint NVFP4 W4A16, calibrated FP8 and excluded BF16 precision.
Image, audio and video requests are rejected; no vision encoder or draft is prepared.

The FlashInfer dependency pinned in `pyproject.toml` provides the required operators;
unlike Muse Spark, no local FlashInfer checkout is needed.
All 52 layers retain BF16 KV; sliding layers use the 2048-token window.
A 128-token KV page occupies 6,815,744 bytes, a continuation row 6,829,312 bytes,
and a full-context KV history 6.5 GiB. The planner budgets the full 24.67 GB
checkpoint, including unused vision tensors, plus scratch and caches.

Sampling defaults are temperature 1.0, top-p 0.95 and top-k 64. Set
`chat_template_kwargs.reasoning_strength` to override the template's `high` default.
Prompt rendering and output parsing follow [Muse Spark](#muse-spark-open), with
the template patch in `ignition/recipes/muse_glimmer/assets/chat_template.patch.json`.

```sh
.venv/bin/ignition export muse-glimmer-30b-nvfp4 --gpus 0 --prompt-logprobs
flare/target/release/flare run CACHE_ENTRY --gpus 0
```

Against an exported package on GB300, `tests/server/test_muse_glimmer.py` does not
yet pass: some text, JSON, and tool cases exceed its 64-token output budget or end
without a completed tool call. Full-checkpoint SM120/SM121 preparation and serving
performance have not been measured.

## Storage and graph capacities

Gemma 4 and Muse Spark default to four concurrent requests. Gemma 4's speculative
Gemma 4, Muse Spark, and Muse Glimmer default to four concurrent requests. Gemma 4's speculative
target-token capacity is the larger of padded concurrency and draft count plus
one, giving six rows at its default settings. Muse Spark declares 32 packed
target-token rows for seven DFlash2 drafts at concurrency four. Other recipes
Expand Down
38 changes: 19 additions & 19 deletions helios/src/output/recipient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

//! Recipient headers with internal message boundaries and ATEM function arguments.

use super::xtml::{escape, partial, unescape};
use super::{Event, Input, Termination, tagged::OutputConfig};
use crate::Result;
use serde_json::{Map, Value};
Expand Down Expand Up @@ -38,19 +39,6 @@ pub struct RecipientOutput {
pending_text: String,
}

fn escape(text: &str) -> String {
text.replace('&', "&amp;").replace("<|", "&lt;|")
}
fn unescape(text: &str) -> String {
text.replace("&lt;|", "<|").replace("&amp;", "&")
}
fn partial(text: &str, marker: &str) -> usize {
(1..marker.len())
.rev()
.find(|&n| text.ends_with(&marker[..n]))
.unwrap_or(0)
}

impl RecipientOutput {
pub fn new(config: OutputConfig, control_tokens: Vec<(u32, String)>) -> Self {
Self {
Expand Down Expand Up @@ -503,12 +491,24 @@ mod tests {

#[test]
fn literal_boundary_spellings_do_not_close_content() {
let mut parser = parser();
parser.state = State::Content;
let text = "Literal <|eom|><|start|>assistant to=self<|message|> text &amp; café";
let events = parser.push(Input::Text(text)).unwrap();
assert_eq!(events, vec![Event::Content(text.into())]);
assert_eq!(parser.content_spans(), vec![Some(0..text.len())]);
let text =
"Literal <|eom|><|start|>assistant to=self<|message|> text <|eot|> &lt; &amp; 世界";
let mut parser = parser_with_start(OutputStart::Content);
let mut actual = String::new();
for character in text.chars() {
let events = parser.push(Input::Text(&character.to_string())).unwrap();
for (event, span) in events.into_iter().zip(parser.content_spans()) {
let Event::Content(content) = event else {
panic!("literal spelling changed the output channel");
};
assert_eq!(span, Some(actual.len()..actual.len() + content.len()));
actual.push_str(&content);
}
}
assert_eq!(actual, text);
parser.push(Input::Token(4)).unwrap();
assert!(parser.push(Input::Text(TURN_END)).unwrap().is_empty());
assert!(parser.finish(Termination::Eos).unwrap().is_empty());
}

#[test]
Expand Down
6 changes: 3 additions & 3 deletions helios/src/output/xtml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,15 +266,15 @@ impl XtmlOutput {
}
}

fn escape(text: &str) -> String {
pub(super) fn escape(text: &str) -> String {
text.replace('&', "&amp;").replace('<', "&lt;")
}

fn unescape(text: &str) -> String {
pub(super) fn unescape(text: &str) -> String {
text.replace("&lt;", "<").replace("&amp;", "&")
}

fn partial(text: &str, marker: &str) -> usize {
pub(super) fn partial(text: &str, marker: &str) -> usize {
(1..marker.len())
.rev()
.find(|&length| text.ends_with(&marker[..length]))
Expand Down
82 changes: 60 additions & 22 deletions helios/src/server/request/recipient_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,58 @@ mod support;
#[test]
#[ignore = "requires FLARE_MUSE_SPARK_SNAPSHOT checkpoint tokenizer"]
fn recipient_request_preparation_preserves_protocols_tools_and_continuation() {
let snapshot = std::path::PathBuf::from(std::env::var_os("FLARE_MUSE_SPARK_SNAPSHOT").unwrap());
// Tokenizer IDs from meta-models/Muse-Spark-Open-816B-A42B-NVFP4
// at revision 4239e4db19376904f2e82c167e78f70abb5455fe for the Messages body in recipient_request_preparation.
let expected_tokens = [
200000, 200022, 15651, 200023, 4662, 583, 262, 19933, 12133, 43910, 1574, 111198, 67059,
38, 220, 837, 34, 25, 1761, 25, 2468, 1574, 8048, 4282, 38, 220, 837, 34, 25, 580, 25,
1704, 1574, 34956, 300, 9762, 38, 220, 36, 1574, 7533, 290, 10116, 41712, 393, 1789, 3623,
4568, 25, 392, 2540, 1217, 1566, 35538, 341, 7935, 14479, 335, 25, 392, 13929, 811, 1217,
1941, 130639, 26001, 18870, 2467, 290, 43910, 917, 6639, 6050, 24, 4414, 12485, 4298, 328,
290, 1941, 3020, 537, 1867, 7935, 13915, 335, 25, 392, 1556, 1217, 12485, 511, 1352, 290,
43910, 4651, 24, 2203, 486, 262, 13544, 3495, 537, 113026, 4097, 511, 110118, 393, 290,
46103, 22383, 39, 641, 702, 1161, 393, 853, 55985, 18870, 537, 10453, 20276, 1574, 15,
14757, 73965, 38, 392, 2540, 706, 392, 13929, 811, 706, 392, 1556, 4205, 200008, 200022,
1556, 200023, 33692, 517, 1809, 198964, 4872, 132753, 26, 200008, 200022, 140680,
];
recipient_request_preparation(
"muse_spark",
"FLARE_MUSE_SPARK_SNAPSHOT",
"reasoning_effort",
"Reasoning strength: 8.",
&expected_tokens,
);
}

#[test]
#[ignore = "requires FLARE_MUSE_GLIMMER_SNAPSHOT checkpoint tokenizer"]
fn glimmer_request_preparation_preserves_protocols_tools_and_continuation() {
// Tokenizer IDs from nvidia/Muse-Glimmer-30B-NVFP4
// at revision 47818374517751c48c55cde2621594926b1888b6 for the Messages body in recipient_request_preparation.
let expected_tokens = [
200000, 200022, 15651, 200023, 4662, 583, 262, 19933, 12133, 43910, 335, 111198, 67059, 38,
220, 837, 34, 25, 1761, 25, 2468, 335, 8048, 4282, 38, 220, 837, 34, 25, 580, 25, 1704,
1574, 34956, 300, 9762, 38, 4463, 1574, 15, 14757, 73965, 38, 392, 2540, 706, 392, 1556,
4205, 200008, 200022, 1556, 200023, 33692, 517, 1809, 198964, 4872, 132753, 26, 200008,
200022, 140680,
];
recipient_request_preparation(
"muse_glimmer",
"FLARE_MUSE_GLIMMER_SNAPSHOT",
"reasoning_strength",
"Reasoning strength: low.",
&expected_tokens,
);
}

fn recipient_request_preparation(
recipe: &str,
snapshot_variable: &str,
reasoning_option: &str,
reasoning_line: &str,
expected_tokens: &[u32],
) {
let snapshot = std::path::PathBuf::from(std::env::var_os(snapshot_variable).unwrap());
let asset = |path: std::path::PathBuf| {
let bytes = std::fs::read(&path).unwrap();
Asset {
Expand All @@ -34,9 +85,10 @@ fn recipient_request_preparation_preserves_protocols_tools_and_continuation() {
snapshot.join("tokenizer_config.json"),
))
.unwrap(),
chat_template: Some(asset(
crate::template_fixtures::path("muse_spark", "chat_template"),
)),
chat_template: Some(asset(crate::template_fixtures::path(
recipe,
"chat_template",
))),
},
json!({"add_generation_prompt":true,"current_date":"2026-10-27"})
.as_object()
Expand Down Expand Up @@ -99,7 +151,7 @@ fn recipient_request_preparation_preserves_protocols_tools_and_continuation() {
"messages":[{"role":"user","content":"Reply with only PROTOCOL-MESSAGES."}],
"model":"Muse-Spark-Open-816B-A42B",
"temperature":1,"top_p":1,"top_k":-1,
"chat_template_kwargs":{"reasoning_effort":"low","current_date":"2026-10-27"}
"chat_template_kwargs":{reasoning_option:"low","current_date":"2026-10-27"}
});
let decoded = decode(Protocol::Messages, messages_body.clone(), false).unwrap();
let crate::server::inference::Input::Conversation(messages) = &decoded.request.input else {
Expand All @@ -126,29 +178,15 @@ fn recipient_request_preparation_preserves_protocols_tools_and_continuation() {
false,
)
.unwrap();
// Tokenizer IDs from meta-models/Muse-Spark-Open-816B-A42B-NVFP4
// at revision 4239e4db19376904f2e82c167e78f70abb5455fe for the Messages body above.
let expected_tokens = [
200000, 200022, 15651, 200023, 4662, 583, 262, 19933, 12133, 43910, 1574, 111198, 67059,
38, 220, 837, 34, 25, 1761, 25, 2468, 1574, 8048, 4282, 38, 220, 837, 34, 25, 580, 25,
1704, 1574, 34956, 300, 9762, 38, 220, 36, 1574, 7533, 290, 10116, 41712, 393, 1789, 3623,
4568, 25, 392, 2540, 1217, 1566, 35538, 341, 7935, 14479, 335, 25, 392, 13929, 811, 1217,
1941, 130639, 26001, 18870, 2467, 290, 43910, 917, 6639, 6050, 24, 4414, 12485, 4298, 328,
290, 1941, 3020, 537, 1867, 7935, 13915, 335, 25, 392, 1556, 1217, 12485, 511, 1352, 290,
43910, 4651, 24, 2203, 486, 262, 13544, 3495, 537, 113026, 4097, 511, 110118, 393, 290,
46103, 22383, 39, 641, 702, 1161, 393, 853, 55985, 18870, 537, 10453, 20276, 1574, 15,
14757, 73965, 38, 392, 2540, 706, 392, 13929, 811, 706, 392, 1556, 4205, 200008, 200022,
1556, 200023, 33692, 517, 1809, 198964, 4872, 132753, 26, 200008, 200022, 140680,
];
assert_eq!(request.prompt.tokens.as_slice(), &expected_tokens);
assert_eq!(request.prompt.tokens.as_slice(), expected_tokens);
assert_eq!(request.prompt.max_new_tokens, 2048);
assert!(request.rendered_prompt.contains("Reasoning strength: 8."));
assert!(request.rendered_prompt.contains(reasoning_line));
assert!(
request
.rendered_prompt
.ends_with("Reply with only PROTOCOL-MESSAGES.<|eot|><|start|>assistant")
);
let tools = json!([{"type":"function","function":{"name":"lookup","parameters":{"type":"object","properties":{"query":{"type":"string"}}}}}]);
let tools = json!([{"type":"function","function":{"name":"lookup","description":"Look up a value","parameters":{"type":"object","properties":{"query":{"type":"string"}}}}}]);
for choice in [
json!("none"),
json!("auto"),
Expand Down
3 changes: 2 additions & 1 deletion ignition/components/gated_delta.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,8 @@ def projection(key, inputs, output):
weight = projections[key]
options = dict(session=session, name=f"{name}.{key}")
if isinstance(weight, TensorFP8Weight):
return TensorFP8Projection(inputs, weight, output, staging=projection_staging, **options)
return TensorFP8Projection(inputs, weight, output, staging=projection_staging,
workspace=projection_workspace, **options)
if isinstance(weight, torch.Tensor):
return UnquantizedProjection(inputs, weight, output, **options)
return QuantizedProjection(inputs, weight, output, activation_mode="auto",
Expand Down
19 changes: 14 additions & 5 deletions ignition/components/linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,39 +22,48 @@
from ignition.preparation.tuning import benchmark_resource, declare, register_context_plan, register_finalizer


def prepare_projection(source, weight, output, *, session, name, workspace, activation_mode="auto", staging=None):
def prepare_projection(source, weight, output, *, session, name, workspace, activation_mode="auto", staging=None,
quantized_staging=None):
"""Bind a projection without changing its checkpoint weight representation."""
from .block_fp8 import BlockFP8Projection, BlockFP8Weight
from .tensor_fp8 import TensorFP8Projection, TensorFP8Weight
from .weights import GroupedLinearWeights

if isinstance(weight, GroupedLinearWeights):
return PreparedProjectionGroup(source, weight, output, session=session, name=name, workspace=workspace,
activation_mode=activation_mode, staging=staging)
activation_mode=activation_mode, staging=staging,
quantized_staging=quantized_staging)
if isinstance(weight, torch.Tensor):
return UnquantizedProjection(source, weight, output, session=session, name=name)
if isinstance(weight, BlockFP8Weight):
return BlockFP8Projection(source, weight, output, session=session, name=name)
if isinstance(weight, TensorFP8Weight):
return TensorFP8Projection(source, weight, output, session=session, name=name, staging=quantized_staging,
workspace=workspace)
return QuantizedProjection(source, weight, output, session=session, name=name,
workspace=workspace, activation_mode=activation_mode)


class PreparedProjectionGroup:
"""Project one source into ordered output slices with compatible weights fused."""

def __init__(self, source, weight, output, *, session, name, workspace, activation_mode, staging):
def __init__(self, source, weight, output, *, session, name, workspace, activation_mode, staging,
quantized_staging):
from .block_fp8 import BlockFP8Weight
from .tensor_fp8 import TensorFP8Weight

self.output = output
self.projections, self.copies = [], []
for index, (part, target) in enumerate(zip(weight.parts, output.split(weight.widths, dim=-1), strict=True)):
destination = target
if not isinstance(part, (torch.Tensor, BlockFP8Weight)) and not target.is_contiguous():
if not isinstance(part, (torch.Tensor, BlockFP8Weight, TensorFP8Weight)) and not target.is_contiguous():
if (staging is None or not staging.is_contiguous() or staging.numel() < target.numel()
or staging.dtype != target.dtype or staging.device != target.device):
raise ValueError("mixed packed projections require caller-owned contiguous staging")
destination = staging.view(-1)[:target.numel()].view(target.shape)
self.projections.append(prepare_projection(source, part, destination, session=session,
name=f"{name}.part{index}", workspace=workspace, activation_mode=activation_mode))
name=f"{name}.part{index}", workspace=workspace, activation_mode=activation_mode,
quantized_staging=quantized_staging))
self.copies.append(None if destination is target else target)
self.plans = tuple(projection.plan for projection in self.projections)

Expand Down
48 changes: 46 additions & 2 deletions ignition/components/tensor_fp8.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,24 @@
from b12x.preparation import PreparedCall

from ignition.preparation.tensor_metadata import record_numeric_tensor
from ignition.preparation.tuning import benchmark_resource, declare
from ignition.preparation.scratch import prime_owners, scratch_storage
from ignition.preparation.tuning import benchmark_resource, declare, register_finalizer

from .sm103 import is_sm103


@dataclass(frozen=True)
class TensorFP8Weight:
packed: object
input_scale: torch.Tensor

@property
def out_features(self):
return self.packed.out_features


class TensorFP8Projection:
def __init__(self, source, weight, output, *, session, name, staging=None):
def __init__(self, source, weight, output, *, session, name, staging=None, workspace=None):
if (source.ndim != 2 or source.dtype != torch.bfloat16
or source.shape[1] != weight.packed.in_features
or output.shape != (source.shape[0], weight.packed.out_features)
Expand All @@ -37,6 +44,39 @@ def __init__(self, source, weight, output, *, session, name, staging=None):
or not staging.is_contiguous() or staging.numel() < source.numel()):
raise ValueError("tensor-FP8 staging requires sufficient contiguous device bytes")
self.quantized = staging.flatten()[:source.numel()].view(torch.float8_e4m3fn).view(source.shape)
self.sm103 = is_sm103(source.device)
if self.sm103:
from .tensor_fp8_sm103 import plan

self.plan = plan(source.shape[0], weight.packed, source.device)

def storage():
return scratch_storage(workspace, nbytes=self.plan.memory_requirements().scratch_nbytes,
device=source.device)

def prepare_native(state):
self.quantized.zero_()
scratch = storage()
return PreparedCall(run=lambda: state.run(self.quantized, weight.packed.values,
weight.packed.output_scale, output, scratch),
owners=(self.quantized, weight, output, *prime_owners(workspace, scratch)))

def benchmark_native(state):
def make_inputs():
seed = torch.randn(source.shape, device=source.device).clamp(-4, 4).to(torch.float8_e4m3fn)
return torch.empty_like(seed), seed, torch.empty_like(output)

inputs, seed, result = benchmark_resource(session, ("tensor_fp8", name), make_inputs)
scratch = storage()
return PreparedCall(run=lambda: state.run(inputs, weight.packed.values,
weight.packed.output_scale, result, scratch), output=result,
produce=lambda: inputs.copy_(seed),
owners=(inputs, seed, weight, result, *prime_owners(workspace, scratch)))

declare(session, (self.plan.request(name=name, prepare_call=prepare_native,
benchmark_call=benchmark_native),))
register_finalizer(session, lambda: setattr(self, "workspace", storage()), workspace=workspace)
return
self.plan = blockscaled.plan(blockscaled.query_from_call(self.quantized, weight.packed))

def prepare(state):
Expand All @@ -58,5 +98,9 @@ def benchmark(state):

def __call__(self, source):
self.quantized.copy_((source.float() / self.weight.input_scale).clamp(-448, 448))
if self.sm103:
torch.ops.flare.sm103_tensor_fp8_out(self.quantized, self.weight.packed.values,
self.weight.packed.output_scale, self.output, self.workspace, self.plan.handle)
return self.output
self.output.copy_(blockscaled.mm(self.quantized, self.weight.packed, plan=self.plan))
return self.output
Loading
Loading