🚀[FEA]: Update FLARE++ to the v2 reference design and add token-sharded context parallelism for FLARE/FLARE++
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Domain
- distributed-systems, machine-learning
Research direction
Start by reading the existing implementations in physicsnemo.nn.FLAREPlusPlus, physicsnemo.models.flare.FLAREPlusPlus, and GeoTransolver, then compare them with FLAREPPMixer in pdebench/models/mixer_backbone.py. For context parallelism, study pdebench/distributed/flare_cp.py and flare_encode in pdebench/models/flarepp.py alongside Appendices A and B of the linked paper. Done means implementing either the v2 mixer or token-sharded support for FLARE and FLAREPlusPlus without the current context-parallelism rejection.
Written by the indexing model from the issue text.
Description
Is this a new feature, an improvement, or a change to existing functionality?
Improvement
How would you describe the priority of this feature request
Medium
Please provide a clear description of problem you would like to solve.
cc @coreyjadams @mnabian
Following up on #1150 (FLARE), I wanted to share the updated version of FLARE++.
- Paper (v2): FLARE++: Low-rank attention with attention-synthesized routing
- Blog post: FLARE++: Stop compressing every field the same way
- Code: https://github.com/vpuri3/FLARE.py
It's great to see FLARE++ already landed in #1940 (physicsnemo.nn.FLAREPlusPlus, physicsnemo.models.flare.FLAREPlusPlus, and GALE_FPP in GeoTransolver). That implementation follows the v1 preprint, so I want to clarify how v1 and v2 relate.
v1 vs. v2. v1 was preliminary work that we posted so there would be something public before my PhD defense. Because it was premature, we didn't release any code with it. v2 (our ICLR submission) is the polished version and has several improvements. What v1 calls FLARE++ is Simplified FLARE++ in v2 (Appendix A, "Simplified FLARE++"). The model v2 calls FLARE++ is the updated mixer described below.
Two things in v2 should be of interest to the team:
1. The FLARE++ token mixer as a replacement for FLARE
Reference: FLAREPPMixer in pdebench/models/mixer_backbone.py. Appendix A of v2 covers the design in full.
Changes from v1 (= the #1940 implementation) to v2:
- Normalizing the synthesis call: head-wise normalization of the seeds and the synthesis keys/values (Appendix A, "Normalizing the synthesis call").
- Fixed reference and gate: the routing query is a learned fixed query plus a per-head sigmoid-gated synthesized term,
q = q_fixed + σ(g) · q_dynamic(Appendix A, "Fixed reference and gate"). With the gate closed, the mixer reduces to FLARE. - Near-identity feature projections: residual-MLP key/value projections initialized near identity (Appendix A, "Near-identity feature projections").
- Three input projections instead of four: the synthesis keys and values are shared (Appendix A, "Sharing synthesis keys and values"). This saves one $C \to C$ projection per block without hurting accuracy in our experiments.
The normalization and initialization choices in Appendix A drastically improve early-training stability and help FLARE++ converge better. Appendix A also explains why synthesized routing queries are hard to optimize without them ("Optimization difficulty of synthesized routing queries"). "Operations in one block" in Appendix A lists the per-block operation sequence of FLARE, FLARE++, and Simplified FLARE++ side by side.
Two results from Appendix D support this:
- Smaller seed variance (Appendix D.1): over ten seeds on Elasticity, FLARE++ has a smaller spread than FLARE. Its coefficient of variation is about 5% (0.37–0.43% test error), against about 11% for FLARE (0.58–0.86%).
- Lower mixed-precision sensitivity (Appendix D.2): FLARE++ is the least precision-sensitive mixer in the sweep. Its FP16 error stays within 8% of its FP32 error at every depth.
2. Multi-GPU context parallelism for FLARE and FLARE++
Reference: pdebench/distributed/flare_cp.py. The model calls it through flare_encode in pdebench/models/flarepp.py. Appendix B of v2 has the complete derivation.
Point tokens are sharded across ranks, and no rank ever gathers the full sequence. The distributed encoder is exact: each rank runs a fused local SDPA against its shard. The rank then contributes only latent-sized outputs and log-sum-exp statistics to a collective, which rebuilds the globally normalized attention (FlareEncoderCPFlash / FlareFlashCPFunction, with a custom backward). Decoding stays local. FLARE calls this encoder once per block. FLARE++ calls it twice, once for query synthesis and once for the physical-value gather. Communication therefore depends on $M$ and the channel width, not on $N$.
Appendix B covers:
- the token-sharded representation
- the exact distributed encoder
- the numerically stable reductions
- the FLARE and FLARE++ communication schedules
- the backward pass
- measured scaling
#1940 added token-sharded FLARE++ and then reverted it, and it currently rejects context parallelism explicitly. This encoder could fill that gap for both FLARE and FLAREPlusPlus.
I'm happy to help with a PR for either piece, or to review.
Describe any alternatives you have considered
No response
- Dominant language
- Python
- Stars
- 3.4k
- Forks
- 828
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 81
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from NVIDIA/physicsnemo
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
NVIDIA/physicsnemo#2214 ·
Maintainers usually reply within 2 days
-
Wasserstein CDF distance uses the first width for every binPossibly taken @sylvesterkaczmarek claimed this 31 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
NVIDIA/physicsnemo#2042 ·
Maintainers usually reply within 2 days
-
🐛[BUG]: Darcy2D Jacobi kernel divides grad(k)·grad(u) by 2dx instead of 4dx², so the data doesn't solve the Darcy equationMay be free again @coreyjadams claimed this 29 days ago, and no pull request is open. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
NVIDIA/physicsnemo#2036 · 2 comments · 1 assignee ·
Maintainers usually reply within 2 days
-
🐛[BUG]: MHD_PDE equation "B_grad_u" uses v * Bx.diff(y) instead of By * u.diff(y)Possibly taken @aaguadob claimed this 37 days ago. Open? - Needs Triage bug
Difficulty 1/5 Under an hour Newbie friendliness 92/100
NVIDIA/physicsnemo#2021 ·
Maintainers usually reply within 2 days
-
🐛[BUG]: Diffusion(time=True) in darcy_physics_informed/utils.py silently drops the time-derivative termPossibly taken @aaguadob claimed this 37 days ago. Open? - Needs Triage bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
NVIDIA/physicsnemo#2020 ·
Maintainers usually reply within 2 days
All issues in NVIDIA/physicsnemo
Similar issues
-
bug ready-for-dev
Difficulty 1/5 1-3 hours Newbie friendliness 92/100
OpenHands/extensions#897 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
tensorflow/datasets#11253 ·
Maintainers usually reply within 1 day
-
fix(core): a config section with all keys commented out crashes startupPossibly taken @Aryanbhargava18 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
kubeflow/mcp-server#512 ·
Maintainers usually reply within 1 day
-
Stop trusting the compromised eMudhra CA certificatesPossibly taken @anth-volk claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
PolicyEngine/uk-triple-lock#54 ·
Maintainers usually reply within 1 day
-
DBFS append mode silently overwrites existing filesPossibly taken @IlyaKhalafi claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
fsspec/filesystem_spec#2429 ·
Maintainers usually reply within 1 day