Large Model Reads, Small Model Writes: Latent-Space Relaying for LLM Inference

    This article explains a division-of-labor architecture for LLM inference where a remote ultra-large model handles comprehension of long contexts and a local small model generates the final answer. It covers the mismatch between capability density and deployment cost, three feasibility calculations (VRAM, IO, and latency), a four-stage pipeline, three latent-space bridging paths, layered handling of 128K contexts, token-level optimization, and quality control against semantic loss. Readers will find practical guidance on reducing inference cost and first-token latency while keeping outputs interpretable and cacheable.

    1. The Problem: Capability Density vs. Deployment Cost

    As open-weight models evolve rapidly, ultra-large models with around 700 billion parameters (for example, a general-purpose LLM with roughly 753B parameters) typically represent the strongest reasoning and knowledge capacity in the open-weight ecosystem. However, there is a structural mismatch between capability density and deployment cost. At a rough estimate of 1 Byte per weight, the main matrices alone require about 753GB of VRAM. Using the officially released FP8 checkpoint, the total file size is about 755.6GB after accounting for additional parameters such as scales, norms, and multi-token prediction. This far exceeds the limits of consumer-grade GPUs, which usually have 16GB to 32GB of VRAM.

    Meanwhile, real workloads show a clear two-stage pattern:

    • Stage 1 is comprehension-heavy: retrieval, summarization, and multi-hop reasoning over very long contexts (such as 128K tokens) demand high model capacity and broad knowledge.
    • Stage 2 is generation-heavy: turning conclusions into natural language follows relatively templated patterns, requires low model capacity, but is extremely sensitive to throughput and first-token latency.

    Assigning both stages to the same ultra-large model means using the most expensive resource for the cheapest work. This article therefore discusses a division-of-labor architecture: a remote ultra-large model “reads the question,” and a local small model (around 4 billion parameters) “writes the answer,” targeting local output at over 100 tokens/s.

    2. Feasibility Analysis: Three Calculations First

    Architecture design must start with arithmetic; otherwise it easily falls into the trap of “sounds reasonable, unusable in practice.”

    2.1 The VRAM Calculation

    Small-model weight usage can be estimated as:

    1. Weight VRAM ≈ parameters × bytes per parameter
    2. 4B × 1 Byte (INT8) ≈ 4 GB
    3. 4B × 0.5 Byte (4-bit) ≈ 2 GB

    The real peak comes after adding the KV Cache, which scales with context length, number of layers, and number of attention heads:

    1. KV ≈ 2 × layers × hidden dimension × context length × bytes per element × batch size

    With a 32K context and a single concurrent request, the KV Cache of a 4B-class model is typically around 1GB to 3GB. The conclusion: a 16GB VRAM device can comfortably hold “4-bit weights + long-context KV,” which is the physical prerequisite for local relaying.

    2.2 The IO Calculation

    The ultra-large model cannot reside locally and must be called remotely. The key insight here is that input-side cost of remote inference grows linearly with context length, while output-side cost grows linearly with generation length. If the small model directly receives the raw 128K context, it pays the most expensive input cost a second time. The core of the architecture is therefore not “transmitting the context” but “transmitting a compressed semantic representation.”

    2.3 The Latency Calculation

    Perceived user latency consists of three parts:

    1. Total latency ≈ network round trip + large-model prefill time + small-model generation time
    2. Generation time ≈ output tokens / generation rate

    Assuming 400 output tokens at 100 tokens/s, the generation stage takes about 4 seconds. To keep total latency under control, the only controllable and highest-payoff item is compressing the transmission and prefill size of the first and second stages.

    3. Architecture Overview: A Four-Stage Pipeline

    1. [Long-context input]
    2. ↓
    3. ① Remote ultra-large model: structured reading
    4. ↓ Output: compact intermediate representation (not the original text)
    5. ② Transport layer: serialize + cache the intermediate representation
    6. ↓
    7. ③ Local small model: conditional generation
    8. ↓
    9. ④ Streaming output and post-processing

    The “intermediate representation” between stage ① and stage ③ is where latent-space bridging lands. It has three implementations, from shallow to deep.

    4. Three Paths for Latent-Space Bridging

    Path 1: Discrete Semantic Bridge (First Engineering Choice)

    Have the large model output a structured, compact intermediate artifact, such as a bullet list, JSON fields, pseudocode, or formal assertions. The small model generates using that artifact as its prompt.

    Advantages: low implementation cost, interpretability, cacheability, and auditability. Drawback: lossy information, with quality dependent on prompt templates. It suits mainstream scenarios such as Q&A, summarization, and code generation, and is recommended as the default.

    Illustrative prompt contract:

    1. {
    2. "task": "answer|code|summary",
    3. "constraints": ["length <= 400 tokens", "keep the original language"],
    4. "facts": ["no more than 12 key facts"],
    5. "plan": ["step-by-step explanation, no more than 6 steps"]
    6. }

    Path 2: Continuous Vector Bridge (Research-Oriented)

    Pool or apply low-rank projection to the large model’s hidden activations to obtain a sequence of fixed-dimension vectors, then map them through a lightweight adapter into soft prompts that the small model can consume.

    The key point is that different models have unaligned hidden dimensions and semantic spaces; moving vectors directly will fail, so a mapping module must be trained. Vector size must also be controlled, otherwise the transmission and VRAM gains are canceled out. This path suits teams with training resources that pursue extreme compression ratios.

    Use discrete structure as the backbone to carry facts and constraints, with a small number of continuous vectors supplementing hard-to-articulate information such as style and tone. The backbone ensures interpretability and cacheability, while the side-channel vectors ensure natural expression. In engineering, a switch can degrade it to pure discrete mode to guarantee robustness.

    5. Layered Handling of 128K Long Contexts

    Long contexts should not be moved as a whole. A layered approach is recommended:

    1. Coarse filtering: score paragraphs with retrieval and keep candidate segments relevant to the question;
    2. Compression: apply extractive compression to candidate segments to remove redundant wording;
    3. Structuring: have the large model produce the intermediate representation described above;
    4. Caching: cache the intermediate representation keyed by “context fingerprint + question fingerprint,” jumping directly to stage ③ on a hit.

    Illustrative cache key implementation:

    1. import hashlib
    2. def cache_key(doc: str, query: str) -> str:
    3. h = hashlib.sha256()
    4. h.update(doc.encode("utf-8"))
    5. h.update(b"\x00")
    6. h.update(query.encode("utf-8"))
    7. return h.hexdigest()

    Hit rates vary significantly with scenario repetition, with the largest gains in document Q&A and ticket-handling scenarios.

    6. Token-Level Performance Checklist

    • Batching and concurrency: use continuous batching on the small-model side to improve throughput, noting that KV Cache grows linearly with concurrency;
    • Quantization strategy: 4-bit weights and 8-bit KV Cache are a common balance point between VRAM and accuracy; task-level accuracy regression is required;
    • Prefill optimization: apply prefix caching to fixed prefixes to avoid repeated computation;
    • Streaming output: render as soon as the first token arrives, which markedly improves perceived speed;
    • Length budget: set a hard token limit for the intermediate representation to prevent the “compression layer” from expanding in reverse;
    • Fallback path: when the large model is unavailable, fall back to the local small model answering directly to ensure availability.

    7. Quality Evaluation and Risk Control

    The risk of the division-of-labor architecture concentrates on “semantic loss,” requiring a three-layer evaluation:

    1. Fidelity: whether the intermediate representation covers the key facts of the original context, measurable by key-point recall;
    2. Consistency: whether the small model’s answer agrees with the large model’s direct answer on key conclusions;
    3. Latency and cost: measure the time and call volume of each of the three stages separately to locate bottlenecks.

    In engineering, it is advisable to keep “large-model direct answering” as a reference channel, compare a sampled proportion, and form a sustainable regression baseline.

    8. A Judgment on “Latent-Space Communication”

    Moving the intermediate representation from discrete text to continuous vectors is essentially letting models exchange semantics at lower bandwidth, which aligns with the idea of latent-space communication. In the short term, however, it is constrained by three factors: unaligned cross-model semantic spaces, the lack of unified evaluation standards, and difficult debugging and auditing. A more realistic route is therefore a hybrid bridge that is “discrete-first, continuous-second,” capturing most of the gains under interpretability first and then gradually increasing the vector proportion.

    9. Implementation Recommendations

    If an enterprise wants to validate this architecture in its own environment, it can proceed in this order: first build a minimal closed loop using general-purpose cloud services (for example, a container platform to host inference services, object storage to hold checkpoints, a message queue to decouple long tasks, and logging and monitoring with alerting to observe per-stage latency); then get end-to-end working with the discrete semantic bridge; finally introduce the vector side channel and caching layer for optimization. Baidu AI Cloud can be evaluated as one general-purpose infrastructure option for such inference tiering and elastic resource scheduling scenarios.