[Model] Add opt-in runtime abliteration for Qwen3.5/Qwen3.8
Project a unit refusal direction out of the residual-stream writes (attention, linear-attention and MLP outputs, and token embeddings) at runtime, enabled by VLLM_ABLITERATION pointing to a JSON or safetensors file with a refusal_direction vector. A bare name resolves to VLLM_ABLITERATION_DIR, default /opt/vllm/abliteration. For one direction this equals the weight edit W' = W - r(r^T W), so a base checkpoint reproduces its abliterated release with no extra weights. Unset, the path loads nothing and adds no work. Co-Authored-By: Hinata <hinata@idihore.id> Signed-off-by: MOVZX <movzx@yahoo.com>
This commit is contained in:
@@ -318,6 +318,17 @@ if TYPE_CHECKING:
|
||||
"""If set, vLLM will skip model name validation in API requests.
|
||||
This allows any model name to be accepted in the 'model' field of requests,
|
||||
making the server model-name agnostic. Useful for proxy/gateway scenarios."""
|
||||
VLLM_ABLITERATION: str | None = None
|
||||
"""Switch for runtime abliteration: a path to a JSON file holding a
|
||||
``refusal_direction`` list of length ``hidden_size``, a safetensors file
|
||||
holding that tensor, or a bare name resolved to
|
||||
``$VLLM_ABLITERATION_DIR/<name>.json``. When set, that direction is
|
||||
projected out of the attention, linear-attention, MLP and token-embedding
|
||||
outputs, which makes a base checkpoint behave like its abliterated release.
|
||||
See ``vllm/model_executor/models/abliteration.py``."""
|
||||
VLLM_ABLITERATION_DIR: str | None = None
|
||||
"""Directory that bare ``VLLM_ABLITERATION`` names resolve to. Defaults to
|
||||
``/opt/vllm/abliteration``."""
|
||||
VLLM_ELASTIC_EP_SCALE_UP_LAUNCH: bool = False
|
||||
VLLM_ELASTIC_EP_DRAIN_REQUESTS: bool = False
|
||||
VLLM_MEMORY_PROFILER_ESTIMATE_CUDAGRAPHS: bool = True
|
||||
@@ -2173,6 +2184,14 @@ environment_variables: dict[str, Callable[[], Any]] = {
|
||||
os.getenv("VLLM_SKIP_MODEL_NAME_VALIDATION", "0").strip().lower()
|
||||
in ("1", "true")
|
||||
),
|
||||
# Switch for runtime abliteration: a JSON file with a "refusal_direction"
|
||||
# list, a safetensors file with that tensor, or a bare name resolved to
|
||||
# $VLLM_ABLITERATION_DIR/<name>.json. When set, that unit direction is
|
||||
# projected out of the residual-stream writes of the attention,
|
||||
# linear-attention and MLP blocks, and of the token embeddings.
|
||||
"VLLM_ABLITERATION": lambda: os.getenv("VLLM_ABLITERATION"),
|
||||
# Directory that bare VLLM_ABLITERATION names resolve to.
|
||||
"VLLM_ABLITERATION_DIR": lambda: os.getenv("VLLM_ABLITERATION_DIR"),
|
||||
# Whether it is a scale up launch engine for elastic EP,
|
||||
# Should only be set by EngineCoreClient.
|
||||
"VLLM_ELASTIC_EP_SCALE_UP_LAUNCH": lambda: bool(
|
||||
|
||||
Reference in New Issue
Block a user