Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
aae638d
test(moe): a short prefill chunk loads its experts through the slot c…
YevheniiKotyrlo Sep 30, 2026
689f3d1
feat(moe): load a short prefill chunk's experts on demand through the…
YevheniiKotyrlo Sep 30, 2026
96c7310
test(moe): a dense model drops the demand-prefill threshold
YevheniiKotyrlo Sep 30, 2026
a8f24b1
test(moe): the demand-prefill threshold is refused off GPU decode
YevheniiKotyrlo Oct 1, 2026
8392c72
merge #676: feat(moe): load a short prefill chunk's experts on demand…
gdevenyi Oct 13, 2026
b880e7c
fix(kernel): size triton's autotune flush buffer to the device l2
gdevenyi Sep 25, 2026
47afdaf
test(utils): drive the async coalesced-pull test with asyncio.run
gdevenyi Oct 13, 2026
c0190aa
fix(engine): keep multimodal placeholder ids out of the repetition-pe…
gdevenyi Sep 24, 2026
3af6e25
fix(engine): apply the repetition penalty from device state, not a pe…
gdevenyi Sep 25, 2026
1e32ddb
fix(server): clarify unsupported response_format error text
Oct 5, 2026
9586885
fix(mm): classify image fetch errors and re-check redirect targets
Avicennasis Oct 3, 2026
cbe217b
test(engine): cover presence/frequency penalties on the greedy and sa…
gdevenyi Sep 25, 2026
d8d261b
perf(model): fuse hc combine with the next block's RMSNorm via hc_com…
Oct 2, 2026
7ec5a11
fix(kernel): bit-exact rmsnorm reduction tree in hc_combine_norm
Oct 2, 2026
c039107
test(kernel): bitwise pin for hc_combine_norm against the split path
Oct 2, 2026
0aa00e4
fix(server): soft-accept OpenAI response_format json_object/json_schema
Oct 5, 2026
97758b6
refactor(server): drop response_format system-hint injection
Oct 5, 2026
941fe3b
test(engine): drop the pre-volta sampling penalty test, whose torch f…
gdevenyi Oct 13, 2026
8eb353b
fix(moe): align on triton past sgl_kernel's 1024-expert limit
gdevenyi Oct 13, 2026
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
3 changes: 2 additions & 1 deletion docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ See [models.md](models.md#moe-strategies) for what each strategy does.
| `--moe-cpu-threads` | physical cores | CPU worker threads for the cpu/hybrid executor |
| `--moe-cpu-layers` | all on GPU | With `offload`: which MoE layers decode on CPU (`3,7,11`, a count, a fraction, or `auto`). `auto` is for Windows/WSL only, where CUDA pinned memory is capped; every value needs an expert format the CPU executor serves (bf16, fp8_block, nvfp4, mxfp4) |
| `--moe-hybrid-max-fetch` | auto | With `hybrid`: max experts fetched over PCIe per layer per step; rest computed on CPU |
| `--moe-prefill-demand-tokens` | 0 | Prefill: a chunk of at most this many tokens loads only the experts it routes to, through the expert cache as decode does (GPU decode only); 0 streams whole layers |
| `--moe-prefill-hit-d2d` | off | Prefill: copy cache-hit experts device-side, stream only misses (CUDA >= 13) |
| `--disable-moe-prefill-overlap` | overlap on | Disable the two-buffer prefill copy overlap |

Expand Down Expand Up @@ -202,7 +203,7 @@ so a client can gate its attachment controls without reading the checkpoint conf
| `--image-min-tokens`, `--image-max-tokens` | processor defaults | Per-image token budget: the image processor resizes every image to take between these many tokens, converted to the family's own units by its processor. A family with fixed budgets honors the maximum only and refuses one below its smallest budget at start-up |
| `--mm-processor-kwargs` | none | JSON object of extra keyword arguments for the checkpoint's image processor call, for knobs the token budget does not cover; applied after the budget, so an explicit key wins |
| `--mm-embed-cache-device` | cpu | Where encoded image embeddings live between prefill chunks. `cpu` keeps them out of the VRAM budget; `cuda` skips the copy back |
| `--allowed-media-domains` | any | Comma-separated hostname allowlist for image URLs; requests for other domains are rejected with a 400. Empty allows any domain |
| `--allowed-media-domains` | any | Comma-separated hostname allowlist for image URLs; requests for other domains are rejected with a 400. Empty allows any domain. Redirects are re-checked against the list and may not land on a private or loopback address |
| `--allowed-local-media-path` | off | Directory `file://` image refs may be read from; unset rejects local files |

## ft shell
Expand Down
11 changes: 7 additions & 4 deletions python/freetoken/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class SamplingParams:
# min_p: drop tokens whose probability is below min_p x the top probability.
min_p: float = 0.0
# OpenAI presence/frequency penalties over the generated tokens; repetition_penalty is the
# HF/vLLM multiplicative penalty over prompt + generated tokens (1.0 = off).
# HF/vLLM multiplicative penalty over prompt + generated tokens (1.0 = off). The sampler
# keeps their state on the device (Req.output_token_counts, Req.prompt_token_mask).
presence_penalty: float = 0.0
frequency_penalty: float = 0.0
repetition_penalty: float = 1.0
Expand Down Expand Up @@ -60,11 +61,10 @@ def is_greedy(self) -> bool:

@property
def needs_logits_processing(self) -> bool:
# the penalties are not LogitsPlan work: the sampler applies them from its own
# device-side state (Sampler.prepare's penalties).
return bool(
self.min_p > 0.0
or self.presence_penalty != 0.0
or self.frequency_penalty != 0.0
or self.repetition_penalty != 1.0
or self.logit_bias
or self.min_tokens > 0
)
Expand Down Expand Up @@ -106,7 +106,10 @@ class Req:
# handler must not free resources under an in-flight forward; it sets this flag and
# _process_last_data frees the request when the batch drains (after copy_done.synchronize).
aborted: bool = False
output_token_counts: torch.Tensor | None = field(default=None, init=False, repr=False)
stop_decode_status: DecodeStatus | None = None
# [vocab] bool on the device: the prompt's ids, for repetition_penalty. Built once.
prompt_token_mask: torch.Tensor | None = field(default=None, init=False, repr=False)

def __post_init__(self) -> None:
assert self.input_ids.is_cpu
Expand Down
1 change: 1 addition & 0 deletions python/freetoken/engine/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class EngineConfig:
moe_cache_auto: bool = False
kv_reserve_tokens: int = 8192 # KV floor for --moe-cache-auto; small by design (MoE-priority)
moe_cache_policy: str = "lru"
moe_prefill_demand_tokens: int = 0
moe_prefill_overlap: bool = True
# Prefill hit/miss split: serve cache-resident experts D2D during prefill
# prefetch instead of re-streaming the full layer over PCIe. Needs CUDA >= 12.8
Expand Down
5 changes: 5 additions & 0 deletions python/freetoken/engine/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,9 @@ def __init__(self, config: EngineConfig):
logger.info_rank0(f"Free memory before loading model: {mem_GB(init_free_memory)}")

# ======================= Model initialization ========================
from freetoken.kernel.triton.autotune_cache import bound_autotune_flush_buffer

bound_autotune_flush_buffer(self.device.index)
set_rope_device(self.device)
with torch.device("meta"), torch_dtype(config.dtype):
self.model = create_model(config.model_config)
Expand Down Expand Up @@ -947,6 +950,7 @@ def _init_offload_moe_cache(self, config: EngineConfig) -> OffloadMoeCache:
cache_size=config.moe_cache_size,
device=self.device,
cache_policy=config.moe_cache_policy,
prefill_demand_tokens=config.moe_prefill_demand_tokens,
prefill_overlap=config.moe_prefill_overlap,
prefill_hit_d2d=config.moe_prefill_hit_d2d,
quant_format=banks.quant_format,
Expand Down Expand Up @@ -1868,6 +1872,7 @@ def _auto_cpu_layers(config: EngineConfig, num_moe_layers: int, *, reserved: int
"moe_cpu_layers": None,
"moe_cpu_threads": 0,
"moe_hybrid_max_fetch": -1,
"moe_prefill_demand_tokens": 0,
"moe_prefill_overlap": True,
"moe_prefill_hit_d2d": False,
"expert_load": "auto",
Expand Down
Loading