-
Notifications
You must be signed in to change notification settings - Fork 19
Feat/fast dllm v2 dual cache #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,15 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """Fast-dLLM v2 hierarchical block decoding strategy.""" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from diffulex.strategy.fast_dllm_v2.config import FastDLLMV2StrategyConfig | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from diffulex.strategy.fast_dllm_v2.engine.kv_cache_manager import FastDLLMV2KVCacheManager | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from diffulex.strategy.fast_dllm_v2.engine.model_runner import FastDLLMV2ModelRunner | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from diffulex.strategy.fast_dllm_v2.engine.request import FastDLLMV2Req | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from diffulex.strategy.fast_dllm_v2.engine.scheduler import FastDLLMV2Scheduler | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| __all__ = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "FastDLLMV2StrategyConfig", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "FastDLLMV2KVCacheManager", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "FastDLLMV2ModelRunner", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "FastDLLMV2Req", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "FastDLLMV2Scheduler", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+3
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Re-export the attention helpers from the package root.
Suggested fix+from diffulex.strategy.fast_dllm_v2.attention import (
+ FastDLLMV2AttnMetaData,
+ fetch_fast_dllm_v2_attn_metadata,
+ reset_fast_dllm_v2_attn_metadata,
+ set_fast_dllm_v2_attn_metadata,
+)
from diffulex.strategy.fast_dllm_v2.config import FastDLLMV2StrategyConfig
from diffulex.strategy.fast_dllm_v2.engine.kv_cache_manager import FastDLLMV2KVCacheManager
from diffulex.strategy.fast_dllm_v2.engine.model_runner import FastDLLMV2ModelRunner
from diffulex.strategy.fast_dllm_v2.engine.request import FastDLLMV2Req
from diffulex.strategy.fast_dllm_v2.engine.scheduler import FastDLLMV2Scheduler
__all__ = [
+ "FastDLLMV2AttnMetaData",
"FastDLLMV2StrategyConfig",
"FastDLLMV2KVCacheManager",
"FastDLLMV2ModelRunner",
"FastDLLMV2Req",
"FastDLLMV2Scheduler",
+ "fetch_fast_dllm_v2_attn_metadata",
+ "reset_fast_dllm_v2_attn_metadata",
+ "set_fast_dllm_v2_attn_metadata",
]As per PR objectives, the Fast-dLLM v2 package should export config, engine, and attention helpers. 📝 Committable suggestion
Suggested change
🧰 Tools🪛 Ruff (0.15.18)[warning] 9-15: Apply an isort-style sorting to (RUF022) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| from diffulex.strategy.fast_dllm_v2.attention.metadata import ( | ||
| FastDLLMV2AttnMetaData, | ||
| fetch_fast_dllm_v2_attn_metadata, | ||
| reset_fast_dllm_v2_attn_metadata, | ||
| set_fast_dllm_v2_attn_metadata, | ||
| ) | ||
|
|
||
| __all__ = [ | ||
| "FastDLLMV2AttnMetaData", | ||
| "fetch_fast_dllm_v2_attn_metadata", | ||
| "reset_fast_dllm_v2_attn_metadata", | ||
| "set_fast_dllm_v2_attn_metadata", | ||
| ] |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,65 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from __future__ import annotations | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import torch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from dataclasses import dataclass | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from diffulex.attention.metadata import infer_prefill_flags | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from diffulex.mixin.multi_block.attention_metadata import MultiBlockAttnMetaDataMixin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @dataclass | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class FastDLLMV2AttnMetaData(MultiBlockAttnMetaDataMixin): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fdv2_cache_only: bool = False | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fdv2_mode: int = 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _FAST_DLLM_V2_ATTN_METADATA = FastDLLMV2AttnMetaData() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def set_fast_dllm_v2_attn_metadata( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| is_prefill: list[bool] | bool, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cu_seqlens_q: torch.Tensor | None = None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cu_seqlens_k: torch.Tensor | None = None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| max_seqlen_q: int = 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| max_seqlen_k: int = 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| slot_mapping: torch.Tensor | None = None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| need_kv_cache_store: bool | None = None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| context_lens: torch.Tensor | None = None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| page_tables: torch.Tensor | None = None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| page_size: int = 32, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| block_size: int = 32, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| kv_cache_layout: str = "unified", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fdv2_cache_only: bool = False, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fdv2_mode: int = 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) -> None: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| global _FAST_DLLM_V2_ATTN_METADATA | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| has_prefill, all_prefill = infer_prefill_flags(is_prefill) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _FAST_DLLM_V2_ATTN_METADATA = FastDLLMV2AttnMetaData( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| is_prefill=is_prefill if isinstance(is_prefill, list) else [bool(is_prefill)], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| enforce_eager=False, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cu_seqlens_q=cu_seqlens_q, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cu_seqlens_k=cu_seqlens_k, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| max_seqlen_q=max_seqlen_q, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| max_seqlen_k=max_seqlen_k, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| slot_mapping=slot_mapping, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| need_kv_cache_store_static=need_kv_cache_store, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| has_prefill_static=has_prefill, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| all_prefill_static=all_prefill, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| context_lens=context_lens, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| page_tables=page_tables, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| page_size=page_size, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| block_size=block_size, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| kv_cache_layout=kv_cache_layout, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fdv2_cache_only=bool(fdv2_cache_only), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fdv2_mode=int(fdv2_mode), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+20
to
+56
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Thread the real Line 40 pins Suggested fix def set_fast_dllm_v2_attn_metadata(
is_prefill: list[bool] | bool,
+ enforce_eager: bool = False,
cu_seqlens_q: torch.Tensor | None = None,
cu_seqlens_k: torch.Tensor | None = None,
@@
_FAST_DLLM_V2_ATTN_METADATA = FastDLLMV2AttnMetaData(
is_prefill=is_prefill if isinstance(is_prefill, list) else [bool(is_prefill)],
- enforce_eager=False,
+ enforce_eager=bool(enforce_eager),
cu_seqlens_q=cu_seqlens_q,📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def fetch_fast_dllm_v2_attn_metadata() -> FastDLLMV2AttnMetaData: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return _FAST_DLLM_V2_ATTN_METADATA | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def reset_fast_dllm_v2_attn_metadata() -> None: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| global _FAST_DLLM_V2_ATTN_METADATA | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _FAST_DLLM_V2_ATTN_METADATA = FastDLLMV2AttnMetaData() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import os | ||
|
|
||
| from dataclasses import dataclass | ||
|
|
||
| from diffulex.engine.strategy_config_registry import StrategyConfigRegistry | ||
| from diffulex.logger import get_logger | ||
|
|
||
|
|
||
| logger = get_logger(__name__) | ||
|
|
||
|
|
||
| @dataclass(frozen=True) | ||
| class FastDLLMV2StrategyConfig: | ||
| name: str = "fast_dllm_v2" | ||
| sub_block_size: int = 8 | ||
| block_size: int = 32 | ||
| use_block_cache: bool = True | ||
|
|
||
|
|
||
| @StrategyConfigRegistry.register("fast_dllm_v2") | ||
| def normalize_fast_dllm_v2_config(config) -> FastDLLMV2StrategyConfig: | ||
| if config.block_size * config.buffer_size != 32: | ||
| logger.warning( | ||
| "Fast-dLLM v2 paper defaults map Diffulex block_size * buffer_size to 32; " | ||
| "got block_size=%s, buffer_size=%s.", | ||
| config.block_size, | ||
| config.buffer_size, | ||
| ) | ||
| if config.buffer_size <= 1: | ||
| raise ValueError("decoding_strategy='fast_dllm_v2' requires buffer_size > 1.") | ||
|
|
||
| if config.multi_block_prefix_full: | ||
| logger.warning("Forcing multi_block_prefix_full=False for decoding_strategy=fast_dllm_v2.") | ||
| config.multi_block_prefix_full = False | ||
|
|
||
| if not config.enable_prefix_caching: | ||
| logger.info("Enabling prefix caching for decoding_strategy=fast_dllm_v2.") | ||
| config.enable_prefix_caching = True | ||
|
|
||
| use_block_cache = bool(getattr(config, "fdv2_use_block_cache", True)) | ||
| env_value = os.environ.get("DIFFULEX_FDV2_USE_BLOCK_CACHE") | ||
| if env_value is not None: | ||
| use_block_cache = env_value.strip().lower() not in {"0", "false", "no", "off"} | ||
|
|
||
| return FastDLLMV2StrategyConfig( | ||
| sub_block_size=int(config.block_size), | ||
| block_size=int(config.block_size) * int(config.buffer_size), | ||
| use_block_cache=use_block_cache, | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| from diffulex.strategy.fast_dllm_v2.engine.kv_cache_manager import FastDLLMV2KVCacheManager | ||
| from diffulex.strategy.fast_dllm_v2.engine.model_runner import FastDLLMV2ModelRunner | ||
| from diffulex.strategy.fast_dllm_v2.engine.request import FastDLLMV2Req | ||
| from diffulex.strategy.fast_dllm_v2.engine.scheduler import FastDLLMV2Scheduler | ||
|
|
||
| __all__ = [ | ||
| "FastDLLMV2KVCacheManager", | ||
| "FastDLLMV2ModelRunner", | ||
| "FastDLLMV2Req", | ||
| "FastDLLMV2Scheduler", | ||
| ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Apply the normal sampling constraints when seeding the next block.
Line 63 bypasses temperature/top-p/top-k and
forbidden_token_ids, then the pending token is written into the next block. This can seed a mask token or make FDV2 final-commit behavior inconsistent with the configured sampler.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents