Ampere (sm_86) compatibility for fp8-cast LoRA fusion and mono-audio input in a2vid#253
Open
Larry Bowden (fastflair) wants to merge 7 commits into
Open
Ampere (sm_86) compatibility for fp8-cast LoRA fusion and mono-audio input in a2vid#253Larry Bowden (fastflair) wants to merge 7 commits into
Larry Bowden (fastflair) wants to merge 7 commits into
Conversation
Updated download command to include additional model file.
For less censored animations and better prompt adherence
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Three issues prevent the distilled + a2vid pipelines from running on Ampere
GPUs (sm_86, e.g. RTX 3090) with
--offload cpuand mono audio input:1.
_read_scalesmmaps the full checkpoint to enumerate key namessafetensors.safe_open()on a 46 GB bf16 checkpoint requires the OS tocommit a 46 GB virtual-memory region. On hosts where total committable
memory (RAM + swap) is below that — common on WSL2 and consumer Linux
machines — this raises
Cannot allocate memory (12)during argumentparsing, before any model is loaded. A bf16 checkpoint has no
*_scaletensors, so the entire mmap was spent on
h.keys()returning an emptyresult.
2.
fuse_cast_fp8_weightuses a Triton kernel that doesn't compile on AmpereWhen the distilled LoRA is fused into fp8-cast weights (required for
dialogue/a2vid shots),
fused_add_round_kernelcasts tofp8e4nv(
float8_e4m3fn). Triton only supports this dtype on Ada (sm_89) andnewer; on Ampere it raises:
CompilationError: type fp8e4nv not supported in this architecture.
The supported fp8 dtypes are ('fp8e4b15', 'fp8e5')
A deterministic bf16 fallback already exists in
fuse_cast_fp8_weightbut was unreachable because the gate only checked
TRITON_AVAILABLE, notGPU capability.
3.
decode_audio_from_filereturns mono for mono input; a2vid requires stereoThe audio VAE's
conv_inhasin_channels=2and_validate_audio_waveformrejects mono. When TTS or any mono wav ispassed via
--audio-path, the pipeline crashes with:RuntimeError: expected input[1, 1, 274, 66] to have 2 channels, but got 1
Fix
fp8_cast.py_read_scales: read only the safetensors header (8-byte length prefix +JSON) to enumerate key names, avoiding the full-file mmap. The
safe_openpath is still taken when*_scalekeys are actually present(prequant fp8 checkpoints). Behavior is identical for all checkpoint
types; only the wasted mapping on bf16 is removed.
_cuda_cc()(cached compute capability) and_triton_can_stochastic_round(dtype): returnsTrueonly when Tritoncan compile the fp8 kernel for the given dtype on the current GPU
(
float8_e4m3fnrequires sm_89+;float8_e5m2requires sm_80+). Gatethe
fused_add_round_launchcall on this instead of bareTRITON_AVAILABLE. On unsupported hardware, the existing deterministicbf16 fallback is taken — no quality change for inference, no rounding
difference for prequant-fp8 checkpoints.
media_io.pydecode_audio_from_file: upmix mono waveforms to dual-mono stereo(
np.repeat(audio, 2, axis=0)) before returning. No-op for already-stereo input.
Testing
--offload cpu,--quantization fp8-cast, distilled checkpoint (bf16), distilled LoRA_read_scalesfix eliminates themmap crash; shots render end-to-end
shots render end-to-end after patch
_triton_can_stochastic_roundreturnsTrueon sm_89+, preserving stochastic rounding on capable hardware(untested by author — please verify on your CI)
Notes
The
_read_scaleschange does not affect prequant fp8 checkpoints: theearly-exit
if not scale_keys: return outis not taken, and the fullsafe_openpath runs as before. The header read is O(KB) regardless ofcheckpoint size, so there is no measurable overhead on the hot path.
The stereo upmix produces L=R dual-mono, which is appropriate for speech
input. The audio VAE and mux path treat both channels identically, so
there is no stereo-width artifact.