• Stefy Lanza (nextime / spora )'s avatar
    ocr: a lane is a page in flight, not a process (v0.3.43) · 6aa4aacd
    Stefy Lanza (nextime / spora ) authored
    The worker protocol was one request, one reply, strictly in order, so pages in
    flight WAS the process count — and a process costs ~600 MB of imported torch.
    That is the whole reason `surya_instances: 64` meant 64 processes, 37 GB and a
    nine-minute stall with the rented GPU idle at 2% KV-cache usage.
    
    In the served modes that memory buys nothing: the recognition VLM is on the pod,
    the local predictor holds no weights (1.7 MB of tokenizer and config on disk —
    surya-2 returns its own boxes, so the detection model is never even fetched),
    and the process rasterises a page and then waits on a socket. So a lane is a
    worker OBJECT inside the process that already exists, with its own predictor and
    its own page, sharing the one torch import. Effective concurrency is
    instances x lanes; `surya_lanes` defaults to 4, served modes only, built on
    demand.
    
    Three things make one process safe to drive concurrently:
    
      - every reply carries the id of the request it answers. Out-of-order replies
        are the point — a short page must not queue behind a dense one — and
        attributing one page's text to another request would be worse than losing
        it, so an unknown id is dropped rather than guessed at;
      - the token trace and the accent repairs are per THREAD. surya's hook is
        module-level, one _generate_one per process, and its sink was a list
        belonging to whichever worker object installed it last. Shared between
        lanes it would have filed one page's logprobs, and surya_repair_accents'
        rewrites, under a different page;
      - a worker that dies fails its pages instead of leaving them parked on a
        reply that is never coming, and killing the engine wakes everything
        waiting.
    
    A single-lane engine sends no ids and reads replies in order exactly as before,
    which is how paddle, docTR and surya-`local` are still driven. `lanes()` is
    asked for politely (_engine_lanes), because an engine is anything with
    recognize_image and a pool must not refuse to build over a capability an engine
    simply does not have.
    
    Tested against the REAL worker protocol with a stubbed engine: four 0.25s pages
    finish in under 0.75s, on four distinct lane objects, and six pages over two
    lanes never exceed two.
    Co-Authored-By: 's avatarClaude Opus 5 <noreply@anthropic.com>
    Claude-Session: https://claude.ai/code/session_01PxYHWbCAjjjD7A1rhFKtaW
    6aa4aacd
Name
Last commit
Last update
..
conftest.py Loading commit data...
ocr_lane_stub_worker.py Loading commit data...
test_admin_auth.py Loading commit data...
test_admin_forward_auth.py Loading commit data...
test_admin_remote_ui.py Loading commit data...
test_audio_ml_backends.py Loading commit data...
test_audio_ml_endpoints.py Loading commit data...
test_autoupgrade.py Loading commit data...
test_autoupgrade_recovers_a_down_server.py Loading commit data...
test_autoupgrade_sees_training.py Loading commit data...
test_broker_config.py Loading commit data...
test_broker_dispatch.py Loading commit data...
test_broker_protocol.py Loading commit data...
test_broker_shutdown.py Loading commit data...
test_broker_streaming.py Loading commit data...
test_burst_placement.py Loading commit data...
test_character_studio_fetch.py Loading commit data...
test_cluster.py Loading commit data...
test_compose.py Loading commit data...
test_forward_auth_peer_trust.py Loading commit data...
test_front_api_auth.py Loading commit data...
test_front_inflight_leak.py Loading commit data...
test_front_ocr_swap_gate.py Loading commit data...
test_image_has_c_compiler.py Loading commit data...
test_longcat_avatar_layout.py Loading commit data...
test_longcat_bsa.py Loading commit data...
test_longcat_cancellable.py Loading commit data...
test_longcat_checkpoint_resolve.py Loading commit data...
test_longcat_component_quant.py Loading commit data...
test_longcat_config_ui.py Loading commit data...
test_longcat_external_training.py Loading commit data...
test_longcat_int8_load.py Loading commit data...
test_longcat_lora.py Loading commit data...
test_longcat_orchestration.py Loading commit data...
test_longcat_packaging.py Loading commit data...
test_longcat_placement.py Loading commit data...
test_longcat_progress.py Loading commit data...
test_longcat_prompt_cache.py Loading commit data...
test_longcat_quantize.py Loading commit data...
test_longcat_scale.py Loading commit data...
test_longcat_tasks.py Loading commit data...
test_longcat_variants.py Loading commit data...
test_longcat_vendored_source.py Loading commit data...
test_longcat_venv_env.py Loading commit data...
test_longcat_vram_estimate.py Loading commit data...
test_longcat_worker.py Loading commit data...
test_manual_multimodal_test_client.py Loading commit data...
test_model_scan_cache.py Loading commit data...
test_ocr_accent_repair.py Loading commit data...
test_ocr_chandra.py Loading commit data...
test_ocr_confidence.py Loading commit data...
test_ocr_fanout.py Loading commit data...
test_ocr_language.py Loading commit data...
test_ocr_olmocr.py Loading commit data...
test_ocr_served_model.py Loading commit data...
test_ocr_token_trace.py Loading commit data...
test_ocr_unreadable_and_dpi.py Loading commit data...
test_ocr_vram_share_and_fallback.py Loading commit data...
test_ocr_worker_lanes.py Loading commit data...
test_olmocr_pod_tls.py Loading commit data...
test_oom_priority.py Loading commit data...
test_pod_log_drain.py Loading commit data...
test_proxy_logprobs.py Loading commit data...
test_remote_execution.py Loading commit data...
test_runpod_client_scale.py Loading commit data...
test_runpod_fleet_status.py Loading commit data...
test_runpod_global_volume.py Loading commit data...
test_runpod_ocr_remotization.py Loading commit data...
test_runpod_placement.py Loading commit data...
test_runpod_pod_extra_args.py Loading commit data...
test_runpod_reaper_grace.py Loading commit data...
test_runpod_scale_down.py Loading commit data...
test_runpod_schedule_region_spend.py Loading commit data...
test_runpod_warmup.py Loading commit data...
test_studio_composed_surfaces.py Loading commit data...
test_surya_runpod_fixes.py Loading commit data...
test_text_lora_to_pod.py Loading commit data...
test_township_api_key.py Loading commit data...
test_township_clip_geometry.py Loading commit data...
test_township_longcat.py Loading commit data...
test_township_page_js.py Loading commit data...
test_township_templates.py Loading commit data...
test_township_video_dataset.py Loading commit data...
test_upgrade_launcher.py Loading commit data...
test_video_as_b64_scope.py Loading commit data...
test_video_geometry.py Loading commit data...
test_vllm_share_self_tuning.py Loading commit data...
test_vram_releasers.py Loading commit data...
test_weight_stores.py Loading commit data...
test_whisper_server_local_models.py Loading commit data...